Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

[Question] Perl function variable

  • 04-02-2011 4:29pm
    #1
    Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭


    Trying to teach myself Perl and having a strange one. The code is below, but does anyone know how to return multiple variables from a "foreach" loop in a function back to where it was called? Because I can't breakout of the {} with my variable the return value is always the last one and not the lot (if I make sense) . Here, $AA is always blank: (any ideas)
    my ($AA,$AE) = my_variables($recv_data);
    print $AA;
    print $AE;
    
    sub my_variables {
    		my @variables = split(/\|/,$_[0]);
    		foreach my $i(@variables) 
    			{
    			if(substr($i,0,2) eq "AA") {my $AA = substr($i,2);return $AA; }
    			if(substr($i,0,2) eq "AE") {my $AE = substr($i,2);return $AE; }
    			
    			}
    	
    	}
    


Advertisement