in reply to Please help me
Hi
To expand a little on what jwkrahn said:
Your foreach loop probably is executing, but because @INFFiles = `dir /b $filespec`; doesn't do what you think, it's only executing once. Backticks (`...`) return a string with the output of the command. If you wanted the filenames in a list, you'd have to split up the string yourself.Edit: wrong diagnosis. But I would still use a built-in way such as glob or readdir, rather than invoke an external command.
Perl already has ways to get a list of filenames. Perhaps the simplest replacement would be:
@INFFiles = glob($filespec);
If you use that, you won't need to chomp or prepend $path in the foreach loop.
Regarding $VersionNumber =~ s/^\d+\.\d+\.\d+\.\d+//g;, I'm not sure if this is a mistake or not, since it will remove everything except digits (0-9), '+' and '.':
$ perl -ple 's/[^\d+\.\d+\.\d+\.\d+]//g' This has no numbers, dot or plus This has 1 dot. 1. This has 1234567890 + . 1234567890+.
It can be simplified to:
$ perl -ple 's/[^.\d+]//g' This has no numbers, dot or plus This has 1 dot. 1. This has 1234567890 + . 1234567890+.
Since it is being used to clean up a version number, I think it is probably meant to be s/[^0-9.]//g - remove everything except digits and dot. Since you've already stripped everything out of version number, the next two lines (strip \x0d and chomp) seem unnecessary.
Finally, use strict; and use warnings; at the top of your script ( if you don't already ). And don't use function prototypes ( the $$$ in sub FileVersion($$$) ) - they don't do what you want.
FalseVinylShrub
Disclaimer: Please review and test code, and use at your own risk... If I answer a question, I would like to hear if and how you solved your problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Please help me
by Jenda (Abbot) on Feb 12, 2010 at 10:15 UTC | |
by FalseVinylShrub (Chaplain) on Feb 12, 2010 at 10:31 UTC | |
|
Re^2: Please help me
by mtrasp (Acolyte) on Feb 18, 2010 at 08:15 UTC | |
by FalseVinylShrub (Chaplain) on Feb 18, 2010 at 12:19 UTC |