[Chicago-talk] Regular expression

Chris Hamilton cjhamil at gmail.com
Wed Feb 6 10:55:26 PST 2008


If you _really_ want a regex you could replace your spilt with this:

split(/\s\s\s*/, $_)

But the other suggestion regarding unpack() is the better option.

-Chris

On Feb 6, 2008 12:50 PM, Andy Lester <andy at petdance.com> wrote:
>
> On Feb 6, 2008, at 12:46 PM, Young, Darren wrote:
>
> > Group                Node            Status
> > -------------------- --------------- ------
> > Cluster Group        GSBDHCL2        Online             <- the line
> > I'm
> > splitting on.
>
>
> If they're fixed width columns, use unpack(), like so:
>
> my ($group,undef,$node,undef,$status) = unpack( 'A20 A1 A15 A1 A6',
> $str );
>
> That's saying "Split out the first 20 alphas into $group, ignore the
> next 1, the next 15 into $node, the next 1 ignored, and the last 6
> into $status". You may need to adjust those widths, since I didn't
> count carefully, but you get the idea.
>
> xoxo,
> Andy
>
> --
> Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
>
>
>
>
>
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>


More information about the Chicago-talk mailing list