Tim McGeary wrote:
> Hi...  I have an array of pipe delimited data from a file.  I need
> to go item by item of the array, splitting up the fields into
> separate variables so that I can insert other pre-determined fields
> into an SQL statement to load into a MySQL db.  I feel pretty
> confident about the SQL part, but I'm not sure the best way to
> split the fields of the array.  I have 4 pipe-delimited fields in
> each line of the array.
>
> is it as simple as doing:
>
> foreach $item (@array) {
> my ($key, $title, $url, $code) = split /\|/;
> do other stuff....;
> }


Looks good to me, but always start with

  use strict;
  use warnings;

and remember the default operand for split is $_.

Also, you may want to think about whether yo may have
leading or trailing pipe characters which will result in
additional empty start and end fields. You also may
want to strip whitespace from each field before you use
it.

Cheers,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to