Skip to main content
edited tags; edited title; edited body
Source Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

Perl: Good solution to Avoiding "warning: Use of uninitialized value" when fetching an integer CGI parameter

I amwas using this code to fetch a CGI parameter:

$page = int(param('page'));

This sometimes results in:

warning: Use of uninitialized value in int

Is this a good solution to resolve this warning, or is better and more succinct code available?

if (defined param('page')) {
    $param_page = int(param('page'));
} else {
    $param_page = 1;
}

Perl: Good solution to "warning: Use of uninitialized value"

I am using this code:

$page = int(param('page'));

This sometimes results in:

warning: Use of uninitialized value in int

Is this a good solution to resolve this warning, or is better and more succinct code available?

if (defined param('page')) {
    $param_page = int(param('page'));
} else {
    $param_page = 1;
}

Avoiding "warning: Use of uninitialized value" when fetching an integer CGI parameter

I was using this code to fetch a CGI parameter:

$page = int(param('page'));

This sometimes results in:

warning: Use of uninitialized value in int

Is this a good solution to resolve this warning, or is better and more succinct code available?

if (defined param('page')) {
    $param_page = int(param('page'));
} else {
    $param_page = 1;
}
Source Link

Perl: Good solution to "warning: Use of uninitialized value"

I am using this code:

$page = int(param('page'));

This sometimes results in:

warning: Use of uninitialized value in int

Is this a good solution to resolve this warning, or is better and more succinct code available?

if (defined param('page')) {
    $param_page = int(param('page'));
} else {
    $param_page = 1;
}