in reply to Unscalar'ize a fake array

G'day Gtforce,

The statement "I receive an array" is vague. What precisely does that mean? Is it passed as an argument to a subroutine? Is it returned from a subroutine? Is it populated in the middle of some code (e.g. '@result = ...', 'push @result, ...', etc.)?

I'd suggest you take a step back and look at how @result is generated. There could be a bug upstream which, when fixed, resolves this, and any other, downstream problems.

I can really only speculate; however, purely as an example of one possible scenario, a change to $/, which hadn't been suitably localised, could cause this sort of situation.

Test data:

$ cat pm_1199549_test_file.txt 2017-08-01 20MICRONS 37744 2016-08-01 20MICRONS 25966 2016-04-20 20MICRONS 30807 2016-04-01 20MICRONS 32780

Non-localised change (with respect to array population):

$ perl -e 'local $/; @x = <>; use Data::Dump; dd \@x' pm_1199549_test_ +file.txt [ "2017-08-01 20MICRONS 37744\n2016-08-01 20MICRONS 25966\n2016-04-20 +20MICRONS 30807\n2016-04-01 20MICRONS 32780\n", ]

Localised change (with respect to array population):

$ perl -e '{ local $/; } @x = <>; use Data::Dump; dd \@x' pm_1199549_t +est_file.txt [ "2017-08-01 20MICRONS 37744\n", "2016-08-01 20MICRONS 25966\n", "2016-04-20 20MICRONS 30807\n", "2016-04-01 20MICRONS 32780\n", ]

If you provide us with more information, we can probably offer better advice.

— Ken

Replies are listed 'Best First'.
Re^2: Unscalar'ize a fake array
by Gtforce (Sexton) on Sep 22, 2017 at 02:15 UTC

    Ken, thank you. The array was being populated somewhere at the beginning of the same code (no subroutines involved). I gave up struggling to understand/handling the delimiters and took a silly way out - I wrote the array into a file and read it back from file into memory - that helped lose my problems and get on with things. Am going to have to look through what I've done and what you've said, carefully (writing and reading back from a file is only a temporary thing that I'll eliminate shortly). Thank you once again.