F
Flamingo
Hey all,
I'm just begining study perl, have some questions about perl regular
expression:
1. Your current program should count lines of a file which contain a
certain string. Modify it so that it counts lines with double letters
(or any other double character). Modify it again so that these double
letters appear also in parentheses. For example your program would
produce a line like this among others:
023 Amp, James Wa(tt), Bob Transformer, etc. These pion(ee)rs
conducted many
Try to get it so that all pairs of letters are in parentheses, not
just the first pair on each line.
2.For a slightly more interesting program you might like to try the
following. Suppose your program is called countlines. Then you would
call it with
../countlines
However, if you call it with several arguments, as in
../countlines first second etc
then those arguments are stored in the array @ARGV. In the above
example we have $ARGV[0] is first and $ARGV[1] is second and $ARGV[2]
is etc. Modify your program so that it accepts one argument and counts
only those lines with that string. It should also put occurrences of
this string in paretheses. So
../countlines the
will output something like this line among others:
019 But (the) greatest Electrical Pioneer of (the)m all was Thomas
Edison, who
Is there anybody who can give me some solutions, appreciate your help.
I'm just begining study perl, have some questions about perl regular
expression:
1. Your current program should count lines of a file which contain a
certain string. Modify it so that it counts lines with double letters
(or any other double character). Modify it again so that these double
letters appear also in parentheses. For example your program would
produce a line like this among others:
023 Amp, James Wa(tt), Bob Transformer, etc. These pion(ee)rs
conducted many
Try to get it so that all pairs of letters are in parentheses, not
just the first pair on each line.
2.For a slightly more interesting program you might like to try the
following. Suppose your program is called countlines. Then you would
call it with
../countlines
However, if you call it with several arguments, as in
../countlines first second etc
then those arguments are stored in the array @ARGV. In the above
example we have $ARGV[0] is first and $ARGV[1] is second and $ARGV[2]
is etc. Modify your program so that it accepts one argument and counts
only those lines with that string. It should also put occurrences of
this string in paretheses. So
../countlines the
will output something like this line among others:
019 But (the) greatest Electrical Pioneer of (the)m all was Thomas
Edison, who
Is there anybody who can give me some solutions, appreciate your help.