http://qs321.pair.com?node_id=418369


in reply to using regular expression to extract subset from a line

I'll leave the analysis of what you've got to someone who's better at regexps than I, but if you're simply looking to extract the argument from a space-delimited string that ends in "makefile", try something simpler like this:

#! /usr/bin/perl -w use strict; my $old_str = 'make -r -f ..\../tools/cell/makefile cell.lib'; my $new_str = ( $old_str =~ /\s+(\S*makefile)/ )[0]; print "New string: $new_str$/"; __END__

HTH

Update: You could do this with split and grep also:

my $new_str = ( grep { /makefile$/ } split /\s+/, $old_str )[0];

_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
            --Friedrich Nietzsche