>>>>> "Josef" == Josef E Galea <[EMAIL PROTECTED]> writes:

    Josef> How can I pass parameters (eg: a file name) to a Perl script

If you mean via the console, parameters (or 'arguments') magically end
up in the @ARGV array, which you can access inside your script.  An
example of this would be (from the top of my head):
   
   #!/usr/bin/perl -w
   use strict;

   if (@ARGV != 2) {               # if we don't have two arguments
      print 'Usage: perl $0 <arg1> <arg2>\n';
      exit;
   }

   $argument1 = $ARGV[0];          # note that arrays are zero-indexed
   $argument2 = $ARGV[1];

   # make sure that $argument{1,2} don't contain special chars
   $argument1 =~ s/[^A-Za-z0-9:\.]//;
   $argument2 =~ s/[^A-Za-z0-9:\.]//; 

   do_something_with($argument1, $argument2);

Hope this helps,

- Chris.
-- 
$a="printf.net"; Chris Ball | chris@void.$a | www.$a | finger: chris@$a
As to luck, there's the old miners' proverb: Gold is where you find it.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to