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

Don't use local @ARGV=...; <> for slurping file contents #1466

Open
ferki opened this issue Feb 10, 2021 · 0 comments · May be fixed by #1511
Open

Don't use local @ARGV=...; <> for slurping file contents #1466

ferki opened this issue Feb 10, 2021 · 0 comments · May be fixed by #1511

Comments

@ferki
Copy link
Member

ferki commented Feb 10, 2021

Migrated from rt.cpan.org #98871 (status was 'new')

Requestors:

From [email protected] (@eserte) on 2014-09-14 13:47:34
:

Rex::Config is using something like

@ARGV = ...; <>

to slurp file contents, and this may happen during compile time (e.g. read_ssh_config is called in import(), so a "use Rex::Config" would trigger this code). Unfortunately this means that a currently active <> loop would break. See cpan-testers/CPAN-Reporter#20 for an issue where this actually happens.

Probably it's safer to use instead

do { open my $fh, $file or die $!; undef $/; <$fh> }

even if it's slightly longer. Or alternatively

use IO::File ();
join '', IO::File->new($file)->getlines;
@monsieurp monsieurp linked a pull request Oct 13, 2021 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant