in reply to Pattern Matching

Firstly, tell us what you are trying to do! By chopping $', you appear to want to match the "number" section of the file name (i.e., without the preceding 0s). Is this correct? If so, no need - 00001 == 1, you don't need to do a "if ('00001' =~ /0*/)" and use "$' == 1", if you see what I mean!!

Next, try not to use $' unless you have to. Bad practice, when a regex match does just as well. I would suggest something similar to:

$file =~ /^0000(?:0*)(.*)$/; $temp = $1;

.. to achieve your goal. I assume, from your regex, that you only want files with more than three preceding zeros. Mine does that, throws away any other preceding zeros, and passes the rest to $temp. Obviously, if it doesn't match then $temp is undef - don't unlink it :)

Now, you can do the comparison by treating the string as a hex number and then testing it. But, I notice A001 is on the end of both - is this common to all files? If so, you could change the regex above to /^0000(?:0*)(.*)A001$/, and then just treat $temp as a number, no fiddling.

Also, if you at all can, change the (.*) to something more strict - if you know that the file will have a five-digit number, for example, express that in the regex. And comment what the regex is _supposed_ to match!!