in reply to simple regex question

All, I ended up using the following method with push. Here it creates 4 arrays from 1 based on its initial character on each line(they are all the same) Thanks everyone for the help foreach $line(@exceptions) { if ($line =~ m/^n/) { $line =~ s/^n//s; push (@before, $line); } if ($line =~ m/^i/) { $line =~ s/^i//s; push (@implementation, $line); } if ($line =~ m/^b/) { $line =~ s/^b//s; push (@backup, $line); } if ($line =~ m/^o/) { $line =~ s/^o//s; push (@offline, $line); } }

Replies are listed 'Best First'.
Re^2: simple regex question
by phenom (Chaplain) on Dec 01, 2010 at 00:09 UTC
    pipeops, glad to hear you have it working. But for future reference, please wrap your <code> in tags - it's MUCH easier to read:

    foreach $line (@exceptions) { if ( $line =~ m/^n/ ) { $line =~ s/^n//s; push( @before, $line ); } elsif ( $line =~ m/^i/ ) { $line =~ s/^i//s; push( @implementation, $line ); } elsif ( $line =~ m/^b/ ) { $line =~ s/^b//s; push( @backup, $line ); } elsif ( $line =~ m/^o/ ) { $line =~ s/^o//s; push( @offline, $line ); } }