Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] SEARCH and REPLACE help me plz

Expand Messages
  • Rodrigo Torres
    ... #!/usr/bin/perl -w # substition.pl # Usage: substition.pl original_word new_word filename die Usage: substition.pl original_word new_word filename if
    Message 1 of 3 , Mar 21, 2005
      Em Seg, 2005-03-21 às 02:35 -0800, neelam escreveu:
      > hi
      > i too have a problem of search and replace :
      > i am having a input file and i need to modify it acc
      > to the user's input eg:
      > if file has the 'live'and we need to replace it with
      > the 'life' in whole program what should we do???
      > plz help.


      #!/usr/bin/perl -w
      # substition.pl
      # Usage: substition.pl original_word new_word filename

      die "Usage: substition.pl original_word new_word filename"
      if @ARGV < 3 ;

      my ( $original, $new, @filenames ) = @ARGV;

      foreach $file (@filenames) {
      open FILE, "<", $file or die $!;
      while (<FILE>) {
      s/$original/$new/g;
      print;
      }
      }

      Please, do a favor for yourself and read this:
      http://srj.ath.cx/references/lperl/

      --
      motobói
    Your message has been successfully submitted and would be delivered to recipients shortly.