[wellylug] perl hacking

Jamie Baddeley wellylug at vpc.co.nz
Thu Apr 14 22:05:57 NZST 2005


Hi,

I'm trying to hack around with a perl script that has the following
code:



sub getblocksize {
    $blocksize=`snmpwalk -v 2c $host -c $community hrStorageAllocationUnits.$drive 2>/dev/null`;
    ($name,$blocks)=split(/ = /, chomp($blocksize));
    $blocks=&splitnamevalue($blocksize);
    $blocks=~s/\ .*//;
    return $blocks;
}


I'm no perl guru, and the problem is that the above needs some awk like statement that achieves the same as below:

 snmpwalk -v 2c $host -c community hrStorageAllocationUnits.$drive|awk
'{print $4}'

How would I do awk like things with the above perl?



cheers

jamie






More information about the wellylug mailing list