The basename + substitution business doesn't seem to make any sense. The doc says basename quotes any metacharacters in the suffix(es), so that line is looking for a literal dot star at the end of the filename - rather unlikely, even if we have a URL to begin with. The substitution will replace the first repeated sequence of one dot followed by any number of word characters by .url (whose dot needs no quoting since it's on the right hand side of the substitution anyway). That sequence does not necessarily have to be what terminates the string. Taking a ponderous guess at the purpose of the hooha, I bid URI.
And for some more Perlishness, use the diamond operator instead of explicitly opening a file. With lots fewer temporaries:
use strict; use warnings; use URI; use URI::Find; use Config::IniHash; use File::Basename; use File::Spec::Functions qw(catfile); my $dir = 'Links'; unless (-d $dir) { mkdir $dir or die "can't mkdir($dir): $!"; } URI::Find->new(\do {local $/; <> })->find(sub { my($uri, $orig_uri) = @_; WriteINI(catfile($dir, uc URI->new($uri)->host), { DEFAULT => { BASEURL => $uri }, InternetShortcut => { URL => $uri, Modified => 0 }, }); });
Makeshifts last the longest.
In reply to Re^2: url2link
by Aristotle
in thread Url2Link 0.1 GUI/TK
by m_dv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |