perlmoth has asked for the wisdom of the Perl Monks concerning the following question:

When I run the following code:
#!d:/perl/bin -w use strict; use diagnostics; use File::Find; @ARGV = (); find sub { push @ARGV, $File::Find::name if (/\.pl$/ and (-M < 1.0)); }, "d:/perl"; $,="\n"; print @ARGV;
I get this:

Warning: Use of "-M" without parens is ambiguous at ft.pl line 11. Unterminated <> operator at ft.pl line 9 (#1) (F) The lexer saw a left angle bracket in a place where it was expecting a term, so it's looking for the corresponding right angle bracket, and not finding it. Chances are you left some needed parentheses out earlier in the line, and you really meant a "less than". Uncaught exception from user code: Unterminated <> operator at ft.pl line 9.

After a lot of trial and error, I found that the only way I could get it to work was by changing the file test part to (1.0 > -M).
Is there a way to write the above code so that I can keep the (-m < 1.0) part?

Replies are listed 'Best First'.
Re: -M file test problem
by count0 (Friar) on Jan 17, 2002 at 01:44 UTC
    You should explicitly give the file test operator ('-M') something to operate on.
    (-M ($_) < 1.0)
Re: -M file test problem
by FoxtrotUniform (Prior) on Jan 17, 2002 at 01:46 UTC

    Mention $_ explicitly:

    (-M $_ < 1.0)

    or perhaps parenthesize to avoid ambiguity, like the warning suggests:

    ((-M) < 1.0)
    --
    :wq