Open p5pRT opened 9 years ago
Formats are a long-standing feature of perl which many programmers and programs do not use. This bug is not about getting rid of formats. However\, there are some builtin variables for use with formats which don't make sense otherwise.
I am particularly thinking of $%\, 'the current page number'\, and $-\, 'the number of lines left'. I can't imagine anyone using these when not using formats. Their default seems to be zero.
However\, they can hide typos in code\, e.g. $->[0] for $_->[0].
Please add a warning at run time if these builtin variables are used but format() has never been called.
It is possible that other format-related variables are set up by some programs before the first call to format()\, so I don't suggest warning on all of them. But these two in particular seem like nobody would want to read or set them without calling format() first.
On Fri Feb 06 05:47:14 2015\, eda@waniasset.com wrote:
Formats are a long-standing feature of perl which many programmers and programs do not use. This bug is not about getting rid of formats. However\, there are some builtin variables for use with formats which don't make sense otherwise.
I am particularly thinking of $%\, 'the current page number'\, and $-\, 'the number of lines left'. I can't imagine anyone using these when not using formats. Their default seems to be zero.
However\, they can hide typos in code\, e.g. $->[0] for $_->[0].
Please add a warning at run time if these builtin variables are used but format() has never been called.
It is possible that other format-related variables are set up by some programs before the first call to format()\, so I don't suggest warning on all of them. But these two in particular seem like nobody would want to read or set them without calling format() first.
An alternative might be:
https://metacpan.org/pod/Perl::Critic::Policy::Variables::ProhibitEvilVariables
As to warning on those variables\, it's possible format is being done somewhere the compiler doesn't see yet\, or won't see until runtime.
Tony
The RT System itself - Status changed from 'new' to 'open'
Tony Cook via RT \<perlbug-followup \
As to warning on those variables\, it's possible format is being done somewhere the compiler doesn't see yet\, or won't see until runtime.
Indeed - which is why this would have to be a run-time warning\, unfortunately.
A global setting 'no formats' would be a way to disable these variables and others at compile time\, but is outside the scope of this bug.
-- Ed Avis \eda@​waniasset\.com
Migrated from rt.perl.org#123751 (status was 'open')
Searchable as RT123751$