Changeset 2368

Show
Ignore:
Timestamp:
10/04/07 16:43:30
Author:
miyagawa
Message:

fixed issues with non-match regexp sub. also handle undef return values

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Web-Scraper/trunk/lib/Web/Scraper.pm

    r2367 r2368  
    9191    local *process_first = create_process(1, $tree, $stash, $current); 
    9292 
     93    my $retval; 
    9394    local *result = sub { 
     95        $retval++; 
    9496        my @keys = @_; 
    9597 
     
    109111 
    110112    # check user specified return value 
    111     return $ret if $ret
     113    return $ret if $retval
    112114 
    113115    return $stash; 
     
    227229 
    228230    no warnings 'uninitialized'; 
    229     if ($retval =~ /^\d+$/ && $_ ne $value) { 
     231    if (($retval =~ /^\d+$/ and $_ ne $value) or (defined $retval and !$retval)) { 
    230232        $value = $_; 
    231233    } else { 
  • Web-Scraper/trunk/t/16_filter.t

    r2366 r2368  
    1717    }; 
    1818    my $want = $s->scrape('<a>foo</a>'); 
    19     is $want, $block->expected, $block->name; 
     19    my $expected = $block->expected eq 'undef' ? undef : $block->expected; 
     20 
     21    is $want, $expected, $block->name; 
    2022}; 
    2123 
     
    6971--- expected 
    7072barbar 
     73 
     74=== no match 
     75--- want 
     76['TEXT', sub { s/xxx/yyy/g }] 
     77--- expected 
     78foo 
     79 
     80=== undef 
     81--- want 
     82['TEXT', sub { return }] 
     83--- expected 
     84undef 
     85 
     86=== number 
     87--- want 
     88['TEXT', sub { return 3 }] 
     89--- expected 
     903