On 10/28/07, Telemachus Odysseos <[EMAIL PROTECTED]> wrote:
> On 10/25/07, Chas. Owens <[EMAIL PROTECTED]> wrote:
> > From the sound of it what you want is in-place-editing:
> >
> > #!/usr/bin/perl -i
> >
> > use strict;
> > use warnings;
> >
> > while (<>) {
> >      s/this/that/
> > }
> >
> > The code above will read in any number of files modifying "this" to
> > "that" in each one.
>
> Doesn't that code empty out a file?  That is, isn't there a key line
> missing:
>
> #!/usr/bin/perl -i
> use strict;
> use warnings;
>
> while (<>) {
>      s/this/that/;
>      print;
> }
>
> I apologize if "print;" was so obvious that it didn't even need to be
> mentioned, but to be honest, I tried it without that line and emptied a few
> test files before I got it right.
>

Doh!, that was supposed to be -pi on the command line version and a
print in the full code.

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


Reply via email to