Sep 16, 2013, 3:53 PM
Post #5 of 5
Re: [daragorn_1] develop the SED command in perl
[In reply to]
yes it is some kind of homework. can somone help me with it?
Sure, we can help, but we're not gonna do your assignment in your place.
Please show what you have done and where you're having difficulties, we will help you.
If you haven't got anything so far, this is a starter:
sed 's/MA/Massachussetts/' file.txt
will print to the screen a version of file.txt where occurrences of MA have been replaced by the full state name.
Same thing in Perl:
perl -pe 's/MA/Massachussetts/' file.txt
As you can see, it is very similar, but of course, it will not always be that easy. Actually, a Perl one-liner will not be sufficient, you will have to write an actual Perl program. But the Perl s/// substitution operator will definitely have to be used heavily in your progtram.