Re: Typeglobs, constants and sub refs

2009-09-17 Thread Matteo Riva
On Thu, Sep 17, 2009 at 8:22 PM, Uri Guttman wrote: > the strange way is because that is how perl does it. perl doesn't have a > proper macro mechanism which is how many langs do constants. so it needs > something that is parsed in perl and subs with empty prototypes work > well. the compiler see

Re: Typeglobs, constants and sub refs

2009-09-17 Thread Matteo Riva
On Thu, Sep 17, 2009 at 8:18 PM, Chas. Owens wrote: > Ah, use constant is just sugar for what he is doing.  And, given that > he is only adding the constants because they don't exist in very old > versions of Perl, it is likely that he is trying to support a version > of Perl prior to 5.004 (whic

Re: Typeglobs, constants and sub refs

2009-09-17 Thread Matteo Riva
On Thu, Sep 17, 2009 at 7:45 PM, Chas. Owens wrote: > Constants have a value beyond the numbers themselves.  Let's suppose > that there is a non-POSIX system that has a seek function that works > quite a bit like POSIX seek, but it use different values for beginning > of file, current location, e

Re: Typeglobs, constants and sub refs

2009-09-17 Thread Matteo Riva
On Thu, Sep 17, 2009 at 5:56 PM, Uri Guttman wrote: > hopefully that explains it. Unfortunately, not really :) I *know* about the symbol table and typeglobs, but I yet have to *understand* how it all works, and how to use it. My first question here - before everything else - is: why subs to ju

Typeglobs, constants and sub refs

2009-09-17 Thread Matteo Riva
After reading Uri's post about projects for beginners, I took a quick look at File::Slurp source code, and I was stuck at the very beginning. My knowledge of Perl is still very beginner level, but I want - time allowing - to improve as I like the language very much. Anyway, the code starts with t

Re: Best way to mix two lists

2009-07-11 Thread Matteo Riva
On Fri, Jul 10, 2009 at 9:25 PM, Gunnar Hjalmarsson wrote: > You can use a hash slice. > >   �...@{ $data{$key} }{ @fields } = split /:/, $val; Thanks Gunnar, your suggestion is enlightening. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...

Best way to mix two lists

2009-07-10 Thread Matteo Riva
Hello everybody, I have two lists and I want to merge them like this: element 1 of list A, element 1 of list B, A2, B2, A3, B3, etc. I need this to create a sequence of key/value for an anonymous hash. I'm using this code: # @fields contains the names of the hash keys # $val is a st