A module author has every right to expect that magic variables like $/ will be at their default values ...

Absolute unmitigated rubbish!

If a variable can only take one known value, it is called a constant. If a module author want to use a specific value for $/ or $\, it is his responsibility to ensure that he has that value: local $/ = '\n"; or whatever. Just as your authority figure, MJD does in his module Tie::File:

## from _read_record() in Tie::File { local $/ = $self->{recsep}; my $fh = $self->{fh}; $rec = <$fh>; } ... unless ($self->{rdonly}) { local $\ = ""; my $fh = $self->{fh}; print $fh $self->{recsep}; }
and a programmer who fails to localize changes in these variables is the one at fault for the trouble caused.

More of the same.

You are processing a fixed record length file. You set the record separator to that length and loop. Within that loop, you call some functions or methods from within a module.

What you are suggesting means that you, as application writer and code owner, now have to undo your requirements before you call each function or method--regardless of whether those modules make use of those variables because you don't know--and restore them afterwards, and every time you call those functions, in order that the module writer can be lazy.

use Some::Module qw[ funcA ]; use Someother::Module qw[ funcb ]; local $/ = \64; while( <$fh> ) { ## do stuff { local $/ = "\n"; funcA(); } ## Do stuff { local $/ = "\n"; funcB(); } ## Do stuff { local $/ = "\n"; funcA; } }

And you want to do this for every function or method? Regardless of whether it makes use of these variables, in every module you call, and everytime you call it? You're nuts. You have completely inverted the burden of responsibility here.

If module author needs a specific value for one of these variables within a subroutine or method,

  1. they know they need it;
  2. they know where they need it;
  3. the scope of the need is naturally bounded by the subroutine;
  4. they only need do it once;

Any other conclusion defies rationality.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^5: winter games, perl, ice and bling by BrowserUk
in thread winter games, perl, ice and bling by mobiusinversion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.