in reply to Re: How to open the file exists in web link
in thread How to open the file exists in web link

Perl does not allow you to directly access a file over the HTTP-protocol through a filehandle

Perl has a pluggable IO system, so that's not really true. For example, it allows the following:

open(my $fh, '<:lwp', 'http://...')

The catch is the module providing the functionality might not exist yet.

Replies are listed 'Best First'.
Re^3: How to open the file exists in web link
by CountZero (Bishop) on Feb 09, 2010 at 07:14 UTC
    Indeed, I should have said "Without adding or writing modules, Perl ...".

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      No, Perl allows it whether you write the module or not. At issue is not what Perl allows, but what Perl provides. Perl does not provide a means of accessing a file through a file handle. Well, not directly. It's pretty darn simple to do, though.

      my $response = $ua->get($url); $response->is_success() or die("Can't get $url: ", $response->status_line(), "\n"); my $content = $response->decoded_content( charset => 'none' ); open(my $fh, '<', \$content) or die("Can't open scalar: $!\n");