c:\> ncopy \foo\bar\*.txt \-1\0N.dat\-2\file.datwhich copies
For Windows, you should probably use File::DosGlob (which is core) or Win32::Wildcard.
It's comparable with doing:
mysub ("foo$BAR");
in Perl. If you want mysub to deal with the interpolation, you shouldn't change mysub to prevent Perl doing the interpolation. Instead, you change the quotes, or escape the special symbols.
It's the same with a Unix shell. If you want your program to do the globbing, prevent the shell from expanding the *. Use quotes, or a backslash.
You might want to look at my module File::Wildcard, which can use regexp captures to derive the new filename. If you want to give this a go, please give me feedback on usability, documentation, etc. and I'm willing to help if you get stuck.
--
Oh Lord, wont you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, wont you burn me a Knoppix CD ?
(Missquoting Janis Joplin)
Now, while this might be against the philosophy of open source/Perl/CPAN/etc, you might want to ask yourself if it's worth the time and effort.
--
tbone1, YAPS (Yet Another Perl Schlub)
And remember, if he succeeds, so what.
- Chick McGee
--
[ e d @ h a l l e y . c c ]
There's no harm in calling glob() on a filename with no wildcards.Indeed, there isn't.
Just glob all but the last argument.No, that would be wrong. Just because globbing on a filename without wildcars is ok doesn't mean that the result of a glob gives you a fixed point.
Suppose for instance you have a utility that removes those files that are given as argument (like rm does). Let's call it remove. But, unlike rm, it globs its arguments - even when working in an environment that globs. Suppose you have a directory that contains the following files:
thesis_worked_on_for_the_past_four_years
naked_perl_chicks.tar.gz
parrot_1.0.0.tar.gz
[a-z]*
And you want to remove that pesky file named [a-z]*. You call your program like this:
remove *a-z*
If you had called rm, the first three files would still be there, with the pesky file removed. However, remove, globbing its arguments, will remove the first three files, leaving the pesky file where it is.
--
[ e d @ h a l l e y . c c ]
perlmonks.org content © perlmonks.org and DrHyde, halley, holli, kalle, Perl Mouse, rinceWind, tbone1
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03