> -----Original Message----- > From: suresh kumar [mailto:[EMAIL PROTECTED] > Sent: 24 November 2008 10:41 > To: beginners@perl.org; [EMAIL PROTECTED]; Amit Saxena > Subject: Regarding conditional statement > > Hi, > > Here is the sample code: > > sub a { > print "i am a\n"; > return 0; > } > > sub b { > print "i am b\n"; > return 1; > } > > if (a() && b()) { > print "yes\n"; > } else { > print "no\n"; > } > > > > I want both the subroutine to be executed, and then i want print some > statements depending upon both the results. > here if a() returns "0" then b() was not getting executed. > > is there any other way to do this check?
This siple change has the effect you want I think. #! /usr/bin/perl use warnings; use strict ; use Data::Dumper; sub a { print "i am a\n"; return 1; } sub b { print "i am b\n"; return 1; } my $aresult = a(); my $bresult = b(); if ($aresult && $bresult) { print "yes\n"; } else { print "no\n"; } Stu Information in this email including any attachments may be privileged, confidential and is intended exclusively for the addressee. The views expressed may not be official policy, but the personal views of the originator. If you have received it in error, please notify the sender by return e-mail and delete it from your system. You should not reproduce, distribute, store, retransmit, use or disclose its contents to anyone. Please note we reserve the right to monitor all e-mail communication through our internal and external networks. SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and are used under licence. British Sky Broadcasting Limited (Registration No. 2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited (Registration No. 2340150) are direct or indirect subsidiaries of British Sky Broadcasting Group plc (Registration No. 2247735). All of the companies mentioned in this paragraph are incorporated in England and Wales and share the same registered office at Grant Way, Isleworth, Middlesex TW7 5QD. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/