Hi,
Pass reference to the array.

#!/usr/bin/perl
   my @array=("First","second","third");
   my $menuStr="im";
   @tempArray=change([EMAIL PROTECTED],$menuStr);
   foreach  (@tempArray) {
        print "\nElement: $_\n";
   }

   sub change
   {
    my ($ra_ref,$var)[EMAIL PROTECTED];
    print "The Varaible is $var \n\n";
    my @nwt = @$ra_ref;
    print "Arrays is @nwt \n";
    @nwt=(23,234,543);
    return @nwt;
   }

Anish Kumar K. wrote:

   #!/usr/bin/perl
   my @array=("First","second","third");
   my $menuStr="im";
   @tempArray=change(@array,$menuStr);
   foreach  (@tempArray) {
        print "\nElement: $_\n";
   }

   sub change
   {
    my (@nwt,$var)[EMAIL PROTECTED];
    print "The Varaible is $var \n\n";
    print "Arrays is @nwt \n";
    @nwt=(23,234,543);
    return @nwt;
   }

Result:

   The Varaible is
   Arrays is First second third im
   Element: 23
   Element: 234
   Element: 543

The varaible number is been appended to the arrya, I want as exactly
passed....

Anish

----- Original Message -----
From: "Edward Wijaya" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Saturday, November 06, 2004 8:52 PM
Subject: Re: how to pass array and varaible




sub mysub {
my ($var, @array) = @_;
       my @new_array = ();
       #do sth to @array or $var;
       return @new_array;
}

read - perldoc perlsub

Regards,
Edward WIJAYA


On Sat, 6 Nov 2004 12:48:26 +0530, Anish Kumar K. <[EMAIL PROTECTED]> wrote:



Hi

I want to pass a array and and a varaible to a subroutine and then some
processing will be done at the subtroutine and the array should be
returned....Please help me in trying to figure out...

Thanks
Anish



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












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




Reply via email to