Andrej Kastrin wrote:
>
> I suppose that above example is not good one; here is the real one:
> Mark
> Francesco
> Ann
> Robert
> 
> transform to: "Mark","Francesco","Ann","Robert"
> 
> and here is my code:
> 
> $source_file = "input.txt";
> $result_file = "output.txt";
> 
> open (SOURCE, $source_file) || die "cannot open $source_file: $!";
> open (RESULT, ">$result_file") || die "cannot open $result_file: $!";
> 
> while (<SOURCE>)
> {
> my($line) = $_;
> if ($line =~ $) #match to end of line
>   {
>      print "$line"; #how to make e.g. "Mark",
>   }
> }

This should do what you want (untested):

use warnings;
use strict;

my $source_file = 'input.txt';
my $result_file = 'output.txt';

open SOURCE, '<', $source_file or die "cannot open $source_file: $!";
open RESULT, '>', $result_file or die "cannot open $result_file: $!";

while ( my $line = <SOURCE> ) {
    chomp $line;
    print qq/"$line"/, eof SOURCE ? "\n" : ',';
    }

__END__



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to