From 8e30607364f6abdd2250591c032126e3e68fdaba Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 7 Jan 2020 17:15:57 +0000 Subject: - Added solution by Fabrizio Poggi. --- challenge-042/fabrizio-poggi/perl/ch-2.pl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 challenge-042/fabrizio-poggi/perl/ch-2.pl (limited to 'challenge-042') diff --git a/challenge-042/fabrizio-poggi/perl/ch-2.pl b/challenge-042/fabrizio-poggi/perl/ch-2.pl new file mode 100644 index 0000000000..5e66956b34 --- /dev/null +++ b/challenge-042/fabrizio-poggi/perl/ch-2.pl @@ -0,0 +1,19 @@ +use strict; +use warnings; + +my @chars = ('(', ')'); +my $lenght; +my $rands; +my $countr; +my $countl; + +$lenght = int(rand(15)) + 1; +while ($lenght--){ $rands.= $chars[rand @chars] }; +print "$rands"; +$countr = () = $rands =~ /\(/g; +$countl = () = $rands =~ /\)/g; +if ($countr - $countl == 0) { + print " - OK\n"; + } else { + print " - NOT OK\n"; + } \ No newline at end of file -- cgit