Bonjour a tous,
Une petite question pour savoir s'il existait un module pour recuperer les parametres d'entree lors d'un appel a un script perl.
J'ai un script qui prend en parametre :
Pour les deux premiers parametres optionnels je peux les retrouver car je sais qu'il va y avoir par la suite un autre parametre, je peux faire un shift et tester la valeur du parametre:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 [] optionnel <> mandatory - <-opt1> - <-opt2> - [-debug] - [-opt3] - <input_file> - [-opt4]
Pour le dernier je ne vois pas comment faire, puis en voyent tout ces if je me suis dit qu'il existait peut etre un module ou une methode pour récupérer plus simplement ces parametres.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 my $param_debug = 0; my $param_event = 0; my $param_gtk = 0; # test first parameter (if it is bad -> die) my $param_type = shift or usage() and die; if( ($param_type ne "-shm") && ($param_type ne "-reg") && ($param_type ne "-SHM") && ($param_type ne "-REG")) { usage() and die; } # test second parameter in param_input parameter my $param_input = shift or usage() and die; # if = debug set debug variable if( ($param_input eq "-debug") || ($param_input eq "-DEBUG") ){ $param_debug = 1; # test third parameter in param_input parameter $param_input = shift or usage() and die; # if = event set the event variable if( ($param_input eq "-event") || ($param_input eq "-EVENT") ){ $param_event = 1; $param_input = shift or usage() and die; } } # if = event set event variable elsif( ($param_input eq "-event") || ($param_input eq "-EVENT") ){ $param_event = 1; $param_input = shift or usage() and die; if( ($param_input eq "-debug") || ($param_input eq "-DEBUG") ){ $param_debug = 1; $param_input = shift or usage() and die; } } # if != event or debug -> contains the input path file my $param_gtk = shift or ?????;
Merci d'avance
Partager