Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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 );

Replies are listed 'Best First'.
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.

    "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)?

      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.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2021-09-17 05:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found