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) );
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
#!/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;
--- 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
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
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
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
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
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
-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
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
11 matches
Mail list logo