PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 28, 2022

[FIXED] What is the "once" warnings in perl?

 April 28, 2022     perl, warnings     No comments   

Issue

I have code that has,

no warnings 'once';

Reading man warnings I don't see an occurrence of /once/ what does this do?


Solution

So long as you don't have strict on, perl allows you to use a variable without declaring it.

perl -wE'$foo = 4;'

Which outputs,

Name main::foo used only once: possible typo at -e line 1.

Note under strict this wouldn't even be permitted,

Global symbol $foo requires explicit package name (did you forget to declare my $foo?) at -e line 1.

You can disable the warning though, without enabling strict by doing no warnings "once"; Though I would suggest strongly you simply remove the unused code instead of silencing the warning.

perl -wE'no warnings "once"; $foo = 4;'

Which both looks ugly and does nothing.



Answered By - Evan Carroll
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing