in reply to Passing two arrays to a subroutine

Use references. You cannot pass more than one array (or hash) without using a reference.
Column(\@act_table,\@colm); ... sub Column { no warnings; my $actcol = shift; my $col = = shift; $colno++; print "In column : $colno\n"; foreach (@$col) { print "$_\n "; $_=~s/(<Tc(?:\s?\;?\s?\;?\d?)?>)(.*)/Entity_convert($2)/eg; $_= ThinSpace($_); #print "***************** $_\n"; } }
You are not using @actcol in the subroutine, so why are you passing it?
Update: One reason why you might be getting "garbage values first" is because you are starting your array iteration at index 1 instead of zero.

Replies are listed 'Best First'.
Re^2: Passing two arrays to a subroutine
by gandhit (Initiate) on Sep 27, 2010 at 13:06 UTC

    Thak you so much for your help

    However when i am passing arrays like this, It is adding one extra $_ in my array

    for ($h=0; $h<=$arg[1]-1; $h++) { my @colm=""; for ($t=0;$t<=$arg[2]-1;$t++) { push @colm, $act_table[$t][$h]; print "***##$act_table[$t][$h]\n"; } Column(\@act_table,\@colm); } } Alnfirstcol (@firstcol); ## Sends first column for alignment to Subro +utine Alnfirstcol #foreach my $item (@firstcol) { #print "$item \n"; #} ## Subroutine : Entity_conv ## Sends cellwise data to Entity module to convert entities ## After entity conversion sends cellwise data ThinSpace subroutine to + add thin space wherever required ## Sends column to Text_Nontext subroutine to evaluate whether column +is contains text data or non text data sub Column { no warnings; my $actcol=shift; my $col=shift; $colno++; foreach (@$col) { print "$_\n"; $_=~s/(<(?:Tr|Tc)(?:\s?\;?\s?\;?\d?)?>)(.*)/$1.Entity_convert( +$2)/eg; } foreach (@$col) { #print "After ## $_\n"; } ThinSpace(\@$col,\@$actcol); return (); }
    Please let me know if i am doing any mistake Thank you
      Using references does not change the array in any way. The problem must lie somewhere else - try to print, or better Data::Dumper, the array at various points in the program.
      BTW, instead of \@$col, you can use just $col.