teamassociated has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; $lsmapFH = new FileHandle "/usr/ios/cli/ioscli lsmap -vadapter $option +s[4] |" or die $!; while (<$lsmapFH>) { if (/no virtual device found/i) { warn "\n\nThis vhost $options[4] has no clients using me, tr +y again with a correct vhost #!\n\n"; die $!; } chomp; $vh = (split)[0] if /^vhost/i; $clid = (split)[2] if /^vhost/i; $cltid = sprintf "%d", $clid; } $lsmapHash{$vh} = { 'clientID' => $cltid, }; } use Data::Dumper; print Dumper \%lsmapHash; $VAR1 = { 'vhost10' => { 'clientID' => '0' } works fine in CLI: # perl -le '$clid=0x0000000a; $cltid= sprintf "%d", $clid; print $clti +d;' 10 __SAMPLE_OUTPUT__ from lsmap SVSA Physloc Client Pa +rtition ID --------------- -------------------------------------------- --------- +--------- vhost10 U9117.MMD.218A8B7-V1-C2 0x0000000b VTD vtscsi25 Status Available LUN 0x8100000000000000 Backing device l02duapXXXX_r1.58ff94782d7c325acc49a8dd9c04bb1e Physloc Mirrored N/A VTD vtscsi26 Status Available LUN 0x8200000000000000 Backing device l02duapofdev_b1.0ee86903d4951ce38a9b691b322ff1d2 Physloc Mirrored N/A
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sprintf to hash
by toolic (Bishop) on Sep 19, 2014 at 18:58 UTC | |
|
Re: sprintf to hash
by ikegami (Patriarch) on Sep 19, 2014 at 18:54 UTC | |
|
Re: sprintf to hash
by RonW (Parson) on Sep 19, 2014 at 23:02 UTC |