in reply to Extracting field from a line

#!/usr/bin/perl -w use strict; my $str = "07870635509,3,0,29052002,DORMANT,05011998,1,2,128,0,0,0"; my @arr = split(',', $str); print "field5 = $arr[4]";
"We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.

Replies are listed 'Best First'.
Re^2: Extracting field from a line
by knirirr (Scribe) on Jul 14, 2005 at 08:49 UTC
    I usually do this, which is much the same:
    my $field5 = [split(/,/,$str)]->[4];