Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: remove 16 Zeros

by eghdam (Initiate)
on Oct 13, 2015 at 11:49 UTC ( #1144678=note: print w/replies, xml ) Need Help??


in reply to Re: remove 16 Zeros
in thread remove 16 Zeros

Hi! Yes thank u for Response. PVID is allways 32

Charachters.

My Script is:

@output =`command` # Output looks like 7 lines and on line is the pvid:

pvid 00c1be9a467335ce0000000000000000

foreach $line (@output) {

if ($line =~ /pvid ..... here i want to grep only the 32 charachters

$pvid = $1 } i just want to get the $pvid.

Replies are listed 'Best First'.
Re^3: remove 16 Zeros
by flexvault (Monsignor) on Oct 13, 2015 at 20:32 UTC

    eghdam,

    Why make it so complicated ( however it is your script :-)

    ############# UNTESTED ################ use strict; my $pvid = ''; # initialize my @output = `command`; # Output looks like 7 lines and on [one] li +ne is the pvid: # pvid 00c1be9a467335ce0000000000000000 # I use qx/command/; # easier to see in cod +e for me! foreach my $line ( @output ) { # print "$line\n"; ## If not working, use print to figure out w +hat's happening if ( substr( $line, 0, 5 ) eq 'pvid ' ) { $pvid = substr( $line, 6, 16 ) # or '32' as you require last; } } if ( $pvid eq '' ) { ... } ## Generate warning or do some error h +andling!

    I'm coding to my style, but you are free to chose what works for you. But remember if you have to go back to the code and update, make it as easy to understand as possible. Don't spend 2 hours figuring out what you did and then make a 2 line update.

    Good Luck...Ed

    "Well done is better than well said." - Benjamin Franklin

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1144678]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2020-10-24 18:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (246 votes). Check out past polls.

    Notices?