thank you for replying again! my actual problem is my if clause in my foreach is not working for the second hash value.
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 %hoa; my $hba; for $hba (@hbas) { $hoa{$hba} = qx(/usr/bin/fcstat $hba|/usr/bin/grep -i "world wide port name"|/us +r/bin/cut -f2 -d:|sed s/0x//); } while (my ($key, $val) = each %hoa) { my ($str,$str1) = split / /, $hoa{$key}; print $str1,"\n"; foreach (<DATA>) { if ( /$str1/g ) { print "YES\n",qx(hostname),"\n",$key,$val,"\n"; print qx(/usr/bin/fcstat $key|head -n 7); print qx(/usr/sbin/lsmcode -cd $key); } } }
__DATA__ 10000000C95C0379 10000000C9551477 10000000C95A58AE
10000000C95CE93F 10000000C94056CD 10000000C9540D92 10000000C9502723 10000000C94FE5D7 10000000C948ACA7 10000000C959C9F9 10000000C956BD68 10000000C9619092 10000000C9639A5D "hba_FW.ksh" 146 lines, 2629 characters root@dxxxxxx:/export/resources/SOX/scripts> perl hba_FW.plx 10000000C95A58AE YES dunmpr01 fcs1 10000000C95A58AE FIBRE CHANNEL STATISTICS REPORT: fcs1 Device Type: FC Adapter (df1000fa) Serial Number: 1D63508268 Option ROM Version: 02881955 Firmware Version: T1D1.91A5 The current microcode level for fcs1 is 191105. 10000000C95C0379

In reply to Re^4: two vars from one string. by mikejones
in thread two vars from one string. by mikejones

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.