Ask a Question related to PERL Miscellaneous, Design and Development.
-
Pacman #1
Wierd result from hash array
I'm getting 'used' to hash arrays and am writing a perl script to
backup my harddrive automatically. I couldn't figure out how to get
the following code to work, so I must be making a mistake I can't see.
Here's my expected result:
foreaching on key one
result: red/green
instead I get the following:
foreaching on key one
two:three
foreaching on key HASH(0x804c014)
:
#!/usr/bin/perl
$BLAH = "one:red:green";
%NADA = {};
($b1,@b2) = split(/:/,$BLAH);
$NADA{$b1} = [@b2];
foreach $k(keys %NADA) {
print "foreaching on key $k\n";
@x = @{$NADA{$k}};
print "result: $x[0]/$x[1]\n";
}
Any help would be great...remove the nospam_ from the email address...
D-
Pacman Guest
-
Wierd query result on MySQL 5 system
I have the following table (complete with sample data). When I run the query below on a mysql 4.1.14 system, the only row returned is row 4 as... -
Updating an array within a hash
Hi Everybdy, I am stuck in a problem for which I need your help. My problem spins around adding an element in an array within a hash. I have a... -
hash of hash of array slices
This works Foreach ( @{$hash{$key1}{$key2}} ) This does note Foreach ( @{($hash{$key1}{$key2})} ) This gives me this error .... Can't... -
adding an array as a hash value
Hi Dermot. Dermot Paikkos wrote: And use warnings; These variables need to have better names so that it's more -
wierd Array of Hash result
I have constructed an array of hashes (pointers to hash elements) and I have the following problem when I foreach or for loop through the array and... -
Pacman #2
Re: Wierd result from hash array
Made a slight mistake...the actual result I get is:
foreaching on key one
result: red/green
foreaching on key HASH(0x804c014)
:
In article <110920031318586753%piercer@nospam_pacbell.net>, Pacman
<piercer@nospam_pacbell.net> wrote:
--> I'm getting 'used' to hash arrays and am writing a perl script to
> backup my harddrive automatically. I couldn't figure out how to get
> the following code to work, so I must be making a mistake I can't see.
>
> Here's my expected result:
>
> foreaching on key one
> result: red/green
>
> instead I get the following:
>
> foreaching on key one
> two:three
> foreaching on key HASH(0x804c014)
> :
>
> #!/usr/bin/perl
>
> $BLAH = "one:red:green";
>
> %NADA = {};
> ($b1,@b2) = split(/:/,$BLAH);
> $NADA{$b1} = [@b2];
>
> foreach $k(keys %NADA) {
> print "foreaching on key $k\n";
> @x = @{$NADA{$k}};
> print "result: $x[0]/$x[1]\n";
> }
>
> Any help would be great...remove the nospam_ from the email address...
>
> D-
#############
Imagination is more important than knowledge - A. Einstein
Pacman Guest
-
Matija Papec #3
Re: Wierd result from hash array
X-Ftn-To: Pacman
Pacman <piercer@nospam_pacbell.net> wrote:use diagnostics;>backup my harddrive automatically. I couldn't figure out how to get
>the following code to work, so I must be making a mistake I can't see.
>
>Here's my expected result:
>
>foreaching on key one
>result: red/green
>
>instead I get the following:
>
>foreaching on key one
>two:three
>foreaching on key HASH(0x804c014)
could tell you lot of useful things.
--
Matija
Matija Papec Guest
-
James E Keenan #4
Re: Wierd result from hash array
"Pacman" <piercer@nospam_pacbell.net> wrote in message
news:110920031318586753%piercer@nospam_pacbell.net ...This line is your problem. You probably meant: %NADA = ();>
>
> I'm getting 'used' to hash arrays and am writing a perl script to
> backup my harddrive automatically. I couldn't figure out how to get
> the following code to work, so I must be making a mistake I can't see.
>
> Here's my expected result:
>
> foreaching on key one
> result: red/green
>
> instead I get the following:
>
> foreaching on key one
> two:three
> foreaching on key HASH(0x804c014)
> :
>
> #!/usr/bin/perl
>
> $BLAH = "one:red:green";
>
> %NADA = {};
You would have discovered this if you had enable warnings (or diagnostics,
as another poster indicated).
jimk
James E Keenan Guest



Reply With Quote

