On Sep 19, Veeraraju_Mareddi said:

>open(READ,"c:\\SMTP.txt");open(WRITE,">>c:\\SMTP1.txt");
>while(<READ>) {
>  /,/gi;
>  print WRITE "'$`',";
>}

Your code does a match and only prints the first chunk of text before a
comma.  The /g modifier does nothing here, because your regex is in void
context.  If you want to make every field in your file be surrounded by
quotes, then do:

  while (<READ>) {
    chomp;  # remove newline
    print WRITE
      join ",",    # join with commas
      map "'$_'",  # put quotes around text
      split /,/;   # split based on the comma
    print WRITE "\n";  # replace newline
  }

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to