in reply to Re: Re: Small question: Why can't I print "@-"?
in thread Small question: Why can't I print "@-"?

Sure, you could use one of those. But, why would you?

Would it improve efficiency? Uh uh. Clarity? Certainly not.

I can't think of a good reason... can you?

BTW, I didn't realize this was a "bug" fixed in 5.8. I was thinking that perl didn't like to interpolate any variables that didn't start with a \w character. But, putting the name in braces will work with other (admittedly poor choices for) variable names such as @% and @!, not just ones perl knows.

-sauoq
"My two cents aren't worth a dime.";
  • Comment on Re: Re: Re: Small question: Why can't I print "@-"?

Replies are listed 'Best First'.
Re: Re: Re: Re: Small question: Why can't I print "@-"?
by demerphq (Chancellor) on Sep 23, 2003 at 23:30 UTC

    Sure, you could use one of those. But, why would you?

    Actually I'd rate the second one ( without the $" || "" ) as the preferred way to go. I don't tend to like interpolating arrays in anything other than quick and dirty code. If I'm going to output a list I prefer a more distinct end of field character than a space.

    But I _did_ put a smiley face on my node dude... :-)


    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi


      But I _did_ put a smiley face on my node dude... :-)

      Oh, I did see the smiley; it's just in my nature to take such suggestions seriously, I guess. Particularly when they come from you, demerphq.

      Although I'm not prejudiced against array interpolation in strings, I'm perfectly happy with using join() instead. (I do agree that avoiding $"||"" is better; it's ugly and prevents joining with "0".)

      But, your first suggestion made me shudder.

      :-)

      -sauoq
      "My two cents aren't worth a dime.";
      

        (I do agree that avoiding $"||"" is better; it's ugly and prevents joining with "0".)

        Yeah it should be $" // "" or defined $" ? $" : "", but you wouldn't do that normally. :-)

        But, your first suggestion made me shudder.

        That was the point. :-) Seriously tho, that trick can be useful, interpolating constants (which really is calling subs) inside of a string, or more specifically a here doc can be nicer than precalculating and interpolating in.


        ---
        demerphq

          First they ignore you, then they laugh at you, then they fight you, then you win.
          -- Gandhi