Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re:, combining two strings

by TGI (Parson)
on May 07, 2001 at 23:45 UTC ( #78621=note: print w/replies, xml ) Need Help??

in reply to, combining two strings

You seem to be a bit confused about how all the parts fit together. Your code is really perl pidgin HTML.

The plain old HTML would look something more like:

<FORM METHOD="POST" ACTION="foo.cgi"> <INPUT TYPE="text" NAME="foo"><P> <INPUT TYPE="text" NAME="bar"> <INPUT TYPE="submit"> </FORM>

The HTML could either be generated by a script or reside in a static file somwhere.

Here's some code that prints a form and any results of previous submits. I didn't list a form action, becuase it defaults to the page it reside in.

#!perl use CGI; use strict; my $q = new CGI; print $q->header(), $q->start_html(), $q->h1('Print some input.'), $q->startform(), $q->textfield('foo'), $q->p(), $q->textfield('bar'), $q->submit(), $q->endform(); # Print w/ space print $q->param('foo').' '.$q->param('bar'); # You can't use "" to in +terpolate param(), it's a function call, not a variable. print $q->p(); # Print w/o space print $q->param('foo').$q->param('bar'); print $q->end_html;

TGI says moo

Replies are listed 'Best First'.
Re: Re:, combining two strings
by stuffy (Monk) on May 07, 2001 at 23:54 UTC
    correct, I posted the part of the cgi that created the html that made the form. it also appears that I can use a comma or a period according to the posts that I have received from others


      The comma operator (,) acts as a list separator. When you feed print and bunch of stuff with commas in-between you are saying print this list of things. In a scalar context the comma evaluates the left arg and dumps the value, then it evaluates the right arg and returns the result.print scalar('foo','bar','this'); gets you this

      The period (.) is the string concatenation operator. It combines strings. It also wants its operands in scalar context.

      $a = 'abc'; $d = 'def'; $A = $a.$b; #ie, $A='abcdef' print $A.$a.$b;

      This code prints abcdefabcdef. Here I say print this one thing that you can make by putting these things together.

      Though they seem to do much the same thing when you're printing, they are actually quite different. Watch out for the scalars only aspect of .!

      TGI says moo

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://78621]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2023-09-22 02:14 GMT
Find Nodes?
    Voting Booth?

    No recent polls found