Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Help getting into HTML file.

Reply
Thread Tools

Help getting into HTML file.

 
 
Jim Simpson
Guest
Posts: n/a
 
      06-25-2004
I have the following line of code:

<my $response = $ua->post(whatever)>

The $response which is returned contains HTML code and is now printing on
the DOS screen. How can I get it into an .html file so I can see it on my
computer screen?

Thanks,

Jim


 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      06-25-2004
Jim Simpson wrote:
> I have the following line of code:
>
> <my $response = $ua->post(whatever)>
>
> The $response which is returned contains HTML code and is now
> printing on the DOS screen. How can I get it into an .html file so
> I can see it on my computer screen?


open my $fh, '> myfile.html' or die $!;
print $fh $response -> content;
close $fh;

(untested)

Then view it with your browser.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      06-25-2004
On Fri, 25 Jun 2004, Jim Simpson wrote:

> I have the following line of code:
>
> <my $response = $ua->post(whatever)>
>
> The $response which is returned contains HTML code and is now printing on
> the DOS screen. How can I get it into an .html file so I can see it on my
> computer screen?


What are you asking? Do you want to print the response to your browser?
Do you want to save the result to a new HTML file on your local computer?

I'm going to assume the latter for now. Somewhere along the way, you must
be printing the response. Rather than printing it to standard output (the
default), open a new file for writing, and print to that file instead.

For documentation on how to do this, see:
perldoc -f open
and
perldoc -f print

After reading that documentation and making an attempt, if you still have
problems, let us know.

Paul Lalli
 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      06-25-2004


Jim Simpson wrote:

> I have the following line of code:
>
> <my $response = $ua->post(whatever)>
>
> The $response which is returned contains HTML code and is now printing on
> the DOS screen. How can I get it into an .html file so I can see it on my
> computer screen?



"$ua->get( $url , $field_name => $value, ... )
This method will dispatch a GET request on the given $url. Further
arguments can be given to initialize the headers of the request. These
are given as separate name/value pairs. The return value is a response
object. See the HTTP::Response manpage for a description of the
interface it provides.

Fields names that start with ``:'' are special. These will not
initialize headers of the request but will determine how the response
content is treated. The following special field names are recognized:

:content_file => $filename
:content_cb => \&callback
:read_size_hint => $bytes

If a $filename is provided with the :content_file option, then the
response content will be saved here instead of in the response object. "

"... post... Additional headers and content options are the same as for
the get() method. "

RTFM

--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
 
Reply With Quote
 
Ken Sington
Guest
Posts: n/a
 
      06-26-2004
Jim Simpson wrote:

> I have the following line of code:
>
> <my $response = $ua->post(whatever)>
>
> The $response which is returned contains HTML code and is now printing on
> the DOS screen. How can I get it into an .html file so I can see it on my
> computer screen?
>
> Thanks,
>
> Jim
>
>

perhaps:
perl myprog.pl > mypage.html
in DOS command prompt.
and opening it in your browser.
that may be simpler
 
Reply With Quote
 
Jim Simpson
Guest
Posts: n/a
 
      06-26-2004
Thanks to all who responded - very helpful.

Jim


"Ken Sington" <ken_sington@nospam_abcdefg.com> wrote in message
news:(E-Mail Removed)...
> Jim Simpson wrote:
>
> > I have the following line of code:
> >
> > <my $response = $ua->post(whatever)>
> >
> > The $response which is returned contains HTML code and is now printing

on
> > the DOS screen. How can I get it into an .html file so I can see it on

my
> > computer screen?
> >
> > Thanks,
> >
> > Jim
> >
> >

> perhaps:
> perl myprog.pl > mypage.html
> in DOS command prompt.
> and opening it in your browser.
> that may be simpler



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting an html file from a online html document and converting itback to code. Patrick Rutledge Java 7 01-31-2013 10:11 PM
Getting HTML attributes, and dropping that HTML tag Phillip Gawlowski Ruby 0 04-16-2007 08:59 PM
Load HTML in text strings into HTML parser in Javascript David Virgil Hobbs HTML 2 04-09-2006 01:21 PM
using dreamweaver : how can I insert HTML file into another html file? johnsonholding@yahoo.com HTML 3 01-10-2006 08:06 PM
Getting "To Render" HTML from WebControl into String =?Utf-8?B?RWFybCBUZWlncm9i?= ASP .Net 1 10-22-2004 10:50 PM



Advertisments