|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
#!/usr/bin/perl
# (find-angg ".zshrc" "psne")
# This Perl script is the soul of the "psne" shell function and its
# friends...
# Examples of usage:
#
# _psne '$vars' http://foo/bar extra1 extra2
# _psne '$vars' http:/foo/bar extra1 extra2
# _psne 'mkdir -p $dir\ncd $dir\nwget @args $url\n' http://foo/bar xtra1 xtra2
#
# (find-man "1 perlfunc" "shift ARRAY")
# (find-man "1 perlre" "legibility")
# (find-man "1 perldata")
# (find-man "1 perldata" "assign to undef")
# (find-man "1 perlop")
# (find-man "1 perlfunc" "eval EXPR")
($format, $url, @args) = @ARGV;
$_ = $url;
(($prot, $usrpasswd, $site, $port, $path, $fname, $query) =
m%^(ftp|http|file)://([^/@]*@)?
([^@/:]*)(:[0-9]*)?/([^?]*/|)([^/?]*)(\?.*)?$
%x) || die "\"$url\": not an url\n";
$dir = "$ENV{S}/$prot/$site/$path";
$urlfile = "$fname$query";
$vars = " \$format = \"$format\"
\$url = \"$url\"
\@args = @args
\$prot = \"$prot\"
\$usrpasswd = \"$usrpasswd\"
\$site = \"$site\"
\$port = \"$port\"
\$path = \"$path\"
\$fname = \"$fname\"
\$query = \"$query\"
\$dir = \"$dir\"
\$urlfile = \"$urlfile\"
";
print(eval("\"$format\""));