|
|
Check syntax question...
I am going through another persons code. I turned on "strict" and
"warnings" and I am not sure what to do about this warning:
"Scalar value @_[0] better written as $_[0] at update_patch.pl line
939."
Should I change it to reflect what is suggested? Why did it suggest
that? I am just a wee learner of Perl.
Robert
|
|
0
|
|
|
|
Reply
|
bobx (95)
|
6/21/2004 4:52:47 PM |
|
On Mon, 21 Jun 2004, Bob wrote:
> I am going through another persons code. I turned on "strict" and
> "warnings" and I am not sure what to do about this warning:
>
> "Scalar value @_[0] better written as $_[0] at update_patch.pl line
> 939."
>
> Should I change it to reflect what is suggested?
Almost certainly yes. We'd have to see the code to be 100% certain, but
the chances of it not being better changed are very unlikely.
> Why did it suggest that?
In Perl, $ is used to mean scalar, which is a single value. @ is used to
mean array, a collection of values. The syntax of @array[2,3,4] for
example, means "the set containing the third, fourth, and fifth elements
of @array". The syntax @array[2] means "the set containing the third
element of @array". $array[2], on the other hand, means simply "the third
element of @array". There is almost never a reason to use a collection
containing one element where all you actually need is that one element.
That is what that warning is about.
> I am just a wee learner of Perl.
Read up! :-) Take a look at
perldoc perlsyn
for the syntax of Perl, and
perldoc perldiag
for a description and explanation of all the warnings you may encounter.
Paul Lali
|
|
0
|
|
|
|
Reply
|
Paul
|
6/21/2004 5:02:18 PM
|
|
Bob <bobx@linuxmail.org> wrote:
> I am going through another persons code. I turned on "strict" and
> "warnings" and I am not sure what to do about this warning:
>
> "Scalar value @_[0] better written as $_[0] at update_patch.pl line
> 939."
>
> Should I change it to reflect what is suggested?
Yes.
> Why did it suggest
> that?
Because sometimes it makes a difference.
> I am just a wee learner of Perl.
Your Question is Asked Frequently:
What is the difference between $array[1] and @array[1]?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
0
|
|
|
|
Reply
|
Tad
|
6/21/2004 11:21:33 PM
|
|
|
2 Replies
66 Views
(page loaded in 0.064 seconds)
Similiar Articles: const char ** syntax question - comp.lang.c++.moderatedUli -- [ See http://www.gotw.ca/resources/clcm.htm for info about ... Library version - comp.unix.solaris const char ** syntax question - comp.lang.c++.moderated ... Do the inplace edit without backup file generated. - comp.lang ...... Post Question | Groups | ... autosplit mode with -n or -p (splits $_ into $F) -c check syntax only ... Synplify synthesis error - comp.arch.fpgaI did another Check Syntax of the top level entity after, and I still got the warning ... Question regarding pragma translate_off/on , synthesis_off/on ... Hi all, Can anyone ... fprint syntax for repeating fields - comp.lang.awkquestion about gsub - comp.lang.awk fprint syntax for repeating fields - comp.lang.awk question about ... standard library reflects the "stream" concept in its syntax; see ... Check if .txt is empty - comp.soft-sys.matlabHi, Very simple/beginner question, but I'm having trouble finding a nice ... the size of the report text area ... way you ... if there's a syntax error, all I see back ... How to debug a SAS program? - comp.soft-sys.sasBy that I mean just scan the program to check for syntax errors and not actually ... Direct link: http://ssc.utexas.edu/consulting/answers/sas/sas54.html Question: I ... smtp check response 500 - comp.lang.rubyThis isn't a ruby question, and "Recipient >> address rejected: User unknown ... End Organisation See rfc2821 for the basic specification of SMTP; see also ... 500: Syntax ... ERROR 1064 (42000) - comp.databases.mysql... Post Question | Groups ... ERROR 1064 (42000) at line 13332: You have an error in your SQL > syntax; check the ... YASM - comp.lang.asm.x86... to the site - www.tortall.net/projects/yasm/ - to check ... I have found YASM very reliable as an Intel syntax x86 ... Just an ignorant question: Does anyone here know ... How best to detect duplicate values in a column? - comp.databases ...Somebody starting from the meta question will see a link to the meta answer, and ... On all the others, if there's a syntax error, all I see back is a blank screen or a ... network.nagios.plugins - Re: Re: syntax question check_nrpe ...Thanks Ian, but I want to configure everything from my Nagios server. The warning and critical tresholds for the disk must be configurable from the nagios-server How do you check the syntax of a JCL without running it?How do you check the syntax of a JCL without running it? Interview Questions 7/28/2012 11:55:14 PM
|
|
|
|
|
|
|
|
|