baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
my problem is that i'm trying to do something that is not meant to be done. i,m using Getopt::Long module in my script and need to pass a string into the script from a shell/cmd , something like:
function(key => './path')-> is a string that i'm trying to pass./prog.pl -o function(key => './path')
and program(prog.pl) looks like:
the problem is, if i do not put an option in ' ' or " " to define it as a string of some sort, i get an error:#!/usr/bin/perl use strict; use Getopt::Long; my $option; GetOptions('o=s' =>\$option); eval($option); sub function { my %arg = @_; ... }
but if my variable or a key is in the quotes like in the example then it is an error for me again if i put ' ' or " ". how to override this problem does anyone have any idea.-bash: syntax error near unexpected token `('
thnx
Update:
i neglected to mention:
i know that if a user uses " " around a string "function(key => './path')" it will work, but the user shouldn't care about anything except the way to properly write its string. and what if a user writes it like: "function(key => "./path")"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getopt::Long problem
by moritz (Cardinal) on Jun 24, 2009 at 20:55 UTC | |
|
Re: Getopt::Long problem
by zwon (Abbot) on Jun 24, 2009 at 21:33 UTC | |
|
Re: Getopt::Long problem
by graff (Chancellor) on Jun 25, 2009 at 01:36 UTC |