[EMAIL PROTECTED] wrote:
> 
> I facing one issue in Perl script.  I am executing one command in Perl
> script and taking the output of that command in one array.  Now I want
> to execute some more commands on each value of the array.
> 
> But the problem is that I am passing each value of the array as a
> argument to that function but somehow it is not taking that value.
> 
> The output of the perl script is:
>  
> 
> *bash-3.00# perl backup.pl*
> */vob/test*
> *Locking VOB 0*
> *cleartool: Error: Unrecognized command: "lock:0"*
> *Locking of VOB 0 failed*
> 
> * *
> 
> Now what I want is I need value “/vob/test” instead of 0.
> 
> Please find the attached perl script.


It would be easier for this list if you posted your code in line.

Your original code was

> #! /usr/bin/perl
> 
> # Perl script to take the backup of critical clearcase data
> 
> @vob_lst=system("/usr/atria/bin/cleartool lsvob -s");
> 
> foreach $a (@vob_lst)
> {
>  &lock($a);
> }
> 
>  sub lock()
> {
>  print "Locking VOB $a\n";
>  `/usr/atria/bin/cleartool lock:$a`;
>  if($?){print "Locking of VOB $a failed\n";}
>  else{print "Locking of VOB $a done\n";
>  }
> }


and I suggest something like this might work better (untested).
HTH,

Rob



#! /usr/bin/perl
use strict;
use warnings;

my @vob_lst = qx(/usr/atria/bin/cleartool lsvob -s);
chomp @vob_lst;

foreach my $a (@vob_lst) {
  lock($a);
}

sub lock {

  print "Locking VOB $a\n";

  my $result = qx(/usr/atria/bin/cleartool lock:$a);

  if ($?) {
    print "Locking of VOB $a failed\n";
  }
  else {
    print "Locking of VOB $a done\n";
  }
}

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


Reply via email to