FAQ

On 2/8/10, 7 wrote:
On 2/8/10, Chris Coggins wrote:
What is the proper syntax for a comparison at the end of a subroutine to
stop the script if a certain variable is "0" or ''?

sub routine{
(get data and process it)
if $varA = '' || $varA = "0" {
(stop script, print error message to user)
}
else{
(continue with script)
}
if ($varA = '' || $varA = "0") { #space after 'if'
#code
}
else { #space after 'else'
#code
}
Rather:

if ($varA eq '' || $varA eq "0") { #space after 'if'
#code
}
else { #space after 'else'
#code
}

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 18 | next ›
Discussion Overview
groupbeginners @
categoriesperl
postedFeb 9, '10 at 12:39a
activeFeb 9, '10 at 7:24a
posts18
users4
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase