Gossamer Forum
Home : General : Perl Programming :

please help me...

Quote Reply
please help me...
I would like to bugfix a program, but therefore the following line has to eddited so that if $in->param('nh') equals to 1 my $page is 0 !

my $page = ($in->param('nh') * 10) | | 0;

Can anyone help me out?
Quote Reply
Re: please help me... In reply to
How about:

($in->param('nh') == 1) and ($page = 0);

Or if you want to set $page to something else if nh is not 1:

($in->param('nh') == 1) ? ($page = 0) : ($page = 5);

Hope that helps,

Alex
Quote Reply
Re: please help me... In reply to
Alex,

now everything except 1 is 0,

but it must be like this:

in{page} ---> $page

0 -- 0
1 -- 0
2 -- 2
3 -- 3
4 -- 4
..and do on!

[This message has been edited by chrishintz (edited January 13, 1999).]
Quote Reply
Re: please help me... In reply to
Umm, not sure of the context of the program, but shouldn't this work?

($in->param('nh') == 1) ? ($page = 0) : ($page = $in->param('nh'));

What this should do is.. if your $in is 0, $page will still be 0.. if it is 1, it will set $page to 0.. if it is anything else, it will stay the same. This is the same as saying:

if ($in->param('nh') == 1) {
$page = 0;
} else {
$page = $in->param('nh');
}



------------------
Fred Hirsch
Web Consultant & Programmer
Quote Reply
Re: please help me... In reply to
 
Thanks a lot Fred,

but is this the way to set 0 to default ?

my $page = 0;
if ($in->param('nh') == 1) {
$page = 0;
} else {
$page = $in->param('nh');
}