Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Re: qw with anonomous list ref

by Jenda (Abbot)
on Oct 29, 2002 at 21:15 UTC ( #208881=note: print w/replies, xml ) Need Help??

in reply to Re: qw with anonomous list ref
in thread qw with anonomous list ref

Does anyone have any idea what would this be good for? I can't imagine any use for \(list).

The only thing that comes to mind is

$ref = \($hashref->{key}->{subkey});
In this case the
$ref = \{$hashref->{key}->{subkey}};
would mean something totaly different ($ref would be a reference to an anonymous hash) and
$ref = \$hashref->{key}->{subkey};
is not very clear.

So are there any other uses?


Replies are listed 'Best First'.
Re: Re: Re: qw with anonomous list ref
by BrowserUk (Pope) on Oct 29, 2002 at 21:57 UTC

    I have used it once for setting up an AoA structure.

    I filled 3 seperate arrays from reading and processing 3 different files and then combined them

    my @AoA = \(@a, @b, @c);

    Slightly easier than initialising (or pushing) 3 anon arrays and then filling them with push @{$AoA[n]}, $stuff; or whatever.

    Nah! Your thinking of Simon Templar, originally played by Roger Moore and later by Ian Ogilvy
Re^3: qw with anonomous list ref
by Aristotle (Chancellor) on Oct 29, 2002 at 22:58 UTC
    Most often I use this to do something to several arrays at once:
    my %silly_example; for(\(@couple, @of, @arrays, @here)) { $silly_example{shift @$_}++; splice @$_, 7, 1; push @$_, shift @$_; }
    Occasionally it comes it handy for a similar use of map or some such.

    Makeshifts last the longest.

\(LIST) useful with DBI bind_columns
by blssu (Pilgrim) on Oct 30, 2002 at 12:59 UTC

    If you're using DBI, then code like this:   $st->bind_columns(undef, \$a, \$b, \$c) can be written as   $st->bind_columns(undef, \($a, $b, $c)) That may be slightly easier to maintain.

    However, two caveats:

    • The \(LIST) form is confusing to many who read it, so make sure you are very consistent.
    • Most code I've seen use bind_columns() is less readable than fetch_hashref(), so if you're thinking of changing your coding style, think about dropping bind_columns() altogether.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://208881]
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: (4)
As of 2021-12-03 09:36 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (28 votes). Check out past polls.