place and plays @_ in perl?
sub Addition{ $a=\@_; ($a,$b,$c)=@$a; $sum=$a+$b+$c; } Addtion(10, 20, 30); print $sum; #60
Labels: place and plays @_ in perl?
[There's More Than One Way To Do It]
Always A Blog To Get Confident in Coding
sub Addition{ $a=\@_; ($a,$b,$c)=@$a; $sum=$a+$b+$c; } Addtion(10, 20, 30); print $sum; #60
Labels: place and plays @_ in perl?
Labels: array create, perl array
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.
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.
© 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 »
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.
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 »
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: Perl Built-ins Quick Reference
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);
print $my_array[0]; # prints 1
print scalar(@my_array); # prints 5
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.
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: Automating Firefox using Perl