in reply to regex assistance

Or using a split rather than a regexp:
use strict; use warnings; use 5.012; my @array = ( 'GAP_SPAN09 - GAP SPAN base (Scratch Testing [TSMC11] : tsmc11_wld( +sxfatd12j))', 'GAP_SPAN03 - GAP SPAN base (DFD E2E Testing [TSPAN04] : tspan04-df +dint-wld(sxfamd6f))', 'OS_WLI02 - POS_WLI02 Web Logic Integrator', ); my @results = map{(split / - /)[0]} @array; say for @results;
Output:
GAP_SPAN09 GAP_SPAN03 OS_WLI02

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: regex assistance
by Anonymous Monk on Oct 21, 2010 at 07:38 UTC
    Thanks for all the responses. It just goes to show how versatile Perl is !