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;
In reply to Use of unitialized variable? by Arsenal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |