From 96ae24cd5629e2365af17a24116bd87f438e7956 Mon Sep 17 00:00:00 2001 From: Ziad Arafat Date: Tue, 21 Feb 2023 20:41:40 -0700 Subject: [PATCH] Added perl example --- PA002/main_perl.pl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 PA002/main_perl.pl diff --git a/PA002/main_perl.pl b/PA002/main_perl.pl new file mode 100644 index 0000000..87640e8 --- /dev/null +++ b/PA002/main_perl.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +# Function that prints a string when we don't have short-circuit evaluation. +sub print_answer { + print "We DO NOT have short-circuit evaluation!\n"; + return 1; +} + +# Set A to false to see if it skips (0 is false in perl) +my $A = 0; + +# If they are both true print that they are both true +# Else print a string to helpdetermine if w have short circuit evaluation. +if ($A && print_answer()) { + print "Both A and B are true\n"; +} else { + print "If you only see this then we DO have short circuit evaluation\n"; +}