At 8:31 PM -0800 11/9/98, Stewart Leicester wrote: >PowerBook 520c, 7.6.1, Perl 5.2.0r4. As you can see from the "File >'<AppleEvent>'", I ran these from the "Run MacPerl Front" BBEdit tool menu. > >Can anyone help me explain this? > >TIA! -Stewart Before I get flamed for answering this question; let me make everyone aware that I do not know everything. :) I'm a "intermediate" perl programmer in general, but I believe I see his problem. >This program: > >--------------------------------- >#!/bin/perl -w > >use strict ^ > >&DoInits(); > >print "pathSep=$pathSep\n"; >exit; > >sub DoInits { > $pathSep = ':'; >} #End of DoInits >-------------------------------- As one of the things I read to very begin with... "Each perl command must have a semi-colon at the end, unless it is a subroutine, or the last line of the script" >Gets this result: > >--------------------------------- ># Undefined subroutine &main::DoInits called. >File '<AppleEvent>'; Line 5 ># BEGIN failed--compilation aborted. >File '<AppleEvent>'; Line 5 >-------------------------------- Line 5 is: "&DoInits();" - it's having a problem seeing the script (paraphrased...) as "use strict&DoInits()" - end of command. Read below and let me step you through it. >And THIS program: > >--------------------------------- >#!/bin/perl -w > >use strict ^ > >#$x = '1'; <==== Added line >&DoInits(); > >print "pathSep=$pathSep\n"; >exit; > >sub DoInits { > $pathSep = ':'; >} #End of DoInits >-------------------------------- > >Gets this result: > >--------------------------------- ># Undefined subroutine &main::DoInits called. >File '<AppleEvent>'; Line 6 ># BEGIN failed--compilation aborted. >File '<AppleEvent>'; Line 6 >-------------------------------- All you did was add a comment, so it changed Line 5 to Line 6, as the script agrees with me. You STILL haven't added the semi-colon to the first command. >BUT... this program: > >--------------------------------- >#!/bin/perl -w > >use strict > >$x = '1'; <==== Changed line >&DoInits(); > >print "pathSep=$pathSep\n"; >exit; > >sub DoInits { > $pathSep = ':'; >} #End of DoInits >-------------------------------- > >WORKS! and gets this result: > >--------------------------------- ># Name "main::x" used only once: possible typo. >File '<AppleEvent>'; Line 5 >pathSep=: >-------------------------------- This one puzzles me a bit, I'll try to explain it how I see it... Feel free to correct me on this one... PERL sees the program as: #!/bin/perl -w ##script interpreter, fine use strict ##I don't see a semi-colon, let's continue. $x = '1'; ##I see a semi-colon, let's base it from here. --------- I copy/pasted the script into MacPERL, added a semi-colon (you should know where by now)... On "Syntax Check..." - I got this error... # Global symbol "x" requires explicit package name. File 'Untitled'; Line 5 # Global symbol "pathSep" requires explicit package name. File 'Untitled'; Line 8 # Untitled had compilation errors. Now I'm lost - thought I figured everything out. :) (AGAIN, I'm a intermediate, not a expert.) Now two of us are asking for help. :) >--- >Stewart Leicester "Ad Astra StewartL@JenSoft.com >JenSoft Technologies Per Aspera" 925/551-0130 > >***** Want to unsubscribe from this list? >***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch --Tim -------------------------------------------------------------------------------- "If the opposite of 'pro' is 'con' ... does that mean the opposite of 'progress' is 'congress'??" -- Unknown -------------------------------------------------------------------------------- ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch