develooper Front page | perl.beginners | Postings from August 2009

Help on regular expression !!

Thread Next
jet speed
August 3, 2009 04:19
Help on regular expression !!
Message ID:

I am new to perl,  I am having trouble capturing the required output from
the command, with my limited knowlege i tried to put something togather. not
sure how to proceed beyond.

What i am trying to achieve
for certain drives ex : B3494_901, B3494_102 from the outputlist is to  find
the index number ex: 19 for drive  B3494_102 as in the output below
 then collect the different index number for these selected drives  in a
variable $idx = 1:2:19:5
  then i can use the $idx inside the command 'tpconfig -multiple_delete
-drive $idx '

Any help would be much appericiated.


use strict;
use warnings;

my @tpd = `tpconfig -dl`;
my $idx;
my $drv;

foreach my $line (@tpd) {
chomp $line;
#$line  =~ m/^Index\s+\d\d/ && do {
$line  =~ m/^Index\w+/ && do {
$idx = $1;
print "$idx \n";
$line =~ /^Drive.*\s+\w\d+/ && do {
$drv =$1;
print "$drv /n";


(  tpconfig -dl  )command output below

       Drive Name              B3494_102
        Index                   19
        NonRewindDrivePath      /dev/rmt/23cbn
        Type                    hcart2
        Status                  DOWN
        SCSI Protection         SR (Global)
        Shared Access           Yes
        TLH(0)  IBM Device Number=974680
        Serial Number           000007897468

Different Drives

        Drive Name              B3494_901
        Drive Name              B3494_100
        Drive Name              B3494_102

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About