08-11-2002, 10:11 PM
var name = "corrie";
var holder = "hi my name is "+name+" what's yours?";
but how to write the above in perl is baffling me, I'm just a beginner in perl and the '$ % @' things are really messing with my head, so that's probably my problem, I know the first is a variable, second is an associative array, and third is a plane old array, but the associations between them (how you can reference the @person with $person) is just confusing me, if anyone knows any good tutorials that cover this in great detail please let me know.
08-12-2002, 11:34 PM
Its quite slow round here these days, no matter I've solved this, if anyone's interested?
$name = "such and such "."is linked into this" ## yes, a dot. That was what was holding me back, a dot.
Well, it is usually the smallest things that get me.
08-13-2002, 02:11 AM
$name = "Corrie";
$holder = "Hi, my name is $name, what's yours?";
As you can see, you can just write the name of the variable within a double-quoted string and Perl will interpolate it for you.
As for the $array bit, it might seem a little weird at first, but if you think about it carefully it actually makes more sense to use the $ symbol here. Since what you're actually accessing with this syntax is a single scalar value, it makes sense to use the single scalar symbol...
To be honest just learning the basic scalar, array and associative array stuff is worth it, it makes sense once you get the hang of it :)
If you want to learn Perl, the best learning book, especially if you're not an experienced programmer already is Learning Perl by Randal Schwartz and Tom Christiansen (I think). But the definitive Perl book, which is slightly meatier and pretty comprehensive is called Programming Perl by Larry Wall, Jon Orwant and Tom Christiansen, also called the Camel Book.
There are millions of beginner's tutorials for Perl out there though, just do a search on Google and some will turn up.
08-13-2002, 11:53 AM
I'll have a look for those books, thanks again