laziness, impatience, and hubris PerlMonks

### Does Perl have if(isset?

by beanscake (Acolyte)
 on Jan 24, 2014 at 20:13 UTC Need Help??
beanscake has asked for the wisdom of the Perl Monks concerning the following question:

Please i need a solution for this, i want to use (PERL) to process a form instead of PHP, now my only problem is converting this LINE to (PERL) SCRIPT.
<?php

if(isset($_POST['comment']))$comment  = $_POST['comment']; ?> [download] Thank you. Replies are listed 'Best First'. Re: Does Perl have if(isset? by Corion (Pope) on Jan 24, 2014 at 20:29 UTC According to the PHP documentation on isset(), the function returns true if the variable has a defined value. This would be equivalent to the defined function of Perl: $comment= param('comment')
if defined param('comment');
[download]

I think the $_POST hash in PHP is populated by HTTP POST parameters - you would have to check that too. Re: Does Perl have if(isset? by Your Mother (Chancellor) on Jan 24, 2014 at 20:21 UTC You should put your code in <code> tags. And without knowing a little Perl this is unlikely to get you far but this is roughly equivalent. I didn't use the if block because it is unperly (to me) when there is no real else. use strict; # DO NOT LEAVE OUT. use warnings; # What did I just say?! use CGI ":standard"; my$comment;
$comment = param("comment") if request_method() eq "POST"; # Note,$comment could be undefined/uninitialized here
# but this is similar to your logical block.
[download]
Re: Does Perl have if(isset?
by karlgoethebier (Parson) on Jan 24, 2014 at 21:01 UTC

I couldn't do otherwise:

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Create A New User
Node Status?
node history
Node Type: perlquestion [id://1071990]
Approved by Corion
Front-paged by Sinistral
help
Chatterbox?
 [Corion]: Do you want to launch a script and keep the command prompt/console window open? [Corion]: Do you want to wait for a key press before closing the window? [LanX]: I want the command line in the history [tye]: -Mouse [Corion]: Option a) would mean launching cmd.exe /k c:\path\to\ batchfile- launching-perl- script.cmd. Option b) would be to add pause as the last line of said batch file. [LanX]: First day after holidays ... and already stressed by the fact that colleagues changed stuff without communication ... apparently I'm the only one trying to fight entropy [Corion]: LanX: The command is always in the history if you typed it in before. If you didn't type the command into the command line, it will not be there. I think there is doskey which can stuff command lines into the history LanX damns the cult of CB ;-) LanX WTF WTF WTF [LanX]: please forget my last 3 posts

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2017-03-27 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should Pluto Get Its Planethood Back?

Results (320 votes). Check out past polls.