(Not much to see here right now)


Inline-Editing Anywhere

You may be aware that Perl allows in-line editing of files via the -i switch. While this option is global for the script, it can be convenient to switch it on selectively. Here is a code snippet from one of Randal Schwartz's columns:
  local @ARGV = "lib/Acme/";                                                                          
  local $^I = "~";                                                                                              
  while (<>) {                                                                                                  
    s/\$YEAR = \d+, \$MONTH = \d+, \$DAY = \d+;/\$YEAR = $Y, \$MONTH = $M, \$DAY = $D;/;                        

Page PathologicallyEclecticRubbishLister
Revision 16 Apr 2004
Parents: Index