HI, a quetion from a newbie to perl.
I have a program that extract some fields:

#!/usr/bin/perl -w

use strict;

my ( $host, $hba, $storage, $fa ,$initiator , $target ) ;
my %wwn = ();

while ( <DATA> ) {
 next unless /\s+([A-Z]\w+)[_-](HBA\d)[_-]([A-Z]\w+)[_-](\w+)\s+ ...
WWN: \d\d\d\d\w{12}/;
( $host, $hba, $storage, $fa ) = /\s+([A-Z]\w+)[_-](HBA\d)[_-]([A-Z]\w
+)[_-](\w+)\s+/;

   print "HOST = $host , HBA = $hba , storage = $storage, FA = $fa
\n";

   $initiator = $host."-".$hba;
   $target  = $storage."-".$fa;

   push  $wwn{$initiator}, $1   if /WWN:\s+(1000\d{12})/;
   push  $wwn{$target}   , $1   if /WWN:\s+(500\d{13})/;

}

__DATA__
             DEV01-HBA0_DMX1-13CA
              WWN: 10000000C934A35B
              WWN: 5006048ACAFE1E4C
             DEV01_HBA0_CX-SPA_P0
              WWN: 10000000C934A35B
              WWN: 500601601060007E
             TEST01_HBA1_STK_TAPES1
              WWN: 100000E002239270
              WWN: 500104F000619193
              WWN: 500104F00061918D
              WWN: 500104F000619190
              WWN: 500104F00061919D

when I run it ,  I got

#emc_parse_switch_zone.pl
Type of arg 1 to push must be array (not hash elem) at ./
emc_parse_switch_zone.pl line 20, near "$1     if"
Execution of ./emc_parse_switch_zone.pl aborted due to compilation
errors.

so my questions:
1. what is wrong with push here?
2. how to properly determine the boundaris of the records.  each
record ending with the last "WWN: " lnes.


thanks.
ciwei


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to