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 »
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
S.No
|
ARRAYS
|
HASHES
|
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
|
It is ordered data collection
Data Can be accessed based on index value
Stack operations performed using push,pop,shift,unshift
Duplicate Elements will be exist in Array
For Large data, Arrays will not be in speed as getting values from
hash keys.
Arrays can be created using () brackets @array=
For More methods refer this link.
for accessing array index
$array[1];
Array can be accessed in loops as below
1.For(@array)
{
}
2.foreach(@array1,@array2)
{
Print $_;
}
3.print grep{},@array;
4. print map{},@array;
Array slices can be used as below
@array[2];
To find length of an array
For Emptying Array
To reverse an array
To add array elements
$array[0]='55';
To Delete array elements
|
It is unordered Data Collection
Data Can be accessed based on Key value
Stack operations cannot be performed
Keys will not have Duplicate elements but Values would have Duplicate
elements.
Based on hash Keys Data retrival would be fast
Hash is also possible to create using () bracket %hash=(1,3,5,6,2);
For More methods refer this link. https://kaavannan-perl.blogspot.com/2019/10/perl-hashes-what-is.html
For accessing hash index use the key name
$hash{1};
Hash can be accessed based on keys and values
While(($k,$vals) = each %h)
{
Print “$k,$vals\n”;
}
Foreach $k (keys %h)
{
Print “$k => $hash{$k}\n”;
}
Foreach $values (values %hash)
{
Print “$values\n”;
}
Hash slices can be used as below,
$hash{'1'}
@array=keys %hash;
To reverse a hash
print reverse %hash;
To add hash Elements
$hash{1}='one';
To Delete hash elements
delete($hash{'1'});
|
Labels: array hash difference
Memory management is an important aspect of programming in any language, and Python is no exception. In Python, memory is managed automatically through a process called garbage collection. While this can be convenient for developers, it can also lead to issues like memory leaks and excessive garbage collection. In this article, we will explore Python's memory management model and provide tips for avoiding common pitfalls.
Python Memory Model
In Python, objects are created dynamically and stored in memory. Each object has a reference count, which keeps track of how many references to the object exist. When an object's reference count reaches zero, it is no longer accessible and can be garbage collected.
Read more »Labels: best practices, Python Memory Management, python tutorial