[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Stupid, non-Mac based PERL question



At 01:59 PM 7/2/97 -0000, Darin S. Morley wrote:
>My spies tell me that one "Strider" wrote:
>
>>I have a database laid out like this, in tab-delimited format:
>>
>>Number[tab]Username[tab]Unneeded data[tab]ditto[tab]... there are fifteen
>>fields total, and then a newline at the end.
>>
>>All I want is the username, perferably in an array, one entry per username.
>>How would I pattern match/replace to get this? Is that even the route I
>>should take?
>
>i haven't tested this, but i think that the following will work:
>
>while(<>) {
>    my $uname = /^[^\t]+\t([^\t]+)/;
>    $array[$#array] = $uname;
>}

Another way to do this (again, not tested) is the following:

while ($line = <FILEHANDLE>) {
   ($number, $uname) = split(/\t/, $line);
   $array[$#array] = $uname;
}

split() is one of my favorite Perl functions.



     -- Jonathan


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch