Can't use string as a symbol ref

2007-12-17 Thread ciwei2103
Can somebody enlighten me what I'm doing wrong?

I have a list in a file , test.dat

sh cat test1.dat
0039
0038

sh  cat test1.pl
#!/usr/bin/perl -w
use strict;
my $input = $ARGV[0];

my @devices =  $input  ;
print devices =  @devices \n;

__END__

now run it with
sh test.pl test1.dat

Can't use string (test1.dat) as a symbol ref while strict refs in
use at ./test.pl line xx.


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




to test maximum consecutive numbers

2007-12-11 Thread ciwei2103
Give a disk sequence know that is incrementing with base 16,  such
as ,

0001
0003
0004
0008
0009
000A
000B
000F
0010
0011

how do I extract the a subset that is have  at least 4 consecutives,
such as  0008 0009 000A 000B

thanks. Jason


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




re: extracting fields from a matching line

2007-11-29 Thread ciwei2103
Given a code segment:

my $cmd = /usr/symcli/bin/something;
open  (SYMCFG,  $cmd | ) or die cannot open $!\n;

while ( SYMCFG ) {
  #print $_ if /FibreChannel  Online$/ ;
  # extract fields from the matching line
  my ( $ident, $fa , $type, $status ) = (split )[0,1,4,5] if /
FibreChannel  Online$/ ;
  print $ident, $fa,$status;

}
close SYMCFG ;

the sample output of running  $cmd looks like:

Ident  Symbolic  Numeric  Slot  Type   Status

DF-1A 01A   1   1   DISK  Online
FA-4A 04A   44   FibreChannel  Online
FA-13A   13A  13   13   FibreChannel  Online

the question:
I would expect to print out the field 0, 1, 4, 5
from the above line, however, while the first 3 fields print OK, the
last field $status seem always got undefined and

Use of uninitialized value at ./emc_device_matching_to_fa.pl line 32,
SYMCFG chunk 23.

what I'm doing wrong?

Thanks.


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




extracting fields from a matching line

2007-11-29 Thread ciwei2103
Given a code segment:

my $cmd = /usr/symcli/bin/something;
open  (SYMCFG,  $cmd | ) or die cannot open $!\n;

while ( SYMCFG ) {
  #print $_ if /FibreChannel  Online$/ ;
  # extract fields from the matching line
  my ( $ident, $fa , $type, $status ) = (split )[0,1,4,5] if /
FibreChannel  Online$/ ;

print $ident  $fa  $type $status \n if defined $status ;

}
close SYMCFG ;

the sample output of running  $cmd looks like:

Ident  Symbolic  Numeric  Slot  Type   Status

DF-1A 01A   1   1   DISK  Online
FA-4A 04A   44   FibreChannel  Online
FA-13A   13A  13   13   FibreChannel  Online

the question:
I would expect to print out the field 0, 1, 4, 5
from the above line, however, while the first 3 fields print OK, the
last field $status seem always got uninitialied and

Use of uninitialized value at ./emc_device_matching_to_fa.pl line 32,
SYMCFG chunk 23.

what I'm doing wrong?

Thanks.


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




about ( .)

2007-11-27 Thread ciwei2103
can someone explain how this code segment works:

# execute a command which may be on a local system or a remote system
sub _lrdo {
 my ($cmd,$exec,$rtn);
 ($cmd) = (@_);
 $exec = (_localsys()) ? $cmd : $SRSH{$SYS} $SYS $cmd;
 $rtn=_do($exec);
 return $rtn;
}

sub _haconfmakero {
_lrdo($VB/haclus -value ReadOnly);
}


Q1:  is the parenthes () around
  _lrdo ( .. )  optional when called?


Q2: why (_) around
  ($cmd ) = ( @_) ,

what is the desired effect of puting ( )
around @_ , and around ($cmd )

Q3: what ( ) archive in the line
   my ($cmd,$exec,$rtn );

thanks


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