Apr
#! /usr/bin/perl
use strict;
use warnings;
@ARGV = (”11214_2008_9368_JobSheet_200.xml”);
while (<>) {
if (/Remove colour consent form/) {
print “Find\n $_\n
Do it colour in print\n”;
}
if (/do not send colour consent form to author/) {
print “Find\n $_\n
Do it colour in print\n”;
}
if (/remove CCF form/) {
print “Find\n $_\n
Do it colour in print\n”;
}
if (/Special Issue/) {
print “Find\n $_\n
Do it colour in www\n”;
}
}
Answer:
NEVER assign a value to @ARGV.
Use -n or -p if your whole program is one big while (<>) loop.
There should be NO SPACE between #! and /usr/bin/perl.
If the body of three of your if statements are the same, you should combine them into one if statement.
Your regexen are kind of long, do you really need to see ALL those words to know what to do with each line?
You should ALWAYS use m//x (don't leave off the m).
If your strings have embedded \n, you should use here-documents << instead.
Answer:
I'm guessing that you want to open the file that you set @ARGV to. You should consider @ARGV read-only by the way. So, I'm guessing you want
$file = $ARGV[0];
open(FH, “<$file");
while(
…
}
I believe that I answered a question that provided a single regex for the first three if statements. There is no reason those can't be combined to one if statement.
Answer:
What Perl are you smokin?
Answer:
pearl”"
oed99g)9(
what?????????????
Book Mark it-> del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Window Live | Tailrank | Furl | Netscape | Yahoo | BlinkList