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:

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:

Wednesday 6 November 2019

perl - array and hash common differences

     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=(1,3,5,6,2);
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


 $#array+1;
       or
scalar(@array);
      or
$a=@array;


For Emptying Array
$#array = -1;
     or
@array = ( );

To reverse an array
print reverse @array;


To sort array Elements
ascending order
@a=sort{$a <=> $b }@array;
desending order
@a=sort{$b <=> $a }@array;


To add array elements
$array[0]='55';




To Delete array elements
delete $array[1];
 
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'}







To find length of hash

@array=keys %hash;
scalar(@array);
     or
$#array+1;
     or
$a=@array;



For Emptying hash
%hash=( );




To reverse a hash
print reverse %hash;



To sort hash elements

 foreach $k (sort keys %hash)
{
   print "$k => $hash{$k}\n";
}



To add hash Elements
$hash{1}='one';





To Delete hash elements
delete($hash{'1'});


Labels:

Tuesday 5 January 2021

Python Memory Management: Avoiding Common Pitfalls and Memory Issues and memory leaks and excessive garbage collection

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: , ,