Walter, Ronald, At 11:17 PM 9/12/99, Walter Torres wrote: >> At 2:42 +0930 1999.09.12, Henry Penninkilampi wrote: >> >I want to determine the full path to the folder in which a MacPerl >> >application resides, and has just been launched. >> >> $ENV{MACPERL} gives exactly that. Ronald stated: >Sure, that works, but so does this... > ># Remove the file name from the complete path ># Win32, MacOS & UNIX compliant >( $scriptPath = $0 ) =~ s{[^\\\/:]*$}{}; One needs to distinguish: (A) The full path wherefrom the _MacPerl SCRIPT_ was launched, which is part of $0, and (B) The full path wherein MacPerl application, and thence standard libraries are to be found, which is $ENV{MACPERL}. The following small program illustrates this: #!perl -w # print_env_argv.pl ######################################################################## # # Display the operating environment, script path, and arguments. # # No arguments required, but they will be displayed if invoked as # a droplet or via script line. # # Author: Larry F. Allen-Tonar # # Variables # my $k; my $i; my ($head_cntrl, $item_cntrl) = ( "\n---------- %s ----------\n" , " %3d %-10s <%s>\n" ); # # Display heading + all environmental variables. # Note: At minimum, expect MACPERL, TMPDIR, and USER. # printf( $head_cntrl, "\$ENV{} environment" ); $i = 0; foreach $k ( sort keys %ENV ) { printf( $item_cntrl, ++$i, $k, $ENV{$k} ); } # # Display heading + script 'path' + all argv values. # Note: If script is not saved, expect a 'relative path' <Untitled>. # printf( $head_cntrl, "\$ARG[] arguments" ); printf( $item_cntrl, 0, "\$0", ( defined($0) ? $0 : 'undefined') ); for ( $i = 0; $i <= $#ARGV; $i++ ) { printf( $item_cntrl, $i + 1, "\$ARGV[$i]", $ARGV[$i] ); } __END__ Store this as a droplet and drop some files on it or execute it via toolbox script line to see ARGV in use. -- Regards, Larry F. Allen-Tonar (larryat@cts.com) +1 760/746-6464 (voice) Principal Designer +1 760/746-0766 (FAX, P.O. Box 463072 upon request) Escondido, CA 92046-3072 ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org