in reply to minimal match regulara expression

You can use s/// to remove everything after the 1st underscore (inclusive):
use warnings; use strict; my $this_server = 'wppwd01a0099_NET_basp_virtual_adapter'; $this_server =~ s/_.*//; print "$this_server\n"; __END__ wppwd01a0099

Replies are listed 'Best First'.
Re^2: minimal match regular expression
by fionbarr (Friar) on Mar 03, 2015 at 16:37 UTC
    bravo, thanks
      you can also:
      use warnings; use strict; my $match, $pruned = split(/_/, $_); print $match
      at work so cant* test it haha

        ... and it doesn't work haha.

        Tested, works:

        c:\@Work\Perl>perl -wMstrict -le "$_ = 'wppwd01a0099_NET_basp_virtual_adapter'; my ($match) = split(/_/, $_); print qq{'$match'}; " 'wppwd01a0099'


        Give a man a fish:  <%-(-(-(-<

Re^2: minimal match regular expression
by fionbarr (Friar) on Mar 03, 2015 at 19:40 UTC
    thanks...this is the one I ended up with after finding out I had some occurances of an internal '-' which choked on (\w+?)