Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

why won't this work?

Posted on 1999-06-26
2
Medium Priority
?
152 Views
Last Modified: 2013-12-25
heres some cgi ti've written that refuses to work

sub get_number {

 open(NUMBER,"http://username.hypermart.net/data.txt");
 $num=<NUMBER>;
 close(NUMBER);
print "number= $num ";

}

and it refuses to work, it should return the number 1, as that is what is typed in data.txt, but it won't.

thanks.
0
Comment
Question by:pobwest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1834776
open(NUMBER,"http://username.hypermart.net/data.txt") or print "can't open file because $!";

#open is used to open a filename on the local file system,
#if you want to make an HTTP request over the net, you might

use LWP::UserAgent;
use HTTP::Request;
$ua = LWP::UserAgent->new;
$request = HTTP::Request->new(GET => "http://username.hypermart.net/data.txt");
$response = $ua->request($request);
$num = $response->content;
0
 
LVL 8

Accepted Solution

by:
MaDdUCK earned 20 total points
ID: 1834777
your code should work, but you did not specifiy the content type. thus, before writing anything to stdout, print the following:

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

or text/plain for text only.


0

Featured Post

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question