If I may be so bold ;-) I recently took and online perl course and learned a number of things. In my homework scripts I added an ID block to identify which homeworks script, my name, etc. I also ran the easier scripts on Mac, Windows98 and UNIX to explore portability. This morning I really took a detour and expanded it to (I'm hoping) a more generic script others can use. It includes a number of things I learned reading this list. I placed all the action in a subroutine. This way you can comment one line and remove it from your output. I'll include the script and, after the __END__ tag, results from three operating systems. I'm open to comments on improving it, etc. Thanks in advance. Paul ---- #!/usr/bin/perl -w # IDblock.pl # Paul Corr 4-July-1999 # http://www.voicenet.com/~corr/ use strict; # configure project attibutes and pass to sub # METHOD ONE: #--- passes $author,$curproject,$projdesc to 'print_ID_block' sub. #my ($author,$curproject,$projdesc); #$author = "Paul Corr"; #$curproject = "Learning Perl: Chap. 8, Ex. 1"; #$projdesc = "Return name for number from 1-9"; #--- comment/uncomment this statement, as needed when testing scripts. #print_ID_block($author,$curproject,$projdesc); #MEHOD TWO: #--- passes list of strings (author, project, description) #--- to 'print_ID_block' sub. #--- comment/uncomment this statement, as needed when testing scripts. print_ID_block("Paul Corr", "Learning Perl: Chap. 8, Ex. 1", "Return name for number from 1-9" ); sub print_ID_block { ### START ID Block -- gives name, assignment, OS, etc. ### my ($authorname,$project,$description) = @_; # get passed params my ($thisOS,$endInput,$PerlVersion,$indent,@libpaths, $libpathslist,$todaysdate, $currentscript); $thisOS = $^O; # it's capital letter 'oh' if ($thisOS =~ "Win"){ $endInput = "Ctrl-Z"; } else { # MacOS or UNIX $endInput = "Ctrl-D"; } $PerlVersion = $]; @libpaths = @INC; $indent = " "; # literal 18 spaces $libpathslist = join("\n".$indent,@libpaths); $todaysdate = localtime; # The char in next statement is a zero. (Might return <AppleEvent> run # from BBEdit, or the full path and script name when run in MacPerl $currentscript = $0; use File::Basename; fileparse_set_fstype($thisOS); my($script,$path) = fileparse($currentscript); my $curdir = `pwd`; # these are 'backticks' (grave char) chomp $curdir; # Who and where are we? print "---------------------------------------------------\n"; print "Script author: $authorname\n"; print "Operating system: $thisOS\n"; print "EOF key sequence: $endInput\n"; print "Perl Version: $PerlVersion\n"; print "Library Paths: $libpathslist"; print "\n"; print "Date: $todaysdate\n"; print "Project: $project\n"; print "Description: $description\n"; print "Full File Spec: $currentscript\n"; print "Script Path: $path\n"; # print "Current Wkg Dir: $curdir\n"; print "Current Script: $script\n"; print "---------------------------------------------------\n\n"; ### END ID Block -- gives name, assignment, OS, etc. ### } __END__ RESULTS: NOTE: Path results may differ depending on whether the script is run in MacPerl, in BBEdit using the MacPerl Tools and Perl Palette or using the new integrated MacPerl menu in BBEdit v5.1. # Run from BBEdit v5.1 using Perl Palette's 'Run Script' # Note the file paths differ from MacPerl and BBE's MacPerl menu # 'Run' command: --------------------------------------------------- Script author: Paul Corr Operating system: MacOS EOF key sequence: Ctrl-D Perl Version: 5.004 Library Paths: MacintoshHD:MacPerl Ÿ:lib:MacPPC: MacintoshHD:MacPerl Ÿ:lib: MacintoshHD:MacPerl Ÿ:site_perl:MacPPC: MacintoshHD:MacPerl Ÿ:site_perl: : Dev:Pseudo: Date: Sun Jul 4 11:39:28 1999 Project: Learning Perl: Chap. 8, Ex. 1 Description: Return name for number from 1-9 Full File Spec: <AppleEvent> Script Path: : Current Wkg Dir: MacintoshHD:MacPerl Ÿ:wkgscripts Current Script: <AppleEvent> --------------------------------------------------- # Run from BBEdit v5.1 MacPerl menu 'Run' command: # Same as running in MacPerl itself --------------------------------------------------- Script author: Paul Corr Operating system: MacOS EOF key sequence: Ctrl-D Perl Version: 5.004 Library Paths: MacintoshHD:MacPerl Ÿ:lib:MacPPC: MacintoshHD:MacPerl Ÿ:lib: MacintoshHD:MacPerl Ÿ:site_perl:MacPPC: MacintoshHD:MacPerl Ÿ:site_perl: : Dev:Pseudo: Date: Sun Jul 4 11:40:23 1999 Project: Learning Perl: Chap. 8, Ex. 1 Description: Return name for number from 1-9 Full File Spec: MacintoshHD:MacPerl Ÿ:wkgscripts:IDblock.pl Script Path: MacintoshHD:MacPerl Ÿ:wkgscripts: Current Wkg Dir: MacintoshHD:MacPerl Ÿ:wkgscripts Current Script: IDblock.pl --------------------------------------------------- # Run directly in MacPerl: --------------------------------------------------- Script author: Paul Corr Operating system: MacOS EOF key sequence: Ctrl-D Perl Version: 5.004 Library Paths: MacintoshHD:MacPerl Ÿ:lib:MacPPC: MacintoshHD:MacPerl Ÿ:lib: MacintoshHD:MacPerl Ÿ:site_perl:MacPPC: MacintoshHD:MacPerl Ÿ:site_perl: : Dev:Pseudo: Date: Sun Jul 4 11:39:51 1999 Project: Learning Perl: Chap. 8, Ex. 1 Description: Return name for number from 1-9 Full File Spec: MacintoshHD:MacPerl Ÿ:wkgscripts:IDblock.pl Script Path: MacintoshHD:MacPerl Ÿ:wkgscripts: Current Wkg Dir: MacintoshHD:MacPerl Ÿ:wkgscripts Current Script: IDblock.pl --------------------------------------------------- # Run in ActivePerl on Windows98 (VirtualPC): --------------------------------------------------- Script author: Paul Corr Operating system: MSWin32 EOF key sequence: Ctrl-Z Perl Version: 5.00503 Library Paths: D:/Programs/Perl/lib D:/Programs/Perl/site/lib . Date: Sun Jul 4 11:39:51 1999 Project: Learning Perl: Chap. 8, Ex. 1 Description: Return name for number from 1-9 Full File Spec: IDblock.pl Script Path: .\ Current Wkg Dir: Current Script: IDblock.pl --------------------------------------------------- # Run in my UNIX shell account: --------------------------------------------------- Script author: Paul Corr Operating system: freebsd EOF key sequence: Ctrl-D Perl Version: 5.00404 Library Paths: /usr/local/lib/perl5/i386-freebsd/5.00404 /usr/local/lib/perl5 /usr/local/lib/perl5/site_perl/i386-freebsd /usr/local/lib/perl5/site_perl . Date: Sun Jul 4 12:20:53 1999 Project: Learning Perl: Chap. 8, Ex. 1 Description: Return name for number from 1-9 Full File Spec: ./IDblock.pl Script Path: ./ Current Wkg Dir: /usr/www/users/corr Current Script: IDblock.pl --------------------------------------------------- ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org