anjaana78 has asked for the wisdom of the Perl Monks concerning the following question:

i am using this code to read from a file which has one word oer line and storing it into a string and i am also inserting the commas now i want to insert qouetes also along each word.
open FILE, "myfile" or die "I am not able to open the file to read"; while (<FILE>) { chomp; $string .= "$_, " ; } close(FILE); chop($string); #removing the last balan space from the string. chop($string); #removing the last , from the string.
the output showd be some thing like this:

"john", "sean", "me".

Replies are listed 'Best First'.
Re: qoutes bugging me
by anjaana78 (Novice) on May 10, 2001 at 18:49 UTC
    just need to modif the code a lil bit
    $ziplist .= '"'; $ziplist .= "$_" ; $ziplist .= '" ,';
    this will do good
      Or this might be easier to read/write: $ziplist .= qq("$_", ); buckaduck
how 'bout this
by cforde (Monk) on May 10, 2001 at 21:21 UTC
    use FileHandle; my $file = new FileHandle "myfile"; my @line = <$file> or die "Unable to open myfile: $!"; my $stuff = join '',@line; $stuff =~ s/\n/","/g; print '"' . $stuff . '"';
    Have fun,
    Carl Forde