Help for this page

Select Code to Download


  1. or download this
    # File: defect1.pl
    use strict;
    ...
    
    $str =~ /\G(\s*)/g or die;
    print("match3: pos=", pos($str), "\n");
    
  2. or download this
    match1: pos=2
    match2: pos=2
    Died at defect1.pl line 13.
    
  3. or download this
    use strict;
    use warnings;
    ...
    my ($x) = ($str =~ /\G(x)/g) or die;
    defined(pos($str)) or warn("pos() is undefined!\n");
    print("this should be x:$x\n");
    
  4. or download this
    pos() is undefined!
    this should be x:x
    
  5. or download this
    use strict;
    use warnings;
    ...
    my $x = ($str =~ /\G(x)/g)[0] or die;
    defined(pos($str)) or warn("pos() is undefined!\n");
    print("this should be x:$x\n");
    
  6. or download this
    pos() is undefined!
    this should be x:x
    
  7. or download this
    use strict;
    use warnings;
    ...
    my $x = $1;
    defined(pos($str)) or warn("pos() is undefined!\n");
    print("this should be x:$x\n");
    
  8. or download this
    this should be x:x
    
  9. or download this
    This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-li
    +nux-thread-multi