Prasanna Kothari <[EMAIL PROTECTED]> wrote:

: Pass reference to the array.

    Prosanna is correct.


: #!/usr/bin/perl

use strict;
use warnings;


:     my @array=("First","second","third");
:     my $menuStr="im";
:     @tempArray=change([EMAIL PROTECTED],$menuStr);

    Should be

 my @tempArray=change([EMAIL PROTECTED],$menuStr);

    Always use strict and warnings. Even on small
test scripts.


:     foreach  (@tempArray) {

    I realize this is an example, but this also could
have been done without @array, $menuStr, and @tempArray.
The square brackets ( "[" & "]" ) allow the array
reference to be constructed in the subroutine call.

 foreach ( change( [ 'First', 'second', 'third'  ], 'im' ) ) {



:          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";

    It's also okay to use:

       print "Array is @$ra_ref\n";
       return ( 23, 234, 543 );


:      @nwt=(23,234,543);
:      return @nwt;
:     }
: 

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


-- 
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