Help for this page

Select Code to Download


  1. or download this
    sub foo {
        return length($_[0]);
    }
    
  2. or download this
    sub dot_to_underscore {
        $_[0] =~ s/\./_/g;
    ...
    
    dot_to_underscore($string);
    print "$string\n";
    
  3. or download this
    sub dot_to_underscore {
        my $string = $_[0];  # No copy on 5.20+, but yes, copy under <5.20
    +.
        $string =~ s/\./_/;  # Copy made under 5.20 because of copy-on-wri
    +te.
        return $string;      # No copy under 5.20+ until the *caller* modi
    +fies the return string. But yes, the caller will get a copy pre-5.20.
    }