in reply to inplace editing code in script

Use B::Deparse to turn a one-liner to a Perl script:

Q:\>perl -MO=Deparse -pi -e "$_='Hello'" BEGIN { $^I = ""; } LINE: while (defined($_ = <ARGV>)) { $_ = 'Hello'; } continue { print $_; } -e syntax OK

See perlvar for the variables used.

Replies are listed 'Best First'.
Re^2: inplace editing code in script
by imran77 (Initiate) on Oct 17, 2008 at 04:38 UTC
    Are you using this script in a file or at command line, kindly explain?

      B::Deparse is a module you can use to convert Perl oneliners into code that you can use in scripts. I'm not sure what else there is to explain between the usage example I've shown and the documentation I've linked to.