Can't use string () as an Array ref

2007-07-06 Thread Brown, Rodrick
I'm getting the following when trying running the following code with use strict; without it, it works fine. #!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; my (@data,@contents); @data = STDIN; push(@contents,map { [ split/:/,$_ ] if/^\w+/ } (sort @data) );

Re: Can't use string () as an Array ref

2007-07-06 Thread Rob Dixon
Brown, Rodrick wrote: I'm getting the following when trying running the following code with use strict; without it, it works fine. #!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; my (@data,@contents); @data = STDIN; push(@contents,map { [ split/:/,$_ ] if/^\w+/ } (sort

error msg : can't use string as an ARRAY ref

2004-02-23 Thread Joseph Paish
#!/usr/bin/perl -w use strict ; use POSIX ; # i need POSIX for some calculations not shown here # variable declarations went here open (fh1, /path/to/filename) or die (nope) ; # sample of layout of fh1 :03/06/1997 sold 1000 widget1 0.230 0.00 # part number in this case is widget1;

Re: error msg : can't use string as an ARRAY ref

2004-02-23 Thread Joseph Paish
--- several lines stripped out --- # everything works well up to here # what i want to do is loop through the sorted unique part numbers array and print out all the array elements in @all_of_them that have a part number that matches that unique value. i then move onto the next

Re: error msg : can't use string as an ARRAY ref

2004-02-23 Thread Randy W. Sims
On 02/23/04 10:38, Joseph Paish wrote: --- several lines stripped out --- # everything works well up to here # what i want to do is loop through the sorted unique part numbers array and print out all the array elements in @all_of_them that have a part number that matches that unique

RE: error msg : can't use string as an ARRAY ref

2004-02-23 Thread Charles K. Clarkson
Joseph Paish [EMAIL PROTECTED] wrote: [snip] : # everything works well up to here : : # what i want to do is loop through the sorted unique part : numbers array and print out all the array elements in : @all_of_them that have a part number that matches that : unique value. i then

Re: error msg : can't use string as an ARRAY ref

2004-02-23 Thread WC -Sx- Jones
Randy W. Sims wrote: On 02/23/04 10:38, Joseph Paish wrote: snipped for ($ctr = 0 ; $ctr (scalar(@all_of_them)) ; $ctr++) { You don't need to say 'scalar' as it will be evaluated in the correct context without it. $#all_of_them -Sx- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For

Re: error msg : can't use string as an ARRAY ref

2004-02-23 Thread WC -Sx- Jones
Joseph Paish wrote: code snipped :) Please use perl -c program to test program before posting. syntax error at t line 12, near ) { Global symbol @all_of_them requires explicit package name at PROG line 13. Global symbol @temp_array requires explicit package name at PROG line 15. syntax

Re: error msg : can't use string as an ARRAY ref

2004-02-23 Thread Joseph Paish
i stripped out a fair chunk of code, including variable declarations to save space. i thought it would be better that way, if i just put in something like variable declarations went here instead of listing them all. that way, only the core code would be shown without cluttering it up with

RE: error msg : can't use string as an ARRAY ref

2004-02-23 Thread Ron Goral
-Original Message- From: Joseph Paish [mailto:[EMAIL PROTECTED] Sent: Monday, February 23, 2004 9:18 AM To: perl_beginner Subject: error msg : can't use string as an ARRAY ref SNIP MESSAGE while (fh1) { push (@all_of_them, $_ ) ; # an array of all the records in the file

Re: error msg : can't use string as an ARRAY ref

2004-02-23 Thread R. Joseph Newton
Ron Goral wrote: Here you are treating @all_of_them as a multi-dimensional array, and this is where the error occurs. Solve this by - a) Splitting the array element here print if (split / /, $all_of_them[$ctr] eq $temp1) ; b) Splitting $_ when you push the data into @all_of_them push