Robert Hanson wrote at Wed, 05 Jun 2002 15:57:05 +0200:

> Here is my solution, others will differ...
> 

Yep, if you like it short ;-)
open BOOK_LIST, "<books.txt" or die "Can't Open: $!";
print join "\n", map {chomp; /(.*) by (.*)/; "$2 - $1"} (<BOOKLIST>);
close BOOK_LIST;

> # always print $! on error so you can see the cause open( INFILE,"books.txt" ) || 
>die "Cann't
> Open: $!";
> 
> while( <INFILE> ) {
>       chomp; # remove the newline
>       next unless ($_); # skip blank lines
> 
>       # split the line by the seperator
>       my @parts= split(/ by /, $_);
> 
>       # die unless exactly 2 parts are found
>       die "Can't split properly" unless ( @parts == 2 );
> 
>       print "$author - $book\n";
> }
> }
> close INFILE;


Greetings,
Janek

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

Reply via email to