Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capturing the path to a file(s) 2

Status
Not open for further replies.

andyv12

IS-IT--Management
Dec 11, 2004
1
CA
If I invoke a Perl script that takes a pathname (with wildcard) as its only argument, how do I capture the path without the wildcard?

Ex:

perlscript.pl /Users/andyv/ps/*

How do I capture the full path minus the wildcard into a variable (just /Users/andyv/ps/)??

Thanks!

AndyV
 
This will remove the *

Code:
#!/usr/bin/perl
print "Content-type: text/html\n\n";

$var1 = "perlscript.pl /Users/andyv/ps/*";

$var1=~s/\*//;

print $var1;
 
for my information, how do you get the '*' into your script?
All the shells I am familiar with would replace the * with everything under /Users/andyv/ps (unless /Users/andyv/ps did not exist )
 
Good point, arn0ld.
Code:
use File::Basename;

my $dirname = dirname($ARGV[0]);
print "$dirname\n";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top