John Doe am Dienstag, 10. Januar 2006 15.06: > [EMAIL PROTECTED] am Dienstag, 10. Januar 2006 14.08: > > I'm new to Perl and am trying to set a variable length byte array that is > > passed to a socket as a string for output. I have the following which > > works, but the commented out code doesn't. What am I doing wrong? > > Thanks. > > Don't forget to put > > use warnings; > use strict; > [...]
> > John: > > > > Thanks very much. That did the trick, except I get tons of errors when I > > include "use strict" like: > > > > Global symbol "$totalNumPkts" requires explicit package name at > > sibtest1.pl > > line 9. yes, that is because of the usage of undeclared variables. Simply define your variables with my, see perldoc -f my and, related, the other ways of declaring variables: perldoc -f our perldoc vars The usage of 'use strict' and declaring variables may look as "too much work", but it will help *a lot* in finding errors, even subtle ones. Not to speak from bigger projects :-) Best thing to do it always, even in 10 line scripts :-) > > But, it now sends the message size I wanted. I have been using O'Reilly's > > "Learning Perl" but it seems not to address everything. Do you have > > another reference that you think is better? Thanks again. "Learning Perl" is a good book, but it's intention is to teach the basics; the example are as short as possible to demonstrate something - nearly everything needed *in practice* is omittet, input sanitizing as an example. Good sources are f.e: - this list, or perlmonks.org, or any other place where realistic examples are discussed - the source code of standard perl modules - further perl code on cpan.org - ... With the time, you will know the people that are known to write good (open source) code. greetings, joe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>