[Chicago-talk] Regular expression

Young, Darren Darren.Young at ChicagoGSB.edu
Wed Feb 6 10:46:47 PST 2008


Need some help on a regular expression... I've always been horrible at
regex's with spaces. Have the output from a Windows cluster command that
looks like this:

Group                Node            Status
-------------------- --------------- ------
Cluster Group        GSBDHCL2        Online             <- the line I'm
splitting on.

Perl code on this is:

### START
my $clustergroup = "Cluster Group";
my $cluster = "gsdhcp";
my $clustercmd = "cluster.exe /cluster:$clustrer group \"$clustergroup\"
/status";
open(CLUSTERCMD, "$clustercmd|") or die "Unable to open cluster command
pipe\n";

while(<CLUSTERCMD>) {
    ### print;
    if ( /$clustergroup/ ) {
        my ( $group, $activenode, $status) = split(/\s(.+)/, $_);  ###
regex here not working
        print "group: $group\n";
        print "active node: $activenode\n";
        print "status: $status\n";
    }
}

close(CLUSTERCMD);
exit(0);
### END

I want to split on "more than 1 space" so I get the first "Cluster
Group" value as the variable $group in the while() loop. If someone
named the cluster group without a space it'd be nice, but they didn't.

Any help would be great.


Darren Young
Systems & Security Architect
Computing Services
Chicago GSB
5807 South Woodlawn Avenue
Chicago, IL 60637

Voice 773.702.0331 | Fax 773.702.0233




More information about the Chicago-talk mailing list