Help for this page

Select Code to Download


  1. or download this
    (my $var1 = <<EOT) =~ s/\r?\n/(munched)/g;
    First line of "var1"
    ...
    First line of "var2"
    Second line of "var2" had a newline here ->
    EOT
    
  2. or download this
    # Was building $var3 in scalar instead of list context
    # my $var3 = map { s/\r?\n\Z/(munched)/; $_ } <<EOT;
    ...
           $interpolated
    And the last newline is also absent ->
    EOT
    
  3. or download this
    my $var4;
    # This generates "Modification of a read-only value attempted at";
    ...
    
    EOT
    }
    
  4. or download this
    # map{}' on the last key is ok.
    my $href = {
    ...
      $href->{key2}->{subkey2} = "Set after eval";
      $@ = undef;
    }
    
  5. or download this
    # This doesn't die, but gives the count of matches...
    $href->{key3} = {
    ...
    EOT
             subkey3 => "No explosion here...but the count of matches",
            };
    
  6. or download this
    $href->{key4} = {
             subkey1 => "Hello",
    ...
             },
             subkey3 => "No explosion here...",
            };
    
  7. or download this
    use strict;
    use warnings;
    ...
    key4->subkey3
    <$href->{key4}->{subkey3}>
    EOF