insta.gator has asked for the wisdom of the Perl Monks concerning the following question:
Hi all. Is it possible to use a defined variable in defining another variable? See example below, which is not working.
$ecounter=0; my @file_line_contents = split (/\|/,$_); while "$ecounter < 45" { $e$ecounter=length($file_line_contents[$ecounter]); $ecounter+=1; }
I tried concatenating the variables and that did not work either. Code is probably ugly but should convey basically what I am trying to do.
Thanks in advance
Update
I am doing validation of data. I have a file of records with 46 elements in each record. I need to validate the length of each element as well as do some content validation. This is why I was creating a variable containing the length for each. Is there a better way?
Thanks for pointing out the syntax errors. I'm not surprised. I did not check that before posting question. Just wanted to get the idea across.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using a variable to define a variable
by ww (Archbishop) on May 08, 2015 at 16:30 UTC | |
by insta.gator (Novice) on May 08, 2015 at 17:37 UTC | |
|
Re: Using a variable to define a variable
by hippo (Archbishop) on May 08, 2015 at 15:51 UTC | |
by AnomalousMonk (Archbishop) on May 08, 2015 at 15:56 UTC | |
by Athanasius (Archbishop) on May 08, 2015 at 16:15 UTC | |
|
Re: Using a variable to define a variable
by AnomalousMonk (Archbishop) on May 08, 2015 at 16:01 UTC | |
|
Re: Using a variable to define a variable
by CountZero (Bishop) on May 08, 2015 at 19:05 UTC | |
|
Re: Using a variable to define a variable
by aaron_baugher (Curate) on May 08, 2015 at 16:02 UTC | |
|
Re: Using a variable to define a variable
by edimusrex (Monk) on May 08, 2015 at 15:49 UTC |