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:

Sunday, 10 November 2019

Perl Array - Common Functionalities and Usage?

Perl Arrays Functionalities:

We Can perform many functionalities using arrays among them below are some of the most used functionalities in perl

Method 1: [find only Duplicate Elements]

@a=(6,6,4,5,7,9,9);
for (@a) {
    push @dup, $_  if ($h{$_}++ == 1)
}
print @dup;


Method 2:[find largest number from an array] 

@sorted = sort { $a <=> $b } @a;
print @sorted[-1];


Method 3:[push and pop functionalities]

push adds the element at  end of  array

push(@a,"one");
push(@a,"two");

pop removes  last element of  array
pop @a

Method 4:[shift and unshift]

shift removes  first element of  array

shift @a;

unshift adds  element  front of array

unshift(@a,'one');

Method 5:[Finding length of an array elements]

1.
@a=(6,6,4,5,7,9,9);
print $#a+1;

2.
print scalar @a;

3.
$b=@a;
print $b;

Method 6:[Emptying array elements]

$#a=-1;

Method 7:[reversing array elements]

@a=(6,6,4,5,7,9,9);
print reverse @a;


Labels: ,

Wednesday, 13 March 2024

The Git & Github Bootcamp Part 3- Master on essentials and the tricky bits: rebasing, squashing, stashing, reflogs, blobs, trees, & more!


Comparing Changes with Git Diff

1. Introducing The Git Diff Command

git diff shows the differences between various commits, the staging area, and the working directory. It’s particularly useful for seeing what has changed in your code before committing.

2. A Guide To Reading Diffs

A diff output shows additions and deletions between two states. Additions are prefixed with a + and highlighted in green, while deletions are prefixed with a - and highlighted in red.

Read more »

Labels:

Sunday, 9 October 2022

Building and Deploying a Containerized Application with Amazon Elastic Kubernetes Service - Lab

 SPL-BE-200-COCEKS-1 - Version 1.0.8

© 2023 Amazon Web Services, Inc. or its affiliates. All rights reserved. This work may not be reproduced or redistributed, in whole or in part, without prior written permission from Amazon Web Services, Inc. Commercial copying, lending, or selling is prohibited. All trademarks are the property of their owners.

Note: Do not include any personal, identifying, or confidential information into the lab environment. Information entered may be visible to others.

Corrections, feedback, or other questions? Contact us at AWS Training and Certification.

Read more »

Labels: ,

Wednesday, 13 March 2024

The Git & Github Bootcamp Part 2- Master on essentials and the tricky bits: rebasing, squashing, stashing, reflogs, blobs, trees, & more!


Working With Branches

1. Introducing Branches

Branches in Git allow you to diverge from the main line of development and work independently on different tasks without affecting each other. It’s like working on a different copy of the project which can later be merged back into the main project.

2. The Master Branch (Or Is It Main?)

Traditionally, the default branch in Git repositories was called “master.” However, there’s a shift towards using “main” as the default branch name for new repositories. It’s important to know the name of your default branch, as it’s the base for new branches and often serves as the stable version of your project.

Read more »

Labels:

Monday, 27 January 2025

Perl Built-ins Quick Reference

1. String Functions

length

Returns the length of a string.

my $str = "Hello, World!";
my $len = length($str);
print "Length: $len\n";  # Output: Length: 13

substr

Extracts a substring from a string.

my $str = "Hello, World!";
my $sub = substr($str, 0, 5);
print "Substring: $sub\n";  # Output: Substring: Hello

index

Returns the position of a substring within a string.

my $str = "Hello, World!";
my $pos = index($str, "World");
print "Position: $pos\n";  # Output: Position: 7

rindex

Returns the last position of a substring within a string.

my $str = "Hello, World! World!";
my $pos = rindex($str, "World");
print "Last Position: $pos\n";  # Output: Last Position: 14

uc

Converts a string to uppercase.

my $str = "Hello, World!";
my $uc_str = uc($str);
print "Uppercase: $uc_str\n";  # Output: Uppercase: HELLO, WORLD!

lc

Converts a string to lowercase.

my $str = "Hello, World!";
my $lc_str = lc($str);
print "Lowercase: $lc_str\n";  # Output: Lowercase: hello, world!

ucfirst

Converts the first character of a string to uppercase.

my $str = "hello, world!";
my $ucfirst_str = ucfirst($str);
print "Ucfirst: $ucfirst_str\n";  # Output: Ucfirst: Hello, world!
Read more »

Labels:

Friday, 19 March 2021

perl data structures tutorial - part1

Perl provides a rich set of data structures that can be used to store and manipulate data. In this tutorial, I'll cover the most commonly used data structures in Perl, along with code examples.

Arrays

Arrays are ordered lists of scalar values. To declare an array, you use the @ symbol followed by the array name. Here's an example:

@my_array = (1, 2, 3, 4, 5);


You can access individual elements of the array using the array name followed by the index of the element in square brackets. Here's an example:

print $my_array[0]; # prints 1


You can also use the scalar function to get the number of elements in an array:

print scalar(@my_array); # prints 5


Read more »

Labels:

Tuesday, 2 July 2024

Automating Firefox using Perl



Automation is essential for modern web development, testing, and data extraction. The Firefox::Marionette Perl module simplifies the automation of Firefox using the Marionette protocol. This blog post demonstrates how to use Firefox::Marionette for essential tasks like navigating web pages, interacting with web elements, handling alerts, and managing cookies. We’ll start with an example script and then explore more advanced functionalities.

Installing Firefox::Marionette

Before diving into the examples, ensure you have the module installed:

cpan install Firefox::Marionette

Or use cpanm:

cpanm Firefox::Marionette

Additionally, ensure Marionette is enabled in Firefox by starting it with the -marionette flag:

firefox -marionette
Read more »

Labels: