Tuesday, 16 January 2024

Login System using perl catalyst MVC



1.install the required Below dependencies:

cpanm --installdeps .

Read more »

Labels:

Tuesday, 22 October 2019

place and plays @_ in perl?

Method 1:

sub Addition{ $a=\@_; ($a,$b,$c)=@$a; $sum=$a+$b+$c; } Addtion(10, 20, 30); print $sum; #60



Read more »

Labels:

Saturday, 11 March 2023

How to Build an Authentication API with JWT Token in Perl

Hi, In many web applications, user authentication is a critical feature that allows users to securely log in and access their data. One common approach to implementing authentication is to use JSON Web Tokens (JWT), which are a type of token-based authentication that can be used across multiple domains and platforms.

In this tutorial, we will show you how to build an authentication API with JWT token in Perl. We will be using the Mojolicious web framework, which is a powerful and flexible framework that makes it easy to build web applications in Perl.

Read more »

Labels: , , ,

Friday, 1 November 2019

perl - find missing numbers in array

Method 1:

@a = (1,3,4,6); @c = map $a[$_-1]+1..$a[$_]-1, 1..@a-1; print join(" ", @c);




Read more »

Labels:

Wednesday, 16 August 2023

Creating a Simple Blog Application in Perl

 create simple blog application that allows users to create, read, update, and delete (CRUD) blog posts. The application uses the Perl Catalyst MVC framework, DBIx::Class ORM for interacting with the database, and provides both REST and GraphQL APIs for accessing the data. The database can be  PostgreSQL.

Read more »

Labels:

Monday, 23 December 2024

Multiple-Choice Quiz on Python Dictionaries

  1. What is the primary structure used to store data in a Python dictionary?
    A) List
    B) Set
    C) Key-Value pairs
    D) Tuple

  2. Which of the following is true about the keys in a Python dictionary?
    A) They can be mutable data types
    B) They must be unique
    C) They can be of any data type, including lists
    D) They are automatically sorted

  3. How do you access the value associated with a key in a Python dictionary?
    A) Using the index number
    B) Using the key itself in square brackets
    C) Using the key in parentheses
    D) Using the key with a dot notation

  4. What will be the output of the following code: d = {'a': 1, 'b': 2}; print(d['b'])?
    A) 1
    B) ‘b’
    C) 2
    D) KeyError

  5. Which method would you use to add a new key-value pair to an existing dictionary?
    A) append()
    B) add()
    C) update()
    D) insert()

  6. If you want to remove a key-value pair from a dictionary, which method would you typically use?
    A) delete()
    B) pop()
    C) remove()
    D) discard()

  7. What will happen if you try to access a key that does not exist in a dictionary?
    A) It returns None
    B) It creates a new key with a default value
    C) It raises a KeyError
    D) It returns an empty string

  8. Which of the following methods can be used to retrieve all keys in a dictionary?
    A) keys()
    B) get_keys()
    C) list_keys()
    D) all_keys()

  9. How can you check if a specific key exists in a Python dictionary?
    A) Using the in operator
    B) Using the exists() method
    C) Using the check() method
    D) Using the includes() method

  10. In Python dictionaries, what is the time complexity for accessing a value by key?
    A) O(n)
    B) O(log n)
    C) O(1)
    D) O(n^2)

Answers:

  1. C
  2. B
  3. B
  4. C
  5. C
  6. B
  7. C
  8. A
  9. A
  10. C

 

Labels:

Friday, 11 December 2020

Perl - securing web services using OAuth 2.0


Hi, This program is a simple OAuth 2.0 authentication and authorization implementation using the Mojolicious web framework in Perl. It allows a user to log in and authorize a client application to access protected resources.

The program defines the necessary endpoints for authentication and authorization using the get method from the Mojolicious::Lite module. The $auth_endpoint and $token_endpoint variables define the authentication and token endpoints for the OAuth 2.0 provider. The $client_id, $client_secret, $redirect_uri, and $scope variables define the client credentials and scope for the OAuth 2.0 client.

Read more »

Labels:

Friday, 4 October 2019

how many types available for getting string variable length in perl?

Method 1:

my $c = map $_, $h =~ /(.)/g;


Method 2:

my $c = split '', $h;


Method 3:

my $count = () = "hello" =~ /./g;


Method 4:

print length $h;


Method 5:

$cnt = "hello" =~ tr/[a-z][A-Z][0-9]//;


Method 6:

$h='hello';
my $v=$h=~ s/[a-z]//g;


Method 7:

print  @_ = push(@_, map $_, (split '', 'hellgo'));


Method 8:

print  @_ = push(@_, grep $_, (split '', 'hellgo'));


Method 9:

print push(@_, grep $_, "hello" =~ /./g);


Method 10:

print push(@_, map $_, "hello" =~ /./g);


Method 11:

print push(@_, grep $_, reverse "hello" =~ /./g);


Method 12:

print push(@_, map $_, reverse "hello" =~ /./g);


Method 13:

print push(@_, map $_, (split '', 'hellgo'));


Method 14:


my $c = grep/./, (reverse split '', 'hello');
print $c;


Method 15:

my $c = map $_, (reverse split '', 'hello');
print $c;


Method 16:

my $c = map $_, (reverse "hello" =~ /./g);
print $c;


Method 17:

my $c = grep/./, (reverse "hello" =~ /./g);
print $c;


Method 18:

my $c = map $_, (reverse split '', 'hello');
print $c;


Method 19:

my $c = grep/./, (reverse split '', 'hello');
print $c;


Method 20:

print scalar map $_, 'hello' =~ /(.)/g;


Method 21:

print scalar grep/./,'helloh' =~ /(.)/g;


Method 22:

print scalar  map $_, (reverse "hello" =~ /./g);


Method 23:

print scalar  map $_, (reverse split '', 'hello');


Method 24:

print scalar  map $_, (split '', 'hello');


Method 25:

print $r = @_= map $_, (split '', 'hello');


Method 26:

print $r = @_= grep $_, (split '', 'hello');


Method 27:

print $r = @_= grep $_, (reverse "hello" =~ /./g);


Method 28:

print $r = @_= grep/./,'helloh' =~ /(.)/g


Method 29:

print $r = @_= map  $_, (reverse "hello" =~ /./g);


Method 30:

print $r = @_= map/./,'helloh' =~ /(.)/g


Method 31:

print $r = @_= map $_, (split '', 'hello');


Method 32:

print $r = @_= grep $_, (split '', 'hello');


Method 33:

print $r = @_= grep $_, (reverse "hello" =~ /./g);


Method 34:

print $r = @_= grep/./,'helloh' =~ /(.)/g


Method 35:

print $r = @_= map  $_, (reverse "hello" =~ /./g);


Method 36:

print $r = @_= map/./,'helloh' =~ /(.)/g


Method 37:

print scalar  map $_, (reverse split '', 'hello');


Method 38:

print length reverse  grep/./,'helloh' =~ /(.)/g;


Method 39:

print length reverse  map $_,'helloh' =~ /(.)/g;


Method 40:

print grep/./, (reverse "hello" =~ tr/[a-z][A-Z][0-9]//);


Method 41:

print map $_, (reverse "hello" =~ tr/[a-z][A-Z][0-9]// );




For More Methods Reach Me:@ letscrackperlinterviewblogspot@gmail.com  

Labels: , , , , ,