in reply to Loading data into an array from a file problem

What am I doing wrong?

You arn't asking a question about your actual code and you didn't use <code></code> tags.


___________
Eric Hodges

Replies are listed 'Best First'.
Re^2: Loading data into an array from a file problem
by pglinx (Acolyte) on Apr 20, 2006 at 22:39 UTC
    oops why does the first work and the second don't
    @Names = (1,2,3); @Names = ($same_as_above_pulled_from_file);

      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

        Yes that did the trick thank you.

      In order to recieve help you will need to put a little more work than that in ;) Show us both the working and the non working versions (the whole version so we can run it and see what it does) and explain what "works" and "doesn't work" mean to you. Your expectations and ours may differ greatly so the more you say explicitly the less there is for us to guess about.


      ___________
      Eric Hodges