in reply to Re^2: Arrow operator usage in perl
in thread Arrow operator usage in perl

The return $hwwns; at the end of your code fragment suggests the code is part of a subroutine. Was a hash reference passed to the subroutine, e.g., do you see something like my ($hwwns) = @_; at the top of the subroutine?

Replies are listed 'Best First'.
Re^4: Arrow operator usage in perl
by dvinay (Acolyte) on Nov 09, 2013 at 19:20 UTC

    this is my Code block may be u can help me out of this

    sub gethpux1131hwwns {         my $hwwns;         my $hwpath;         my $hwwn;         my @fcdevices = `ioscan -kfnNC fc | grep "/dev/" 2>/dev/null`;         foreach my $fcdev(@fcdevices) {                 my @fcdump = `fcmsutil $fcdev`;                 foreach my $ln (@fcdump) {               if($ln =~ /Hardware Path is/)               {               (my $pathname, $hwpath) = split('= ', $ln);                         chomp($hwpath);               }              elsif($ln =~ /N_Port Port World Wide Name/)                {                (my $hwwnname, $hwwn) = split('= ', $ln);                            chomp($hwwn);                }              }                $hwwns->{$hwpath} = $hwwn;         }         return $hwwns; }

      Ah! The subroutine only returns a hash reference, like the following:

      use strict; use warnings; use Data::Dumper; my $hashRef = getHashRef(); print Dumper \$hashRef; print $hashRef->{'Hello'}; sub getHashRef { my $hwwns; $hwwns->{'Hello'} = 'world!'; return $hwwns; }

      Output:

      $VAR1 = \{ 'Hello' => 'world!' }; world!