On Tuesday, May 7, 2002, at 08:23 , Timothy Johnson wrote:
> Here's one way with a regex: > > open(INFILE,"myfile.txt") || die "Could not open myfile.txt!\n"; > while(<INFILE>){ > $_ =~ /^(\d{6})\s+(\w+\s*\w*)\s+(\w+)\s+(<.+\@.+>)\s*$/ || die > "Improper > format"; > $index = $1; > $firstmaybemiddle = $2; > $last = $3; > $smtpaddr = $4; > } For those of you new to perl, On behalf of the morally responsible wing of the perl community, I would like to apologize for some of the writers here who, well meander a bit.... <rant hasCode='true' isNearTopic='mostly'> CHILDREN!!!! { Yes, you formerly known as , and his side kick } the game is 'where is waldo' - not WATCH ME CRUSH WALDO I love 'perl line noise' over 'sed line noise' for regular expression matching - but IF you are going to be demonstratively SILLY about OVER working the regEX at least show some elan while ( <INFO1> ) { /^(\d{6})\s+(\w+\s*\w*)\s+(\w+)\s+(<.+\@.+>)\s*$/ ; my $num = $1; my $tmp = $2; my $last = $3; my $email = $4; my ($first, $middle) = split(/ \s*/, $tmp); $middle ||= "NMN"; # NMN: No Middle Name print "found :$num:$first:$middle:$last:$email:\n"; } IF you are planning on writing the 'validator' - then use Jonathan's approach and WHINE about it - rather than die..... Although he should have put together a second list of 'Scragged' lines of data - and hence should have returned the refs to the arrays... but details... <rant/> <JustSilly val="Now Don't Make Me come down there and fix you!"/> ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]