How to find out whether reference is pointing to a scalar, array or hash in Perl?
Answer:
Use the ref() function
my $data = [1,2,3];
print ref($data); # print out ARRAY
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
How to find out whether reference is pointing to a scalar, array or hash in Perl?
Answer:
Use the ref() function
my $data = [1,2,3];
print ref($data); # print out ARRAY
How do you pronunce 'Linux'?
Answer:
Check out the pronunciation by Linus Torvalds, the creator of the Linux.
Shutdown Linux X minutes later
Answer:
To schedule Linux shutdown in X minutes later, use the following command
E.g. shutdown in 10 minutes
# sudo shutdown -h 10
List files in a tar file
Answer:
To list all files inside a tar file, use the following command
# tar tf test.tar
Insert search string back to the result in sed
Answer:
Following command will replace "foo" by "bar", using the sed.
# echo "foo" | sed 's/foo/bar/'
But how to append the word "foo" at the end of "bar"?
Here is the solution with the & (& defines the pattern found in the search string)
# echo "foo" | sed 's/foo/bar&/'