in reply to regex question
Or you could use split + negative indices
my @aFlds = split(/\t/, $line); my $last_field = $aFlds[-1]; my $next_to_last_field = $aFlds[-2];
If you also want to remove the final two fields after you have assigned them to variables, you can also use split + pop
#Note: if $line='A\tB\tC\t\D\tE', then # @aFlds = ('A','B','C','D','E') before popping # and ('A','B','C') after popping my @aFlds = split(/\t/, $line); my $last_field = pop @aFlds; my $next_to_last_field = pop @aFlds;
Best, beth
|
|---|