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

"Used only once" doesn't recognize arguement passing #1031

Closed
p5pRT opened this issue Jan 12, 2000 · 3 comments
Closed

"Used only once" doesn't recognize arguement passing #1031

p5pRT opened this issue Jan 12, 2000 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 12, 2000

Migrated from rt.perl.org#1982 (status was 'resolved')

Searchable as RT1982$

@p5pRT
Copy link
Author

p5pRT commented Jan 12, 2000

From kenneth_kron@icgcomm.com

perl -cw
open (NPORTS, "<MS_Ports.txt") ||
  &log("Master Pop port list not available", "​:$!", $Notify) ;
%NPops = &GetPortList(NPORTS) ;

Name "main​::NPORTS" used only once​: possible typo at - line 1.
Name "main​::NPops" used only once​: possible typo at - line 3.
Name "main​::Notify" used only once​: possible typo at - line 2.

bash-2.03$ perl -v

This is perl, version 5.005_03 built for sun4-solaris

Copyright 1987-1999, Larry Wall

Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source
kit.

@p5pRT
Copy link
Author

p5pRT commented Jan 12, 2000

From [Unknown Contact. See original ticket]

On Jan 12, Kenneth Kron said​:

The following code fragment incorrectly reports NPORTS only used once
when it is passed to a subroutine

Probably because Perl expects the NPORTS filehandle to be passed as
*NPORTS or \*NPORTS, unless the GetPortList function has been prototyped
to take a glob as its first argument.

perl -cw
open (NPORTS, "<MS_Ports.txt") ||
&log("Master Pop port list not available", "​:$!", $Notify) ;
%NPops = &GetPortList(NPORTS) ;

Name "main​::NPORTS" used only once​: possible typo at - line 1.
Name "main​::NPops" used only once​: possible typo at - line 3.
Name "main​::Notify" used only once​: possible typo at - line 2.

--

  MIDN 4/C PINYAN, USNR, NROTCURPI http​://www.pobox.com/~japhy/
  jeff pinyan​: japhy@​pobox.com perl stuff​: japhy+perl@​pobox.com
  "The Art of Perl" http​://www.pobox.com/~japhy/book/
  CPAN ID​: PINYAN http​://www.perl.com/CPAN/authors/id/P/PI/PINYAN/
  PerlMonth - An Online Perl Magazine http​://www.perlmonth.com/

@p5pRT
Copy link
Author

p5pRT commented Jan 12, 2000

From @TimToady

japhy@​pobox.com writes​:
: On Jan 12, Kenneth Kron said​:
:
: > The following code fragment incorrectly reports NPORTS only used once
: > when it is passed to a subroutine
:
: Probably because Perl expects the NPORTS filehandle to be passed as
: *NPORTS or \*NPORTS, unless the GetPortList function has been prototyped
: to take a glob as its first argument.

Even with a prototype, calling the function using & would defeat it.
So what you're basically doing is passing a bareword (an unquoted string),
that just happens to get interpreted later as an indirect file handle.
Note that under "use strict" you're not allowed to use a bareword that
way at all. If you ever plan to add "use strict", start passing your
filehandles as *NPORTS or \*NPORTS now, or you'll have a bunch of cleanup
to do later.

Larry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant