in reply to Re: general perl question
in thread In-place editing of files (was: general perl question)

The flags work without the command line, too. The following will convert any files specified on the command line to all caps.
#!/usr/bin/perl -w -i.bak -p $_ = uc;
In fact, there was an Obfuscated Perl contest entry a while back that does DOS-to-Unix conversions using only command line switches on the shebang line.

xoxo,
Andy

# Andy Lester  http://www.petdance.com  AIM:petdance
%_=split';','.; Perl ;@;st a;m;ker;p;not;o;hac;t;her;y;ju';
print map $_{$_}, split //,
'andy@petdance.com'

Replies are listed 'Best First'.
Re: Re: Re: converting files in place
by repson (Chaplain) on Apr 25, 2001 at 07:31 UTC
    What I meant was that my code can be dropped in the middle of a program, while to use the switches in the middle of a program you would have to spawn a new perl with those switches.
    #!/usr/bin/perl -w ..... system(q#perl -i.bak -p -e '$_ = uc'#); .....