Perl Scripting Tips

Now if you are writing scripts with Perl and come from a C or C++ programming background, one of the first things you would want to know is Multiline comment. Well its simple, as shown below.

=begin comment

<your script>

=end comment


The next thing I wanted to work on was to read a file or paragraph line by line and search for the presence of a string in any line. Here’s how to go about it.

#$obj has the set of lines to be parsed

foreach my $resultline (split /^/m, $obj) {

#$resultline has a line currently being read, $str has to be searched in this line

if (index ($resultline, $str) != 1) {

<Your action>








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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s