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

How to Substitute

Expand Messages
  • joach@direct.ca
    I m reading and trying to apply some of the concepts to real data files........ and the weekend seems like an excellent time to ask for help. What I am trying
    Message 1 of 1 , Jul 30, 2000
    • 0 Attachment
      I'm reading and trying to apply some of the concepts to real data
      files........ and the weekend seems like an excellent time to ask for
      help.
      What I am trying to do is read a file and replace the " , " with a "
      "( 2 spaces).......... now this does not seem like much..... but there
      are may files with spaces from main frame machines that need to be in
      the CSV format for the PC. Of course it seems like I am doing just the
      opposite..... well I have CSV data that I can practice on ......later I
      will reverse the code for the real thing.

      My problem right now is that the below code does not do that...... the
      debugger can't find errors..... which was nice. But the still the
      script is incorrect. Could someone have a look............

      TIA

      John



      #!/usr/bin/perl -w
      # for bat file switch - Name change!
      $infile=shift;
      $outfile=shift;

      open (IN, "$infile");
      open (OUT, ">$outfile");
      foreach ($S_)
      { (s/,/" "/); #substitute the comma for a space

      print OUT $S_ ;
      }
      next;
      close (IN);
      close (OUT);
      exit;
    Your message has been successfully submitted and would be delivered to recipients shortly.