![]() |
Hmm… that doesn't fix it. In the example
Code:
open -a PreviewCode:
my $historicalValue; |
Quote:
So that "open" is misplaced in @ARGV. But I don't see why that would prevent GetOptions from working. Note also that it is (IMHO) slightly strange to be assigning a scalar to an array with a statement like: @ARGV = $historicalUse; I would either use parentheses: @ARGV = ($historicalUse); or start with an empty array @ARGV=(); and then add the scalar with 'push': push(@ARGV, $historicalUse); But I guess it works, so it's just a matter of style. |
Quote:
@a = $x, $yis parsed as (@a = $x), $y;which is probably not what you want (and will give you a warning if you use warnings;). The warning is that $y is a useless evaluation in a void context, because it has no side-effects. Change it to have a side-effect, and the warning disappears: @a = $x, ++$y;parses as: (@a = $x), (++$y);Adding parentheses, as in: @a = ($x, $y);serves to change the grouping, but does not change the scalar-or-list nature of the assignment. What makes this a list assignment is the presence of a list on the left hand side of the assignment. These statements: @a = $x;are all parsed identically except for the varying numbers of superfluous parentheses. In all these cases, the right hand side is evaluated in list context because the left hand side is a list. A comma has different meanings in different contexts, so that in: ($x, $y) = @a;it's the comma on the left hand side of an assignment that creates the list. The parentheses are there only to make the comma bind tighter than the assignment. Parentheses are useful for delimiting an empty list, but they don't create one. You have to already be in list context for some other reason: @a = ; # syntax errorIn Perl, context is everything. The very meaning of an expression like "(7,8)" changes depending on its context. Learn to "follow the context", and Perl becomes less cryptic. |
| All times are GMT -5. The time now is 05:52 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.