in reply to Re: newbie attempting to extract
in thread newbie attempting to extract

Thanks Velaki,


Obviously this works beautifully. I've tried reading the perldoc info on split.... and tried to put in an incrementing loop to give the values unique names such that these can then be passed to php code for insertion into mysql. It appears that split does all this in one pass so incrementing a loop counter doesn't work. Can this @_array be used to directly insert into mysql table?


Thanks a bunch

Jim
jamaas btinternet com

Replies are listed 'Best First'.
Re^3: newbie attempting to extract
by Prior Nacre V (Hermit) on Oct 04, 2004 at 01:15 UTC

    This provides a unique value for each data item. It combines a row ID ($.) and a field ID ($i).

    # data_read use strict; use warnings; while (<DATA>) { chomp; my @data = split; for (my $i = 0; $i <= $#data; ++$i) { print "$._$i = $data[$i]\n"; } } __DATA__ qwerty qwerty qwerty asdf zxcv 1234 qwerty qwerty qwerty asdf zxcv

    Here's the output:

    [ ~/tmp ] $ perl data_read 1_0 = qwerty 1_1 = qwerty 1_2 = qwerty 1_3 = asdf 1_4 = zxcv 1_5 = 1234 2_0 = qwerty 2_1 = qwerty 2_2 = qwerty 2_3 = asdf 2_4 = zxcv [ ~/tmp ] $

    Here's a perl.com article which describes $. and other special variables.

    Regards,

    PN5