On Sunday 11 July 2004 10:18, Paul Smith wrote:
>
> Dear All

Hello,

> I am a beginner with perl. I would like to ask you whether it is
> difficult to make a perl script doing the following:
>
> (1) read a text file;
> (2) erase the character # placed at the beginning of the line that
> contains "Zyloric";
> (3) replace the original file with the file got after the deletion
> mentioned in (2).

No, it is not that difficult at all, in fact the following "script" 
will do just that:

perl -i.bak -pe'/Zyloric/&&s/^#//' text_file


However, if you want a complete Perl program, you could write it 
something like this:

#!/usr/bin/perl
use warnings;
use strict;

( $^I, @ARGV ) = ( '.bak', 'text_file' );
while ( <> ) {
    s/^#// if /Zyloric/;
    print;
    }

__END__



John
-- 
use Perl;
program
fulfillment


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to