final Re: getstore and comments

2005-08-22 Thread Adriano Allora

hi,

for infos on comments and over all for advices about getstore.

Now I did what I wanted (using get() instead of getstore(), and 
localhost, and storing the result in a variable).


(The ovid cgi-course seems very well.)

Thank you all,

alladr



|^|_|^|_|^|  |^|_|^|_|^|
 || ||
 || ||
 ||*\_/*\_/*\_/*\_/*\_/* ||
 |   |
 |   |
 |   |
 | http://www.e-allora.net|
 |   |
 |   |
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: getstore and comments

2005-08-19 Thread John W. Krahn
Adriano Allora wrote:
> hi to all,

Hello,

> Some questions:
> 1) how can I write multine comments? something like /** ... **/?

Install this module:

http://search.cpan.org/~kane/Acme-Comment-1.02/


> 2) the following script doesn't find the page requested in getstore
> (baolian.local = 127.0.0.1). Why?

.local is not a valid TLD (AFAIK) and baolian.local is not equal to 127.0.0.1.
 You need to use localhost like:

$status = getstore('http://localhost/~adrianoallora/index.html', $homepage);


> 3) $homepage must be a real page/file or I can use it like a normal
> variable or a filehandle to read with whlie(<>)?

I don't understand, sorry.



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: getstore and comments

2005-08-19 Thread Ovid
Hi Adriano,

The previous emails answered your questions, but may I strongly
recommend that you use strict, warnings, and taint checking?  These
three things, though they seem annoying at first, will save you much
grief in the long run.

For example, in the script you provided, you had the following two
lines:

  $query = CGI::new();
  print $query->header();

With most object-oriented code, those would have failed.  However, both
strict and warnings would have made it more likely that such a failure
would have been caught.

In the case of the CGI.pm module, the only reason this works is because
CGI.pm does a lot of work behind the scenes to let you use this module
in both a functional and object-oriented fashion.  It's only a
side-effect of this behavior which allowed your syntax to work.  The
proper syntax would be (assuming we're using strict and declaring our
variables):

  my $query = CGI->new;
  print $query->header;

Just to illustrate the problem, consider the following:

  #!/usr/bin/perl
  use warnings;
  use strict;

  {
  package Foo;
  sub new { bless {} => shift }
  }

  use Data::Dumper;
  print Dumper Foo::new; # Oops!  Should be Foo->new;

If you run that, because you have warnings enabled, you get the
following output:

  Use of uninitialized value in bless at test.pl line 8.
  Explicit blessing to '' (assuming package main) at test.pl line 8.
  $VAR1 = bless( {}, 'main' );

Clearly, blessing the object into package main is not what was
intended.

You may wish to read my CGI Course at
http://users.easystreet.com/ovid/cgi_course/

I cover similar issues and I also discuss the values of taint checking.

Hope this helps!

Cheers,
Ovid

-- 
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: getstore and comments

2005-08-19 Thread Chris Devers
On Fri, 19 Aug 2005, Adriano Allora wrote:

> Some questions:
> 1) how can I write multine comments? something like /** ... **/?

Method one, simple comments:

# Here is a comment
# that spans across
# several lines

Method two, POD:

=pod
Here is a comment
that spans across
several lines
=cut

Note that these aren't quite equivalent though. The first way is 
simpler, and it's how most Perl programmers seem to handle brief (or 
maybe not so brief) notes on how the program works. The second way is 
intended as documentation, possibly for programmers, possibly for later 
users of the script; the second way will respond to the `perldoc` 
command -- meaning anyone that can run the script can also examine 
comments formatted this way. That may or may not be desirable, which may 
be why it seems to be less common than simple # comments. 

> 2) the following script doesn't find the page requested in getstore
> (baolian.local = 127.0.0.1). Why?

Are you really expecting to store the contents of one URL to another? 
The getstore() function is intended for saving to a file. Try saving to 
a file that can be accessed as that URL --

$homepage = "~/public_html/provaperl5.html";

Etc. As far as I know, it cannot be a URL, it must be a file.

> 3) $homepage must be a real page/file or I can use it like a normal 
> variable or a filehandle to read with whlie(<>)?

It must be a real *file*, not a *page* (though that file can be accessed 
as a page, depending on where it is and how your web server is set up). 

I'm not sure what you mean by "must be a file ... or ... normal variable 
... or ... filehandle"; the way you write this implies that it's one, or 
the other, or the third, but that isn't necessarily the case. 

 


-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: getstore and comments

2005-08-19 Thread David Dorward
On Fri, Aug 19, 2005 at 10:58:24AM +0200, Adriano Allora wrote:

> Some questions:
> 1) how can I write multine comments? something like /** ... **/?

You can fake it with POD. I juse use a decent editor that lets me
comment out a every line in a region.
 
> 2) the following script doesn't find the page requested in getstore 
> (baolian.local = 127.0.0.1). Why?

The second parameter for getstore is a file, not a URL.

> 3) $homepage must be a real page/file or I can use it like a normal 
> variable or a filehandle to read with whlie(<>)?

The documentation doesn't say, but usually a module which takes a file
can take either a filename or a filehandle.

If your only intention is to read it, then you might be better off
with get() instead of getstore().

-- 
David Dorward  http://dorward.me.uk


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]