Hey guys,
New perl user here.
I'm getting an error and I'm guessing i'm just stupid. I tried searching a bit and really didn't find a solution
Here's some silly test code I'm using. I have an array of array names (actually an array of strings). I simply want to grab that array of strings and use it to create arrays of the same name.
I've got to do something like this on a much larger scale, but decided to do proof of concept first.
Here's my test code snippet (I get no syntax or compilation error but it doesn't work)
#!/usr/bin/env perl
use Cwd;
our $cwd = getcwd();
@arr = ('cars', 'trucks');
@$arr[0] = (4,3,2,1);
print @trucks;
This on the other hand, works quite well and it seems to be the same thing with one line condensed
#!/usr/bin/env perl
use Cwd;
our $cwd = getcwd();
@arr = ('cars', 'trucks');
$str = $arr[0];
@$str = (4,3,2,1);
print @cars;
Wondering if somebody could point me in the right direction or slap some sense into my head
Thanks in advance
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.