bash shell script - perl conversion

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
.....................................................
 
P

Paul Lalli

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".

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
....................................................

Soooo, what exactly are you asking for? Are you asking us to write the
program for you? Doesn't that defeat the purpose of your trying to learn
Perl? You say you haven't gotten very far - well how far *have* you
gotten? Show us what you have, and tell us what problems you're having.
That way we can help correct you.

If you're just looking for a site to help you learn Perl, try
http://learn.perl.org

Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top