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.


In reply to Re: Please help me by FalseVinylShrub
in thread Please help me by mtrasp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.