You can read Dave Roth's articles published in the Windows IT Pro magazine (formally known as Windows .NET Magazine) that use Perl to accomplish interesting tasks.
Our Administrator's Handbook book is here and not a moment too soon! Win32 Perl Scripting: Administrator's Handbook
Available at Amazon.com
The 2nd edition of our Win32 Perl Programming: Standard Extensions is available.
Check out our recommended reading list.
Back to the Script Repository
For example, I wrote a script called FindStr.pl. I call it by just using "FindStr" but this collides with the command line FindStr.exe command. By running this tool as:
perl findinpath.pl findstr*
I get the following output:
1) 'C:\WINDOWS\system32\findstr.exe' 2) 'c:\tools\FINDSTR.PL'
This way I know exactly where the two colliding named files are.
You can download the script here.
# FindInPath.pl # ------------- # Simple program that looks for a file in the path # Syntax: # perl FindInPath.pl <file name> # # Examples: # perl FindInPath.pl cmd.exe # perl FindInPath.pl cmd* # # 2002.01.20 rothd@roth.net # # Permission is granted to redistribute and modify this code as long as # the below copyright is included. # # Copyright © 2002 by Dave Roth # Courtesty of Roth Consulting # http://www.roth.net/ use File::DosGlob qw( glob ); if( 0 == scalar @ARGV ) { print "$0 file [file2 [file3 [...]]]"; exit; } @Dirs = split( ";", $ENV{PATH} ); foreach my $File ( @ARGV ) { foreach my $Dir ( @Dirs ) { my $Path = "$Dir\\$File"; # Very pathetic hack to handle spaces in a path. Since # the default glob() functions fails with embedded spaces we # have to rely on File::DosGlob which forces us to do this crap. my $DosGlobPath = $Path; $DosGlobPath =~ s#\\#/#g; $DosGlobPath =~ s/(\s)/\\$1/g; foreach my $Location ( glob( $DosGlobPath ) ) { $Location =~ s#/#\\#g; printf( " % 3d) '%s'\n", ++$iCount, $Location ); } } }
Note: Neither Roth Consulting nor its affiliates are responsible for problems resulting from the misuse, modification or execution of any of the scripts on this web site. It is best that the the user read over the script carefully to insure that the code is not harmful to his environment.
This page has been viewed 1 times.