in reply to Syntax for array?

while(<>){ push @array,(split/~/)[1]; }

Replies are listed 'Best First'.
Re: Re: Syntax for array?
by dash2 (Hermit) on Jul 10, 2001 at 15:52 UTC
    And an explanation, as you're a newbie:

    while(<>) {

    This bit reads every line from your file (if you've specified your file name on the command line, e.g. "./myscript.pl filename.txt")

    push @array,(split /~/)[1];

    split /~/ takes the current line, and splits it into an array on the ~ character.

    (split /~/)[1] takes the second element of that array. That's staffid, the bit you want. Similarly print( ('a','n','d')[1] ) would print "n".

    push @array, ... just adds this to your array.

    dave hj~