banker123 said:
I am trying to populate a hash from two source files. The code below
only populates the last elements from the source files. I woul like to
populate the hash with all the elements foiund in the source files.
!/usr/bin/perl
use strict;
use warnings;
while ( <data1> ) {
($box,$priority)=split;
}
while ( <data2> ) {
($lockbox,$group)=split;
}
my %data = ( $box => { group => "$group" , priority => "$priority"} );
Post real code, not something you typed in, untested:
"use" not allowed in expression at C:\Documents and Settings\John\My
Documents\use.pl line 2, at end of line
syntax error at C:\Documents and Settings\John\My Documents\use.pl line
2, near "perl
use strict"
BEGIN not safe after errors--compilation aborted at C:\Documents and
Settings\John\My Documents\use.pl line 3.
Even if I consider the first line a copy mistake, and add the # I get:
Global symbol "$box" requires explicit package name at C:\Documents and
Settings\John\My Documents\use.pl line 6.
Global symbol "$priority" requires explicit package name at C:\Documents
and Settings\John\My Documents\use.pl line 6.
Bareword "data1" not allowed while "strict subs" in use at C:\Documents
and Settings\John\My Documents\use.pl line 8.
Global symbol "$lockbox" requires explicit package name at C:\Documents
and Settings\John\My Documents\use.pl line 9.
Global symbol "$group" requires explicit package name at C:\Documents
and Settings\John\My Documents\use.pl line 9.
Bareword "data2" not allowed while "strict subs" in use at C:\Documents
and Settings\John\My Documents\use.pl line 12.
Global symbol "$box" requires explicit package name at C:\Documents and
Settings\John\My Documents\use.pl line 12.
Global symbol "$group" requires explicit package name at C:\Documents
and Settings\John\My Documents\use.pl line 12.
Global symbol "$priority" requires explicit package name at C:\Documents
and Settings\John\My Documents\use.pl line 12.
Bareword "group" not allowed while "strict subs" in use at C:\Documents
and Settings\John\My Documents\use.pl line 12.
Bareword "priority" not allowed while "strict subs" in use at C:
\Documents and Settings\John\My Documents\use.pl line 12
..
Maye you thought that just manually adding use strict and use warnings
made things right?
Post real code.
Finally, how can you expect to get each item if you don't store the data
while you loop over your data?