CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Dymanic Variable with Perl

 



200120022003
New User

Mar 24, 2010, 11:40 PM

Post #1 of 2 (1693 views)
Dymanic Variable with Perl Can't Post

I am writing a login script as follow:

====================================
my $login = param('login');
my $password = param('password');
my @newarraytom = ('name','company','email');

@selected_array = "@newarray".$login;
print @selected_array;
====================================
or directly print "@newarray".$login;

I want to use the $login variable to select appropriate array (@newarraytom), this case login as tom.

Can perl do that ? Thank you !


7stud
Enthusiast

Mar 25, 2010, 3:16 AM

Post #2 of 2 (1687 views)
Re: [200120022003] Dymanic Variable with Perl [In reply to] Can't Post


Code
use strict; 
use warnings;
use 5.010;

my %info_for = (
tom => ['ibm', 'abc@xxx'],
betty => ['google', 'xyz@xxx'],
);

my $name = 'tom';
say "@{$info_for{$name}}";

--output:--
ibm abc@xxx



(This post was edited by 7stud on Mar 25, 2010, 3:18 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives