mikejones has asked for the wisdom of the Perl Monks concerning the following question:

Hi All!

I want to place this one string into two vars. Then i will compare these vars to a list of strings using __DATA__

So I'd like to see from Dumper VAR1 and VAR2?

thank you!

sample data from OS command: root@dxxxxx:/export/resources/SOX/scripts> fcstat fcs0|grep -i node |c +ut -f2 -d: 0x20000000C95C0379 __OUTPUT__ $VAR1 = ' 0x20000000C95A58AE '; $VAR1 = ' 0x20000000C95C0379 '; __CODE__ use strict; use warnings; use Data::Dumper; my @hbas; open (LSDEV, "/usr/sbin/lsdev |") or die $!; while (<LSDEV>) { if ( /^(fcs\d+)/ ) { push (@hbas, +(split)[0]); } } my %hoh; for my $hba (@hbas) { $hoh{$hba} = qx(/usr/bin/fcstat $hba|/usr/bin/grep -i node|/usr/bin/cut -f2 +-d:); } while (my ($key, $val) = each %hoh) { #print "$key =>\n\t$val\n"; #print "\n"; $\ = "\n"; print Dumper($val); my $str = split /\s+/, $val; print $str; }

Replies are listed 'Best First'.
Re: two vars from one string.
by ikegami (Patriarch) on Mar 02, 2010 at 22:23 UTC
    There are ways of naming vars with Dumper, but if all you want is different names,you can pass multiple values to Dumper at once.
    print(Dumper(values(%hoh)));
      I used Dumper to illustrate the data was in one var! My goal is to have the values in 2 separate variables?
      ## @hbas contains fcs0 fcs1 my %hoh; for my $hba (@hbas) { $hoh{$hba} = qx(/usr/bin/fcstat $hba|/usr/bin/grep -i node|/usr/bin/cut -f2 +-d:); } ### above gives me WWN strings while (my ($key, $val) = each %hoh) { print "$key =>\n\t$val\n"; print $val; } __OUTPUT__ fcs1 => 0x20000000C95A58AE 0x20000000C95A58AE fcs0 => 0x20000000C95C0379 0x20000000C95C0379
        But they are in two separate variables, $hoh{fcs0} and $hoh{fcs1}. What's the actual problem?