Sayed, Irfan (Irfan) wrote:
> Hi All,

Hello,

> Following is my code....
>  
> # /usr/bin/perl
> use strict;
> use warnings;
>  
> my $CT = "/usr/atria/bin/cleartool";
> my @vob_list = `$CT lsvob -s`;
> my $ele;
> my @vob_list1;
> my $i;
> my $size;
> $size = $#vob_list+1;
>  
> for ($i=0;$i<=$size;$i++)
> {
>  $ele = $vob_list[$i];
>  $ele =~ s/$ele/"$ele",/g;
>  $vob_list1[$i] = $ele;
> }
>  
> I am getting following error.
>  
> Use of uninitialized value in regexp compilation at apply_trigger1.pl
> line 16.
> Use of uninitialized value in substitution (s///) at apply_trigger1.pl
> line 16.
> Use of uninitialized value in substitution (s///) at apply_trigger1.pl
> line 16.

Your for loop could be written more simply as:

for ( @vob_list ) {
    s/$_/"$_",/g;
    }


However you could use map and avoid the loop and substitution altogether:

my @vob_list1 = map qq{"$_",}, `$CT lsvob -s`;


And if you really need to populate both arrays @vob_list and @vob_list1 then:

my @vob_list1 = map qq{"$_",}, my @vob_list = `$CT lsvob -s`;





John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

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


Reply via email to