2

I've got a client-side script I'm making that communicates with GNU-FTP. I want to be able to send it a custom argument on the command line, so I've created an argument --ftp-args

This is what it looks like

GetOptions(
  .. redacted stuff..
  "ftp-args=s%" => \$FTP_ARGS
) or die("Error in command line arguments\n");

However, whenever I try to call it I get an error,

$ ./script/dm-ftp360 --ftp-args="-E"
Option ftp-args, key "-E", requires a value
Error in command line arguments

Is it possible to get around this, and make this possible?

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468

1 Answers1

2

You've specified s% - defining an option that specifies hash entries. That implies a form key=value for each argument to the option. But you've only specified -E. The error message is about the missing =value part, not the leading -.

Perhaps use s@ instead to ingest a set of simple options? Or give an empty value using "-E=" if you need to separate the keys and values before passing them to ftp.

martin clayton
  • 76,436
  • 32
  • 213
  • 198
  • I didn't want the '%' at all simple `=s`. Damn, so much for copy-and-pasting code I've used a thousand times without looking it up. – Evan Carroll Jun 13 '13 at 23:18
  • @EvanCarroll I keep a skeleton script that has all the boilerplate code, including GetOpt::Long, so I don't have to remember. – kjprice Jun 13 '13 at 23:30