in reply to my, my, my

I hear ya brother. I'm also tired of brushing my teeth and checking my rearview mirror.

Replies are listed 'Best First'.
Re: Re: my, my, my
by princepawn (Parson) on Nov 14, 2002 at 18:39 UTC
    Either that or given that my is so common it might be the default or pragma-chooseable.

    Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

      No, that wouldn't help. There has to be a way to discriminate declaration from use if you want to be able to tell a use of a mistyped variable apart from a declaration of a new one. I don't think three characters is a high price to pay for that service - especially considering you can, if the occasion lends itself to it, declare multiple variables with a single my.

      Your code has room for clarification and shortening in other areas; I'd write it like this:

      sub getDivisionList { (my ($agency_name, $nodes_only) = @_) or return; my $obj = __PACKAGE__->new($agency_name); my @node = $obj->{ts}->get_node_list('division'); return (!@node) ? () : $nodes_only ? ($o, @n) : map {($n->value('divname'), $n->value('siebel_id'))} @n; }
      (The jury's still out on how to indent the dangling last "default" expression, btw. I'm not entirely satisfied with any of the options so far.)

      Makeshifts last the longest.

        I think I'd layout the return expression like this, but like you, I'm not convinced its necessarially the 'best way'?

        return (!@node) ? () : $nodes_only ? ($o, @n) : map { ( $n->value('divname'), $n->value('siebel_id') ) } @n;

        As for the first line of the sub...without actually trying it, I'm not sure quite what the or is checking for. Is that equivalent to

        return unless my($agency_name, $nodes_only) = @_;

        If so, is there an advantage in using the or form?


        Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
        Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
        Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
        Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.