Arsenal has asked for the wisdom of the Perl Monks concerning the following question:
This is the offending subroutine (spaced out a bit to make it more readable):Use of uninitialized value at ./gethtml.pl line 16, <my_socket> chunk +1.
while admittedly trivial, I like my code warning free. Is it telling me that the my_socket filehandle isn't initialized ? how can I initialize this? (maybe I need more caffeine.. :P )#/usr/bin/perl -w #gethtml.pl : HTML fetch and return. 28 MAR 2000 rev 1 use Socket; use strict; sub gethtml { my $my_url = $_[0]; my ($my_host, $my_request, $my_html_return) = ''; ($my_host, $my_url) = ($my_url =~ m#(.*?)/(.*)#); $my_request = "GET \/$my_url HTTP/1.0\nAccept: */*\nHost:$my_host\nUse +r-Agent: WebMangle/1.0\n\n"; socket(my_socket, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || retu +rn "Socket Error: $!"; connect(my_socket, sockaddr_in(80,inet_aton($my_host))) || return "Con +nect Error: $!"; send(my_socket, $my_request, 0x0); while(<my_socket>) {$my_html_return = $my_html_return . $_;} #above line is the offending one close my_socket || return "Close Error: $!"; return $my_html_return; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use of unitialized variable?
by athomason (Curate) on Aug 29, 2000 at 00:50 UTC | |
|
Re: Use of unitialized variable?
by ncw (Friar) on Aug 29, 2000 at 00:49 UTC | |
|
Re: Use of unitialized variable?
by Arsenal (Novice) on Aug 29, 2000 at 02:47 UTC | |
by jeffa (Bishop) on Aug 29, 2000 at 05:37 UTC | |
by merlyn (Sage) on Aug 29, 2000 at 05:40 UTC | |
by jeffa (Bishop) on Aug 29, 2000 at 05:52 UTC | |
by merlyn (Sage) on Aug 29, 2000 at 05:55 UTC | |
|