Re: From column to row?



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
.



Relevant Pages

  • AS3 Quitlist - *Offlist* - Please read
    ... Mike Figmint ...figliolaAS3surewest.net ... Tom Westbrook ...tomAS3twestbrook.com ... Ann ..lilmsdippitydooAS3yahoo.com ... Mark ..mark.weatherillAS3btinternet.com ...
    (alt.support.stop-smoking)
  • Re: AS3 Quitlist - *Offlist* - Please read
    ... Mike Figmint ...figliolaAS3surewest.net ... Tom Westbrook ...tomAS3twestbrook.com ... Ann ..lilmsdippitydooAS3yahoo.com ... Mark ..mark.weatherillAS3btinternet.com ...
    (alt.support.stop-smoking)
  • Re: AS3 QUITLIST VERIFICATION No Reply List
    ... Tracey and John ...tfrederickAS3lssnorth.org ... Mark ..mark.weatherillAS3btinternet.com ... Ann Mennen ...mennenAS3iprimus.com.au ... Cindy Zimmerman ..zimmerman.11AS3osu.edu ...
    (alt.support.stop-smoking)
  • Re: AS3 QUITLIST VERIFICATION No Reply List
    ... In April next year please either reply to the Verification e-mail or ... Mark ..mark.weatherillAS3btinternet.com ... Ann Mennen ...mennenAS3iprimus.com.au ... Mark Barry ..markAS3bssound.com.au ...
    (alt.support.stop-smoking)
  • Re: AS3 QUITLIST VERIFICATION No Reply List
    ... Tracey and John ...tfrederickAS3lssnorth.org ... Mark ..mark.weatherillAS3btinternet.com ... Ann Mennen ...mennenAS3iprimus.com.au ... Cindy Zimmerman ..zimmerman.11AS3osu.edu ...
    (alt.support.stop-smoking)