Re: Using $_ in a function if no argument is passed

From: Paul Johnson (paul_at_pjcj.net)
Date: 04/02/04

  • Next message: Praful Bajaria: "New to Perl"
    Date: Fri, 2 Apr 2004 19:36:04 +0200
    To: "Beau E. Cox" <beau@beaucox.com>
    
    

    On Fri, Apr 02, 2004 at 07:18:25AM -1000, Beau E. Cox wrote:

    > sub to_upper
    > {
    > # point to passed arg or caller's $_
    > my $arg = $_[0] ? \$_[0] : \$_;

          my $arg = @_ ? \$_[0] : \$_;

    > # modify in place
    > $$arg = uc $$arg;
    > }

    $_ = "Leave me alone!";
    $s = "0";
    to_upper $s;

    -- 
    Paul Johnson - paul@pjcj.net
    http://www.pjcj.net
    

  • Next message: Praful Bajaria: "New to Perl"