Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readdir doesn't autopopulate $_ #32

Closed
toddr opened this issue Jan 18, 2019 · 2 comments
Closed

readdir doesn't autopopulate $_ #32

toddr opened this issue Jan 18, 2019 · 2 comments

Comments

@toddr
Copy link
Member

toddr commented Jan 18, 2019

#!/usr/bin/perl

use strict;
use warnings;
use Test::MockFile;

my $mock_obj = Test::MockFile->dir( '/path', [qw/uh like whut/] );

if ( opendir( my $dh, $mock_obj->{'file_name'} ) ) {
    print "opened dir $mock_obj->{'file_name'}\n";
    while ( readdir $dh ) {
        print "- $_\n";
    }
    closedir($dh);
}
else {
    print "cannah do iht capt'n\n";
}
$>perl foo.pl 
opened dir /path
Use of uninitialized value $_ in concatenation (.) or string at foo.pl line 12.
- 
Use of uninitialized value $_ in concatenation (.) or string at foo.pl line 12.
- 
Use of uninitialized value $_ in concatenation (.) or string at foo.pl line 12.
- 
Use of uninitialized value $_ in concatenation (.) or string at foo.pl line 12.
- 
Use of uninitialized value $_ in concatenation (.) or string at foo.pl line 12.
- 
@toddr
Copy link
Member Author

toddr commented Jan 24, 2019

This turns out to be a bug in perl. https://rt.perl.org/Public/Bug/Display.html?id=133795

@toddr toddr changed the title readdir (and probably others) don't autopopulate $_ readdir doesn't autopopulate $_ Jan 24, 2019
@toddr
Copy link
Member Author

toddr commented Jan 24, 2019

Given this is a confirmed bug in perl, I'm closing this case for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant