Welcome to WebmasterWorld Guest from 50.19.190.144

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Is this valid code?

     
6:31 pm on Mar 11, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 17, 2003
posts: 115
votes: 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!

7:03 pm on Mar 11, 2008 (gmt 0)

Preferred Member

10+ Year Member

joined:Jan 5, 2006
posts:536
votes: 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.

7:19 pm on Mar 11, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 17, 2003
posts: 115
votes: 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.

8:15 pm on Mar 11, 2008 (gmt 0)

Preferred Member

10+ Year Member

joined:Jan 5, 2006
posts:536
votes: 0


Very good.
11:55 pm on Mar 11, 2008 (gmt 0)

Administrator

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

joined:Aug 10, 2004
posts:10542
votes: 8


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

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

7:45 pm on Mar 14, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 17, 2003
posts:115
votes: 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.

6:54 am on Mar 15, 2008 (gmt 0)

Administrator

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

joined:Aug 10, 2004
posts:10542
votes: 8


why not install it yourself in a local library and refer to it with a "use lib" statement in your script?
12:54 pm on Mar 16, 2008 (gmt 0)

Full Member

10+ Year Member

joined:July 23, 2003
posts:227
votes: 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]

1:45 pm on Mar 17, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 17, 2003
posts: 115
votes: 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.

11:09 pm on Mar 17, 2008 (gmt 0)

Administrator

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

joined:Aug 10, 2004
posts:10542
votes: 8


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.
1:30 pm on Mar 18, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 17, 2003
posts:115
votes: 0


Thanks for the info phranque. It is much appreciated.
10:31 pm on May 8, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:May 8, 2008
posts:74
votes: 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]

1:33 pm on May 9, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 17, 2003
posts: 115
votes: 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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members