Quantcast
Channel: Source.kohlerville.com » perl
Viewing all articles
Browse latest Browse all 3

Perl day 1: arguments

$
0
0

So here’s day one of my journey to learning perl. The reason I’m learning it is because there’s a lot of perl used at my work place. I can sort of read it, but I think it’s good to actually be able to code it as well.

The first lesson I thought would be good is how to accept arguments. I always feel like this is a good way to start because I can mess around and toss different kinds of strings and numbers into the program easily. The link for today’s code is from How to read command-line arguments with Perl

The website is pretty good about explaining that the arguments are stored in an array called ARGV and can reference the elements by using $ARGV[numberStartingFromZero]

From the sample I’ve noticed that the path for perl is at the top just like in python and shell scripts I’ve written before.

Another thing to notice is that $ is used when creating and accessing variables, even arrays.

Comments look like the common in most other dynamic languages and uses the # symbol.

Lastly, $#ARGV will get you what the last number of the array is. So if there’s only one element in the array, it will be in the 0th place.


Viewing all articles
Browse latest Browse all 3

Trending Articles