Count Item in an Array

To get the number of items in an array, you can evaluate the array as scalar context.

my @array = ("Apple", "Orange", "Tomato");

my $count = @array;
print $count;

Also scalar method can be used. This way seems more simple.

print scalar(@array);

 

Continue Job in Background after Logout

In order to continue a job after logout, we can use “nohup” command which ignores HUP signal.

$ nohup command

Adding “&” gets the command to run in background.

$ nohup command &

Standard output and error of the command are output to nohup.out file created in the directory where the command is executed. If you want to avoid the file creation, redirect standard error to standard output and standard output to /dev/null.

$ nohup command > /dev/null 2>&1 &

Usually “nohup” is used in this style.

Top