#!perl -sw use strict; use vars qw/$f $s $t $debug/; #! This allows us to reference global vars without violating strict. =pod comment only! Note: $::var is (assuming we are in main) shorthand for saying $main::var which is the same as $var if we aren't using strict and we haven't defined my $var at the current scope. (I'm sure that I haven't captured the all the semantics in this comment, but the Perl lawyers will correct me :) if -debug not on the command line, it would set my $debug to undef, which would cause warnings later when we try to do 'print "something\n" if $debug;'. we could use defined, but that's hard work. =cut my $debug = $::debug || 0; my $file = $::f || 'd:/temp/temp.dat'; #! Use a tempfile by default my $size = $::s || 4096; #! default size my $time = $::t || time; #! default to now. print <210020 C:\test\210020.pl will run with settings debug: 0 file: d:/temp/temp.dat size: 4096 time: 1036283982 C:\test>210020 -debug -f="./temp.dat" -s=8192 C:\test\210020.pl will run with settings debug: 1 file: ./temp.dat size: 8192 time: 1036283985 C:\test>