In my response, shown below, if I replace 
        $rhash=shift; # My approach
with
        $rhash=@_;        # Your Approach

then nothing will be printed. The reason is that the results are interpreted
in a scalar notation when you adopt the latter approach. Therefore, never
attempt to do an assignment as shown. If at all you still wanted to do that,
you could have given a,
        $rhash = @_[0];
that would have forced it to be in scalar context, though I do not think it
is a good idea to use array-slices either to the left or right of the
assignment. You can be at least pretty lax when having something like
@array[0] on the right side of the assignment, but never on the left hand
side though.

Thanks,
Rex


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 15, 2001 11:27 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: Printing with arrow notation


%hash =('key1'=>'value1','key2'=> 'value2');
 
PrintHash(\%hash);
sub PrintHash{
  $rhash = shift;
  for(keys %{$rhash}){
        print "$_ => $rhash->{$_}\n";
  }
}

would work.

-- Rex

-----Original Message-----
From: jonathan vandine [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 15, 2001 11:08 AM
To: [EMAIL PROTECTED]
Subject: Printing with arrow notation


I am passing a hash as a reference to a subroutine and want to print its 
values using arrow notation. Such as..
%hash ("value1", "value2", etc..);
PrintHash(\%hash);
    sub PrintHash
{
  $rhash = @_;
  What would work here for print using arrow notation?
}
Thanks

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to