2 Replies - 4473 Views - Last Post: 09 August 2012 - 04:00 AM

#1 rags158  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 04-September 10

Why this code does not work?

Posted 09 August 2012 - 03:19 AM

Hi Everyone

I'm following on-line tutorials and keep running into problems esp when using CGI.pm
I am trying to run what seems like a simple script but like most of these tutorials
that I am following it doesn't work.

Can anybody please take a look at it and tell me where I am going wrong.

Thanks in advance

A.Total Noob.

#!/usr/bin/perl

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

use strict;
use warnings;
use CGI;

my$cgi = new CGI;

print $cgi->redirect('http://www.gmail.com');
print $cgi->start_html,

$cgi->end_html;

exit;



Is This A Good Question/Topic? 0
  • +

Replies To: Why this code does not work?

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2090
  • View blog
  • Posts: 3,185
  • Joined: 21-June 11

Re: Why this code does not work?

Posted 09 August 2012 - 03:34 AM

Generally it would help if you describe in what way your code doesn't work. Just saying "doesn't work", doesn't really tell us anything.

That said, you should not manually print the HTTP header when using CGI.pm - that's what the header and redirect functions are for. Calling the redirect function won't work if you've already printed a header manually (or for that matter using the header function).
Was This Post Helpful? 0
  • +
  • -

#3 rags158  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 04-September 10

Re: Why this code does not work?

Posted 09 August 2012 - 04:00 AM

Thanks for the reply D.I.C Lover

Sorry I should have said that it does not redirect to the said website when run from my server or from the IDE.

I just commented out the header and it worked.

Thanks so much :bigsmile:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1