in reply to Re^3: how to force scalar context (without scalar())?
in thread how to force scalar context (without scalar())?

That exactly answer my question. Thanks.
Boris
  • Comment on Re^4: how to force scalar context (without scalar())?

Replies are listed 'Best First'.
Re^5: how to force scalar context (without scalar())?
by ihb (Deacon) on Sep 19, 2004 at 21:40 UTC

    I really really wonder how you can think that

    func( aa => (my $aa = foo()), bb => (my $bb = bar()), );
    can be prettier than
    func( aa => scalar foo(), bb => scalar bar(), );
    One can argue code aesthetics all day, but your assignment can be a real pain in the long run and all it does is to fool the maintenance programmer into thinking that you especially want those values later. If you do this, although please don't, at least use a do block to handle the scoping issue (and make the maintenance programmer scratch his head a little less).
    func( aa => do { my $t = foo() }, bb => do { my $t = bar() }, );

    ihb

    Read argumentation in its context!

      Thanks, but you missed the whole point of my question from the beginning. Please reread the question. My intent is _not_ to replace all occurrence of scalar. Nor I try to re-implement the scalar function.
      Boris