Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: a REFERENCE of array of hashes

by why_bird (Pilgrim)
on Jun 24, 2009 at 13:38 UTC ( #774394=note: print w/replies, xml ) Need Help??


in reply to Re^2: a REFERENCE of array of hashes
in thread a REFERENCE of array of hashes

I haven't got too much time so a couple of points to start with.

Learn regular expressions. I mean it. They look like a mess to begin with, but I promise, they're SO useful. I don't really use pack/unpack, so this isn't definitive, but I think they're usually used for 'weird' characters and formatting, or manipulating bits. Well, I'm sure many people will argue with 'usually' and tbh, if they can enlighten me on the matter, it'd be useful..!

A quick tip to get you going:

my $text="fakeemail@somewhere.com"; $text =~ /(.+?)@(.+?)/; print "$1, $2"; -------------- fakeemail, somewhere.com
=~ is the regex operator. the groups, indicated with brackets () that you match show up in the variables $1 and $2.

For comma separated values, I would also recommend that you use 'split' as I mentioned before. It's much easier and if the format of your fields change, it won't screw up your program.

@client is an array. A real array. You know it's a real array because you declared it 'my @client'.

\%entry is a hash reference. So you've made an array of hash references. I'm not sure really what they mean by a 'reference array of hashes' but I would interpret it in the way that you have.

why_bird
p.s. I haven't tested the snippets of code here or below, just so you know!
........
Those are my principles. If you don't like them I have others.
-- Groucho Marx
.......

Replies are listed 'Best First'.
Re^4: a REFERENCE of array of hashes
by Anonymous Monk on Jun 24, 2009 at 13:57 UTC
    Thank you so much for you help. Your hints are very useful. Since I only start learning Perl for the last 2 weeks I dont really know which is the best way to do certain work. Now I can focuse on split to try to work out the answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://774394]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2021-10-23 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (86 votes). Check out past polls.

    Notices?