On Sun Sep 29 13:24:28 2013, plokinom@gmail.com wrote: > But regarding library code: If your library code blindly modifies global > variables (such as $_), it's probably broken. --- It didn't "blindly modify" it. The value of $_ was *saved* in the code that made use of it and restored when done. That would *seem* to be a perfectly reasonable solution in most languages. Even in assembler, if you use registers, you save them, you use them, you restore them. Asking for that ability in perl. if I have: sub reader() { my save=$_"; open(my $fh, "<myfile") or die "open:$!"; while (<$fh>) { ... } $_=$save; } that saves $_ and restores it upon exit -- it will still fail if, in the callstack above "somewhere", that called this -- it was called from a for ('a' 'b' 'c') { ...reader() } reader will fail with an error claim it attempted to modify a read-only var. The library function cannot use while(<>) while "$_" is read only -- despite the fact that it was trying to be "good" and saved $_ before using it (and restored it upon exit). That is the issue. --- via perlbug: queue: perl5 status: rejected https://rt.perl.org:443/rt3/Ticket/Display.html?id=120047Thread Previous | Thread Next