Hey I'm about 2 weeks into learning perl. I have several years experience in PHP + javascript + a couple of others.
Coming from other languages, perl is friggin weird. What gets me most is stuff like this:
%hash = ();
$hash{'key'} = 'val';
you initiate the hash with %, and add keys with $, which in my book is wickedly confusing.
now i realise that perl is an old language the evolved from humble beginnings so there's lots of convultion built in, kinda like PHP and its inconsistently named functions. i also realise that perl celetrates the fact that there is more then one way to do stuff. that's cool.
still after banging my head against the wall trying to get my head around most of the 'is it' @ or % or $ or {} or [] or () or \ or whatever issues, it seems to me that BY FAR the most intuitive way to program is to only use scalers and references, i.e.
$str = 'abc';
$hash = {}
$hash->{'key'} = 'val';
$array = [];
push @$array, 'val'; # one of the few times you ever use a @ or a %
print $array->[0];
is it ok to program exclusively like this? everywhere else on this site i see people intialise arrays with @array = ();, so i feel like i'm missing something here?
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.