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

use encoding "whatever", Filter=>1;

I'd like to be able to specify an encoding with filtering on the perl command line equivalent to the above statement. I can't figure out the Filter part though. What is the proper syntax?

perl -Mencoding=whatever ???? myscript
perl -M'encoding ?????' myscript

-------
Update:

This works:

perl -Mencoding=whatever,Filter,1 myscript

Thanks!

  • Comment on encoding with filtering from command line

Replies are listed 'Best First'.
Re: encoding with filtering from command line
by monkfan (Curate) on Apr 07, 2005 at 14:10 UTC
    In addition to previous answer.
    While in 'use encoding "whatever", Filter => 1;" you really have 'use encoding "whatever","Filter",1;'
    and with -M you specify the argument list specified with commas and without any quotes.

    Check perlrun.
    HtH.

    Regards,
    Edward
Re: encoding with filtering from command line
by cog (Parson) on Apr 07, 2005 at 13:56 UTC
    Without knowing the syntax, I would try perl -Mencoding=whatever,Filter=>1 yourscript

    Doesn't that work?

      Right or wrong, I think some quoting would be necessary, so as to avoid redirection to a file named "1", at least under *nix. In this case, a double quoting should be fine and system-independent:
      perl "-Mencoding=whatever,Filter=>1" yourscript

      Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")

      Don't fool yourself.
Re: encoding with filtering from command line
by Anonymous Monk on Apr 07, 2005 at 15:34 UTC
    Ummm, perl -Mencoding=whatever,Filter,1?