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

Re: Records question

by rbc (Curate)
on Jan 11, 2003 at 00:45 UTC ( #226017=note: print w/ replies, xml ) Need Help??


in reply to Records question

The easiest way to print out @corps would be to use Data::Dumper
like so ...

... use Data::Dumper; ... print Dumper( @corps );


Comment on Re: Records question
Download Code
Re: Re: Records question
by sauoq (Abbot) on Jan 11, 2003 at 00:54 UTC
    print Dumper( \@corps );    # Will probably be neater.

    If you pass an array, it'll treat it as a bunch of scalars. Passing a reference is cleaner.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Re: Records question
by dave8775 (Novice) on Jan 11, 2003 at 00:56 UTC

    Great! That is definatelly quick (and simpler). :) Nonetheless to complete my code I will eventually have to access that data... and since it is nested and requires a long trail to get to the inner data is it considered easier or more common practice to simply store the data in an array and separate field values and records with some delimeter? Or am I on a good track (records is good for this and it won't be to difficult to get at the data)?

    thanks!
      Delimited data organization might seem tempting, especially if the concept of references is a little foreign. But I think you will find that in general, manipulating data internally using records is good, and internally using just delimited data in an array is bad, unless your data is very simple. In a complex record structure, each atom of data has a location, which can't be said for the delimited data; it requires you to create temporary variables and use split every time you need access to something. There is also the problem of quoting/escaping data so it doesn't interfere with the delimiter. Given that your record structure is intelligently organized (it seems that way so far), you really can't go wrong. Once you really come to understand Perl's way of handling references, you will find very little data that you can't model inside your program with complex structures. The same can't be said for a delimited array.

      See perlreftut for more info.

      blokhead

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-09-16 02:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (155 votes), past polls