On Sat, Jul 19, 2008 at 2:45 PM, Bobby Jafari <[EMAIL PROTECTED]> wrote:
> Hi all, > > I am getting a syntax error with the following code: > > Line 10: @snmpSessions = (%snmpSession1, %snmpSession2); > Line 11: foreach %snmpSession (@snmpSessions) > Line 12: { > Line 13: # The following is call to my own subroutine that has > been tested and it works (:-) > Line 14: ðernetGlobalMode (\%snmpSession); > Line 15: } > > I get the following error: > syntax error at C:\SVN\qa-tests\2084\testcase\TC-Ether-Type-Test.pl line > 11, near "foreach %snmpSession" > syntax error at C:\SVN\qa-tests\2084\testcase\TC-Ether-Type-Test.pl line > 15, near "}" > Execution of C:\SVN\qa-tests\2084\testcase\TC-Ether-Type-Test.pl aborted > due to compilation errors. > > Thanks for your comments and feedback. > Regards, > Bobby > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > > > Hi ! The following statement is causing the problems :- *Line 10: @snmpSessions = (%snmpSession1, %snmpSession2);* The statement should be [EMAIL PROTECTED] = (\%snmpSession1, \%snmpSession2);* Remember, arrays can contain only scaler values so in case you want contents of some hashes etc in an array, you must use references. Having said that, the following lines * ** Line 11: foreach %snmpSession (@snmpSessions) Line 12: { Line 13: # The following is call to my own subroutine that has been tested and it works (:-) Line 14: ðernetGlobalMode (\%snmpSession); Line 15: }* should change to * Line 11: foreach $snmpS (@snmpSessions) Line 12: { Line 13: # The following is call to my own subroutine that has been tested and it works (:-) Line 14: ðernetGlobalMode ($snmpS); Line 15: }* Let us know in case you are facing more problems. Regards, Amit Saxena