Start learning Perl at

References : <- google : perl beginner //helpful docs sometimes not come from official guys as but from other people who understand Perl thoroughly!

Problem: What I need to know to write the very 1st task : Term frequency of a file?

First of all, I suggest u to watch some demo video on using Perl here . It will provide u a very useful basic general & 1st-view of coding by Perl. Later on, u will need urself to look for more details on Perl syntax! Here are some of mine reviews.

Supposed u have a perl script file
In Unix OS, u run it by calling : perl argument0 argument1 …
, where is stand for more arguments u may add.
The belowings should be noticed when working with read-from-files :

  • <filename.var> result-string of 1 line read from file named filename.var, which read at current reading-position in that file – the next call of this command will read the next line.
    In case there’s no more to read, a non-defined value will be returned.
  • $_ is a special variables, default-behaving variables, that stored line latest read from <filename.var>.
  • ARGV, another special variables, is the one that stored a must-say-to-understand file-handle, a special file handle in fact which help to read all the content of all files inputed as arguments list in command line (i.e the ones above).
    More, u should notice that this name, ARGV, is also used as other variables (same name!) such as @ARGV (the array of arguments’s filenames) and $ARGV(the current filename that being read).
  • So, <ARGV> is what we need to read line-by-line from the contents of all input-as-argument files.
    This command is used so frequently that Perl makes it simpler as <> only !
  • defined(<expression>) is function that help to check if the final value of the expression is valid or not (defined or not defined).
  • # is used to mark all the following part of the current script-line as a comment.

So, finally, after u seem to get well-prepared with the above Perl’s commands, the followings will be my steps workings with the files.
From my professor Chevallet, he demo to me as :

while (<>) { #not end of file

#work with your read line.
#use $_ as 1 line read from the files


The above that marked is actually means while ( defined($_=<ARGV>) ) , from this u can, hopefully as myself, can answer urself the up-coming questions ! So let’s get some codings!

I may record a video of my coding ^_^ or may not. See u later! Bye all!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: