P
Peter Steele
Hello all,
I am trying to teach myself perl and I have a bash shell script which
I
thought might be a good "perl conversion exercise".
My shell script does the following (my apologies if I am boring those
who don't require an explanation ...):
- Set a variable, "INFILE", to be an input file specified as a
commandline
argument.
- For each record in the file "headers" , set a variable ($header) as
the string contained in that record.
- grep the input file INFILE for occurrences of the "$header" string,
and store this result in a variable for further regex processing.
While this is trivial with the shell, I have not yet gotten very far
with perl.
The "headers" file will contain ten lines of text, and the INFILE will
typically be less than 50Kb in size.
Any suggestions?
Thank you all for your time.
Script follows:
.....................................................
INFILE=$@
while read header
do
echo "looking for $header in $INFILE"
result=`grep -i $header $INFILE`
done<headers
.....................................................
I am trying to teach myself perl and I have a bash shell script which
I
thought might be a good "perl conversion exercise".
My shell script does the following (my apologies if I am boring those
who don't require an explanation ...):
- Set a variable, "INFILE", to be an input file specified as a
commandline
argument.
- For each record in the file "headers" , set a variable ($header) as
the string contained in that record.
- grep the input file INFILE for occurrences of the "$header" string,
and store this result in a variable for further regex processing.
While this is trivial with the shell, I have not yet gotten very far
with perl.
The "headers" file will contain ten lines of text, and the INFILE will
typically be less than 50Kb in size.
Any suggestions?
Thank you all for your time.
Script follows:
.....................................................
INFILE=$@
while read header
do
echo "looking for $header in $INFILE"
result=`grep -i $header $INFILE`
done<headers
.....................................................