http://www.perlmonks.org?node_id=1013303

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

Seeking wisdom of the Perlwiser monks ...

Created this in pieces, combined and whittled the pieces down to the following two lines and cannot figure out how to combine them to the desired one liner.

my ($str) = $input =~ m#^-L(((?!\s*-).)*)#; $input =~ s#-lmylib#$str/mylib.a#;

Any suggestions ??

The details:

# # Input : -L/usr/local/lib -lmylib -lz # Desired output: -L/usr/local/lib /usr/local/lib/mylib.a -lz # use strict; use warnings; # The input string my $input = '-L/usr/local/lib -lmylib -lz'; # The meat my ($str) = $input =~ m#^-L(((?!\s*-).)*)#; $input =~ s#-lmylib#$str/mylib.a#;

Thank y'all for doing what ya do!