homepage Welcome to WebmasterWorld Guest from 54.237.213.31
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Is this valid code?
TheSeoGuy

10+ Year Member



 
Msg#: 3597711 posted 6:31 pm on Mar 11, 2008 (gmt 0)

We recently migrated a site for one of our clients to a Linux hosting environment.

We are not familiar with perl or cgi, but after much finagling, we have most of the site up and running. The site uses a header.cgi file which is included at the top of almost every page. At the very top of this file are the following two lines of code.

print "Content-type: text/html\n\n";
print q^

I've noticed that in all the pages utilizing this header, the text Content-type: text/html displays on the actual web page. This is not correct as it should be html. Also, I wasn't sure what the print q^ did.

Is there something wrong in the two lines of code that would cause the file to print out html as text (Content-type: text/html)?

And what is the function of the print q^?

Thanks in advanced!

 

perl_diver

5+ Year Member



 
Msg#: 3597711 posted 7:03 pm on Mar 11, 2008 (gmt 0)

The first line is a valid http header, but if you see it displayed as text in the browser that means another http header has already been printed. The second line is not valid as-is. But it could be that the author as deliberately coded the script in an unusual manner and the "q^" line is just the beginning of some more code that gets added to it and becomes valid code. "q" is the single-quote operator and "^" would be the delimiter, in total it would look like this:

print q^some stuff to print^;

although using the "^" character as a string delimiter is also unusual it is valid if someone wanted to do that.

TheSeoGuy

10+ Year Member



 
Msg#: 3597711 posted 7:19 pm on Mar 11, 2008 (gmt 0)

Thanks for the reply and the info perl_diver.

I believe you are correct in your assumption.

The line directly after print q^ is standard html...
<table border="0"...

If I go to the bottom of the file, it ends with
</table>^;

Note the closing ^ "closing" carrot.

I will try to find out where else the http header is getting written out...

Thanks again.

perl_diver

5+ Year Member



 
Msg#: 3597711 posted 8:15 pm on Mar 11, 2008 (gmt 0)

Very good.

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 3597711 posted 11:55 pm on Mar 11, 2008 (gmt 0)

most likely the including script or the server is providing the header.

[edited by: phranque at 2:44 am (utc) on Mar. 17, 2008]

TheSeoGuy

10+ Year Member



 
Msg#: 3597711 posted 7:45 pm on Mar 14, 2008 (gmt 0)

Thanks for the reply phranque. We were able to get the main site running, but now we are running into another issue. Part of the site relies on a module called Crypt::CBC. This module is not installed on our host server by default nor will they install it for us. Is there another "more standard" module that we might be able to use in place of the Crypt::CBC module?

Thanks.

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 3597711 posted 6:54 am on Mar 15, 2008 (gmt 0)

why not install it yourself in a local library and refer to it with a "use lib" statement in your script?

wruppert

10+ Year Member



 
Msg#: 3597711 posted 12:54 pm on Mar 16, 2008 (gmt 0)

You can install Crypt::CBC from CPAN, it is a pure Perl module, into a local directory. You can modify the PERL5LIB environment variable to include the local library.

There was a related discussion at [webmasterworld.com...] .

[edited by: phranque at 2:50 am (utc) on Mar. 17, 2008]
[edit reason] fixed the link [/edit]

TheSeoGuy

10+ Year Member



 
Msg#: 3597711 posted 1:45 pm on Mar 17, 2008 (gmt 0)

phranque & wruppert,

Thank you both for your replies. Please excuse my inexperience with Perl and Perl modules. I see in the code the lib path that references the un-installed perl module.

If I understand you correctly, I can just upload the .pm file to the directory of where the lib path is already pointing and it is "installed"?

Do I only need to upload the .pm file? When I unzip the module, it consists of numerous files and directories.

Thanks again.

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 3597711 posted 11:09 pm on Mar 17, 2008 (gmt 0)

for simpler modules, the zipped file contains the .pm file and the make files and usually a readme file.
try creating a subdirectory in your lib path directory:
mkdir /(lib_path)/Crypt
and then copy CBC.pm to that subdirectory.
if the package has more operational pieces/parts than just the one .pm, it's usually easier to install it with make.

TheSeoGuy

10+ Year Member



 
Msg#: 3597711 posted 1:30 pm on Mar 18, 2008 (gmt 0)

Thanks for the info phranque. It is much appreciated.

chorny

5+ Year Member



 
Msg#: 3597711 posted 10:31 pm on May 8, 2008 (gmt 0)

TheSeoGuy, package manager for your OS may contain ready package for Crypt::CBC. Or do
cpan Crypt::CBC
from command prompt.

[edited by: phranque at 2:47 am (utc) on May 9, 2008]
[edit reason] No urls, please. See TOS [webmasterworld.com] [/edit]

TheSeoGuy

10+ Year Member



 
Msg#: 3597711 posted 1:33 pm on May 9, 2008 (gmt 0)

Thanks for your reply chorny.

Because we were limited in access due to the hosting environment restrictions, we ended up removing the few lines of code that referenced the module in question and were able to get the site to function properly.

Thanks again.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved