Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl: how can i pass list to script?

i need to pass list to my script how can i do it?

for example i have script: flow.pl i need to pass to it list of fubs :

fub1, fub2, fub3 

and path to database1 =

path1 

and path to database2 =

path2 

and how can i get this parameters?

 (through $ARGV[i]?)

if i do:

flow.pl fub1,fub2,fub3 path1 path2

and in the code:

$listoffubs = $ARGV[0]
$path1 = $ARGV[1]
$path2 = $ARGV[2]

list of fubs get name of fubs like one word.

like image 316
user782642 Avatar asked Dec 13 '22 06:12

user782642


1 Answers

Having lists of positional arguments is ok as long as the lists are short and simple. Once you get into a larger number of arguments or you have arguments with an internal structure, then you probably want to look at named arguments.

In this case, I think I'd be looking at using GetOpt::Long to implement named arguments.

like image 54
Dave Cross Avatar answered Jan 03 '23 12:01

Dave Cross