Here is my solution, others will differ... # 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; Rob -----Original Message----- From: Denham Eva [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 05, 2002 9:42 AM To: BeginnersPerl (E-mail) Subject: Regex Problem - please help Hello Listers, I am struggling to get this right. Beginner in perl, so please forgive ignorance, but the regular expressions are confusing. I am trying to read in a file, with content as follows ---snip--- 1984 by George Orwell A BEND IN THE RIVER by V.S. Naipaul A CLOCKWORK ORANGE by Anthony Burgess A DANCE TO THE MUSIC OF TIME (series) by Anthony Powell A FAREWELL TO ARMS by Ernest Hemingway A HANDFUL OF DUST by Evelyn Waugh ---end snip--- The idea is to list by Author ie. George Orwell - 1984 V.S. Naipaul - A BEND IN THE RIVER Anthony Burgess - A CLOCKWORK ORANGE Anthony Powell - A DANCE TO THE MUSIC OF TIME (series) Ernest Hemingway - A FAREWELL TO ARMS Evelyn Waugh - A HANDFUL OF DUST OK my code thus far is:- --- Spin Code --- open(INFILE,"books.txt")||die "Cann't Open"; while(<INFILE>) { $_ =~ m/[A-Fa-z0-9]/ || die "Sorry Don't Work"; # Here regex is for everything # But I would like to chop it up to divide Authors from Books # Then to add them together with:- print "$author - $Book" -:for instance # In the end to write the output to a seperate file. $index = $_; print $index; } --- Close Code --- Now this produces a whole string, which I know, unfortunately I am not to good with the regex part. Any help will be much appreciated. Denham Eva Oracle DBA In UNIX Land On a quiet Night, you can hear the Windows machines reboot. ############################################################################ ######### This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal For more information please visit www.marshalsoftware.com ############################################################################ ######### -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]