#!/usr/bin/perl -w # dotest.pl # pod at tail use strict; use vars qw( $scalar1 $scalar2 $scalar3 @list1 @list2 @list3 @list4 ); my $configfile = 'dotest.conf'; print "\n", "Starting $0\n", "Reading vars by \"do\"ing $configfile\n", ; do "$configfile"; print "Printing var contents with $0\n\n", " \$scalar1 contains: $scalar1\n", " \$scalar2 contains: $scalar2\n", " \$scalar3 contains: $scalar3\n", ; print "\n \@list1 contains: "; for(@list1) { print"\n $_"; } print "\n \@list2 contains: "; for(@list2) { print"\n $_"; } print "\n \@list3 contains: "; for(@list3) { print"\n $_"; } print "\n \@list4 contains: "; for(@list4) { print"\n $_"; } print "\n\nDone running $0\n\n"; =head1 Title dotest.pl =head1 Description Test scriptlet for Perl's builtin "do" function. =head1 Comments The config file doesn't appear to need: chmod +x shebang line And must not include vars declared lexically with 'my' Better to declare the vars lexically in main script with 'my', instead of the above global declaration with 'use vars qw...' but I can never seem to remember the right syntax for my'ing a group of vars. =head1 Author ybiC =head1 Updated 2001-06-21 14:40 Add @list4. Add Sample run to pod. Add Contents of config file to pod. =head1 Contents of config file $scalar1 = 'now is the time'; $scalar2 = 'it was the best of times'; $scalar3 = 'tiiime is ticking away, tick-tick-ticking away'; @list1 = qq($scalar1 $scalar2 $scalar3); @list2 = qw($scalar1 $scalar2 $scalar3); @list3 = ("$scalar1", "$scalar2", "$scalar3"); @list4 = qq($scalar1, $scalar2, $scalar3); =head1 Sample run Starting dotest.pl Reading vars by "do"ing dotest.conf Printing var contents with /cygdrive/d/Perl/DR/dotest.pl $scalar1 contains: now is the time $scalar2 contains: it was the best of times $scalar3 contains: tiiiime is ticking away, tick-tick-ticking away @list1 contains: now is the time it was the best of times tiiiime is ticking away, tick-tick-ticking away @list2 contains: $scalar1 $scalar2 $scalar3 @list3 contains: now is the time it was the best of times tiiiime is ticking away, tick-tick-ticking away @list4 contains: now is the time, it was the best of times, tiiiime is ticking away, tick-tick-ticking away Done running dotest.pl =cut