in reply to Re^2: Loading data into an array from a file problem
in thread Loading data into an array from a file problem

Because (1,2,3) is three elements, and ($same_as_above_pulled_from_file) is just a single scalar value, not a list of several values.

Maybe you mean:

@names = split /,\s*/, $same_as_above_pulled_from_file;

...chomp and fiddle with split to get the desired results.


Dave

Replies are listed 'Best First'.
Re^4: Loading data into an array from a file problem
by pglinx (Acolyte) on Apr 20, 2006 at 23:27 UTC
    Yes that did the trick thank you.

      Be warned though, splitting on commas can only take you so far. For example, if you're dealing with quoted strings, any of which might actually contained embeded commas that should be treated as textual punctuation rather than delimiters, you'll get into trouble really fast. If it turns out that your dataset is more complex, use Text::CSV, or some other similar-purposed module.


      Dave