From 9bbe9b4a8f964510382bf78ccca33c65c3252f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Fri, 23 Feb 2024 18:21:29 +0100 Subject: [PATCH] Save flags into variables. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicolás Ortega Froysa --- pacundo.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pacundo.pl b/pacundo.pl index e828d39..192f7c2 100755 --- a/pacundo.pl +++ b/pacundo.pl @@ -30,6 +30,9 @@ use Getopt::Std; my $VERSION = "1.0"; my $PROG_NAME = "pacundo"; +my $r_flag = 0; +my $dry_run = 0; + sub print_version { print("$PROG_NAME v$VERSION\n"); } @@ -50,7 +53,7 @@ OPTIONS: -v Print program version\n"); } -getopts("irvh", \my %opts); +getopts("irdvh", \my %opts); if ($opts{'v'}) { &print_version(); @@ -58,4 +61,11 @@ if ($opts{'v'}) { } elsif ($opts{'h'}) { &print_help(); exit 0; +} elsif ($opts{'r'} && $opts{'i'}) { + print("Improper usage. -r and -i cannot be used at the same time.\n"); + print("Use -h for help information.\n"); + exit 1; } + +$r_flag = 1 if ($opts{'r'}); +$dry_run = 1 if ($opts{'d'});