[22931] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5151 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 29 00:05:54 2003

Date: Sat, 28 Jun 2003 21:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 28 Jun 2003     Volume: 10 Number: 5151

Today's topics:
        <STDIN> blues (Tan Rezaei)
    Re: <STDIN> blues <eric-amick@comcast.net>
    Re: <STDIN> blues (Tad McClellan)
    Re: <STDIN> blues (Kent Paul Dolan)
    Re: <STDIN> blues <thepotplants@yahoo.com>
    Re: BTree examples ?? (Kenjis Kaan)
    Re: How do you sort a 2D array with column headers? (Greg Bacon)
    Re: No error for calling undefined sub's? (Gilgames)
    Re: No error for calling undefined sub's? <REMOVEsdnCAPS@comcast.net>
    Re: No error for calling undefined sub's? (Tad McClellan)
    Re: No error for calling undefined sub's? <bart.lateur@pandora.be>
    Re: Not following "if" <REMOVEsdnCAPS@comcast.net>
    Re: Regex to capture ip address from hosts file <abigail@abigail.nl>
        Testing perlfuncs (getopt) for true/false. (yeah i'm ne <thepotplants@yahoo.com>
    Re: Testing perlfuncs (getopt) for true/false. (yeah i' <krahnj@acm.org>
    Re: transform 3*0.0 into 0.0, 0.0, 0.0 <bwalton@rochester.rr.com>
        URL checking (Mandy)
    Re: URL checking <asu1@c-o-r-n-e-l-l.edu>
    Re: URL checking (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 28 Jun 2003 15:19:08 -0700
From: trezaei@hotmail.com (Tan Rezaei)
Subject: <STDIN> blues
Message-Id: <8c92d509.0306281419.4c8482ee@posting.google.com>

I have this bit of code on a win2k Server:

-----------------------------------------
#!E:\Perl\bin\perl.exe
print "\n\n Productline (QA, PROD, ...)?\n ";
chop($opt_p=<STDIN>);

print "\n\n Company (0001, 1000, 1001, \.\.\.) ? \n";
chop($opt_c=<STDIN>);

if ($opt_c =~ /\D/) { warn "Company number contains non digits"}

print "\n\n Ready to Process Company $opt_c in Productline $opt_p
(Y/N)?  \n";
chop($run=<STDIN>);
-----------------------------------------

Now when I run this, it does not prompt me for the variables but if I
enter all three of them then I will get the questions.

If I comment out all the lines with <STDIN> then I get all the promts
immediately.

Now this actually works fine on one machine and I only get this
problem when I put the file on the server.

Is there something about terminal settigs or clearing the buffer that
might be the issue. If so, how do I clear the screen buffer? This is
one of those things that you just don't want to waste your time on.
And it is really killing me.

Any help at all would be greatly appreciated.

thanks in advance

T


------------------------------

Date: Sat, 28 Jun 2003 19:19:20 -0400
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: <STDIN> blues
Message-Id: <pd8sfv8lqsh69kchd8m9njuurrkf5467ob@4ax.com>

On 28 Jun 2003 15:19:08 -0700, trezaei@hotmail.com (Tan Rezaei) wrote:

>I have this bit of code on a win2k Server:
>
>-----------------------------------------
>#!E:\Perl\bin\perl.exe
>print "\n\n Productline (QA, PROD, ...)?\n ";
>chop($opt_p=<STDIN>);
>
>print "\n\n Company (0001, 1000, 1001, \.\.\.) ? \n";
>chop($opt_c=<STDIN>);
>
>if ($opt_c =~ /\D/) { warn "Company number contains non digits"}
>
>print "\n\n Ready to Process Company $opt_c in Productline $opt_p
>(Y/N)?  \n";
>chop($run=<STDIN>);
>-----------------------------------------
>
>Now when I run this, it does not prompt me for the variables but if I
>enter all three of them then I will get the questions.

Try adding

$| = 1;

before the first print; that will tell Perl to flush after every write
to STDOUT.  I'm a bit puzzled as to why it would behave differently on
different machines, though.

perldoc perlvar

-- 
Eric Amick
Columbia, MD


------------------------------

Date: Sat, 28 Jun 2003 19:10:56 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: <STDIN> blues
Message-Id: <slrnbfsbkg.6ap.tadmc@magna.augustmail.com>

Tan Rezaei <trezaei@hotmail.com> wrote:

> chop($opt_p=<STDIN>);


That is soooooo '90s.

   chomp($opt_p=<STDIN>);  # the way it has been done since 1995!


> Now when I run this, it does not prompt me for the variables but if I
> enter all three of them then I will get the questions.


   http://perl.plover.com/FAQs/Buffering.html


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 28 Jun 2003 19:52:25 -0700
From: xanthian@well.com (Kent Paul Dolan)
Subject: Re: <STDIN> blues
Message-Id: <a3eaa964.0306281852.2746dcb8@posting.google.com>

trezaei@hotmail.com (Tan Rezaei) wrote:

> I have this bit of code on a win2k Server:

Ah, someone wise enough to post the source code in a nicely trimmed
down example without being asked!

> -----------------------------------------
> #!E:\Perl\bin\perl.exe
> print "\n\n Productline (QA, PROD, ...)?\n ";
> chop($opt_p=<STDIN>);
> 
> print "\n\n Company (0001, 1000, 1001, \.\.\.) ? \n";
> chop($opt_c=<STDIN>);
> 
> if ($opt_c =~ /\D/) { warn "Company number contains non digits"}
> 
> print "\n\n Ready to Process Company $opt_c in Productline $opt_p
> (Y/N)?  \n";
> chop($run=<STDIN>);
> -----------------------------------------
> 
> Now when I run this, it does not prompt me for the variables but if I
> enter all three of them then I will get the questions.
> 
> If I comment out all the lines with <STDIN> then I get all the promts
> immediately.
> 
> Now this actually works fine on one machine and I only get this
> problem when I put the file on the server.
> 
> Is there something about terminal settigs or clearing the buffer that
> might be the issue. If so, how do I clear the screen buffer? This is
> one of those things that you just don't want to waste your time on.
> And it is really killing me.
> 
> Any help at all would be greatly appreciated.
> 
> thanks in advance
> 
> T

It's been too long since I committed Perl with malice aforethought to
give you a detailed fix, but indeed your problem is buffering; when
you write from (any Unix program at all, and probably elsewhere),
unless you force matters to occur otherwise, written output is
buffered in memory until a standard bufferful (probably 512 bytes, but
can vary with OS) is ready to be written to "disk" (which in this case
is your screen) in a nice tidy efficient single write.

Sadly, that isn't at all what you want to have happen here.

The name of the magic you need is a forced "flush" of the STDOUT
stream, but I don't remember how to spell that in Perl, and the triage
of living homeless has left all my computer language manuals sold at
auction years ago.  Still, perhaps that will be clue enough to help
you find the answer yourself.

[It's also possible that some variant of writing in "raw" mode will
work, but that is really inefficient, and all you need in this
instance is to get the characters out one whole line at a time, not
each single character separately pushed with an immediate I/O action.]

And by the way, in general, "chomp" is friendlier than "chop", you
really don't want to use "chop" where you are trying explicitly to
trim a newline, but only where you _really, really_ want to trim the
last byte of a string, no matter _what_ value that byte contains.
Usually that is only true when you are treating string contents as
strings of binary octets rather than as strings of characters.  To
make a bad pun reversed, the habitual use of "chop" can bite you,
while "chomp", strangely, will not.

xanthian.


------------------------------

Date: Sun, 29 Jun 2003 15:30:58 +1200
From: "ThePotPlants" <thepotplants@yahoo.com>
Subject: Re: <STDIN> blues
Message-Id: <m3tLa.57155$JA5.1015363@news.xtra.co.nz>


"Tan Rezaei" <trezaei@hotmail.com> wrote:
> I have this bit of code on a win2k Server:
>
> -----------------------------------------
> #!E:\Perl\bin\perl.exe
> print "\n\n Productline (QA, PROD, ...)?\n ";
> chop($opt_p=<STDIN>);
>
> print "\n\n Company (0001, 1000, 1001, \.\.\.) ? \n";
> chop($opt_c=<STDIN>);
>
> if ($opt_c =~ /\D/) { warn "Company number contains non digits"}
>
> print "\n\n Ready to Process Company $opt_c in Productline $opt_p
> (Y/N)?  \n";
> chop($run=<STDIN>);
> -----------------------------------------
>
> Now when I run this, it does not prompt me for the variables but if I
> enter all three of them then I will get the questions.
>
> If I comment out all the lines with <STDIN> then I get all the promts
> immediately.
>
> Now this actually works fine on one machine and I only get this
> problem when I put the file on the server.
>
> Is there something about terminal settigs or clearing the buffer that
> might be the issue. If so, how do I clear the screen buffer? This is
> one of those things that you just don't want to waste your time on.
> And it is really killing me.
>
> Any help at all would be greatly appreciated.
>
> thanks in advance
>
> T

Looking at it a little differently...

It looks to me like you are mixing the use of @ARGV and GETOPT::STD (given
away by your variables $opt_c & $opt_p)
I posted a question related to getopt, have a look at it, you may want to
consider using that instead.
Ask yourself if you want to execute the programme and pass it variables, or
if you want to prompt the user for input.

P








------------------------------

Date: 28 Jun 2003 19:06:28 -0700
From: tivolinewbie@canada.com (Kenjis Kaan)
Subject: Re: BTree examples ??
Message-Id: <6a8ba9f8.0306281806.58e73098@posting.google.com>

Jörg Westheide <joerg@objectpark.org> wrote in message news:<0306QYvULoUrv0yfMhx3ae8Ayw@objectpark.org>...
> Hi!
> 
> > I am wondering if anyone has an example of using BTree for
> > storing data on a disk file.??   I found some BTree modules on the
> > web, but none give example of how you would then store it and retrieve
> > it from disk drive.
> 
> Have a look at the DB File module
> 
> > I have a need to store hundred of thousands of
> > key, data values
> 
> That's no problem (I used it with some millions)
> The only backdraw I discovered, is the really bad performance on 
> Win(2K), it's fine on Linux though
> 
> J rg

But Win2k is what I am doing all this on.  Using Activestate Perl.


------------------------------

Date: Sun, 29 Jun 2003 00:29:18 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: How do you sort a 2D array with column headers?
Message-Id: <vfscmuq0g2cfb1@corp.supernews.com>

In article <liurfvo9qc5miq038r5f3taoq9b302g8rs@4ax.com>,
     <Dennis@NoSpam.com> wrote:

: [...]
:
: A lot of neat code. Some of the perl syntax is new to me but I'll get
: to work with my Perl books and learn.  Thanks again.

Anything in particular that gave you trouble?  This is a discussion
group, after all. :-)  If you'll permit a guess, reading the perlref,
perllol, and perldsc manpages will help your understanding.

Greg
-- 
What has transformed the limited war between royal armies into total war,
the clash between peoples, is not technicalities of military art, but the
substitution of the welfare state for the laissez-faire state.
    -- Ludwig von Mises, *Human Action*


------------------------------

Date: 28 Jun 2003 23:34:49 GMT
From: gilgames@aol.coma (Gilgames)
Subject: Re: No error for calling undefined sub's?
Message-Id: <20030628193449.01961.00000356@mb-m10.aol.com>

<<

How about posting a simple script that illustrates the phenomenon?

/ Gunnar
>>


  sub bamboo {
     print "bamboo\n";
  }
  bamboo();
  bamboo;
  bampoo;


will print 2 "bamboo" lines, and gives no error message for the third call. 

Error will appear if either one put & sign in from of the subroutine, or put
the () after the name. 


------------------------------

Date: Sat, 28 Jun 2003 19:06:42 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: No error for calling undefined sub's?
Message-Id: <Xns93A8CC95AAE51sdn.comcast@206.127.4.25>

gilgames@aol.coma (Gilgames) wrote in
news:20030628193449.01961.00000356@mb-m10.aol.com: 

> <<
> 
> How about posting a simple script that illustrates the phenomenon?
> 
> / Gunnar
>>>
> 
> 
>   sub bamboo {
>      print "bamboo\n";
>   }
>   bamboo();
>   bamboo;
>   bampoo;
> 
> 
> will print 2 "bamboo" lines, and gives no error message for the third
> call. 
> 
> Error will appear if either one put & sign in from of the subroutine,
> or put the () after the name. 

Or better yet, if you 'use strict'.

-- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print


------------------------------

Date: Sat, 28 Jun 2003 19:14:48 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: No error for calling undefined sub's?
Message-Id: <slrnbfsbro.6ap.tadmc@magna.augustmail.com>

Gilgames <gilgames@aol.coma> wrote:


>   sub bamboo {
>      print "bamboo\n";
>   }
>   bamboo();
>   bamboo;
>   bampoo;
> 
> will print 2 "bamboo" lines, and gives no error message for the third call. 


You should enable warnings when developing Perl code, if you had you
would have gotten a warning message.

You should enable strict in Perl programs, if you had you would have
gotten an error message.

If you don't ask to get help, then you don't get it.

So ask.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sun, 29 Jun 2003 00:19:51 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: No error for calling undefined sub's?
Message-Id: <d5csfvkutdjpc6ftfclv2ad7kl92osn82k@4ax.com>

Gilgames wrote:

>  sub bamboo {
>     print "bamboo\n";
>  }
>  bamboo();
>  bamboo;
>  bampoo;
>
>
>will print 2 "bamboo" lines, and gives no error message for the third call. 

That's because "bampoo" is treated as a bareword. Perl interprets it as
a quoted string, i.e. a piece of text with that word as contents. Try

	$x = bampoo;
	print $x;

You do get a warning though, if you run it under -w.

"use strict;" will prevent that.

-- 
	Bart.


------------------------------

Date: Sat, 28 Jun 2003 19:05:40 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Not following "if"
Message-Id: <Xns93A8CC694761Csdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Eric Amick <eric-amick@comcast.net> wrote in 
news:q2irfv8sb8b7sfkklaev39jd6jg0503jtm@4ax.com:

> On Sat, 28 Jun 2003 16:25:02 +0200, Stefan Glimne <Snygg@gmx.net> wrote:
> 
>>   if ($imdblink{$imdbid}) {
>>     print "File already exist with the name 
>>$filmlista{$imdblink{$imdbid}}<BR>\n";
>>   } else {
> 
> In most cases, referring to an nonexistent array or hash element causes
> it to be created, a process called "autovivification."  Most of the time
> it's very handy, but it isn't when you just want to check for existence.

Autovivification only happens when you use a nonexistent hash or array 
element as a reference.  Simply testing whether it's true or not will not 
cause it to spring into existence.

But yes, it appears that the exists operator is what the OP needs.

- -- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPv4tUWPeouIeTNHoEQL4WACfchHxyJXk6zXK9ybeIvu3FVjcQ6QAn2HF
kNtrCFH/s5Xu31MW+1Vs6ESJ
=AX8g
-----END PGP SIGNATURE-----


------------------------------

Date: 28 Jun 2003 22:09:17 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Regex to capture ip address from hosts file
Message-Id: <slrnbfs4gd.el.abigail@alexandra.abigail.nl>

BC (bcraw@adelphia.net) wrote on MMMDLXXXVII September MCMXCIII in
<URL:news:Kk0La.19266$Jw6.7848888@news1.news.adelphia.net>:
-:  thanks for the feedback. i settled on the following to capture just the
-:  hostname as the key
-:  and the ip address as a value. can you see anything wrong with, or a way to
-:  optimize?
-:  
-:  (/^#?((\d{1,3}\.){3}\d{1,3})\s+(.[a-zA-Z0-9]+.).*#/)


use Regexp::Common;

if (/^#?($RE{net}{IPv4})\s+($RE{net}{domain}).*#/) {
    print $1;   # IP number.
    print $2;   # Host name.
}



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


------------------------------

Date: Sun, 29 Jun 2003 14:41:32 +1200
From: "ThePotPlants" <thepotplants@yahoo.com>
Subject: Testing perlfuncs (getopt) for true/false. (yeah i'm newbie.)
Message-Id: <0lsLa.57095$JA5.1013959@news.xtra.co.nz>


I keep seeing in the documentation about functions returning 1 or 0 true or
false... But I can't see how to test for it.
I want to know how to "test" something to see if it is true or false. Both
in general, and specifically for my problem.

My particular problem is using Getopt::Std;
My code works.. (sort of), but I know i'm not using it properly.

Getopt takes command line options and the following values (which is pretty
cool.)

Essentially I'm testing to see if the associated value is null to decide
whether to call the sub routines, rather than testing if the option has been
invoked.

See my programme below.

If no options are supplied the else condition should complain "invalid
option".

In my programme -e is the first valid option and -h is for help.
If I type: "opt2.pl -e arg1" then the argument arg1 is passed so that
variable $opt_e = arg1. And it calls the sub. (hoorah!)
If I type "opt2.pl -e " i.e with no argument then it fails, and complains
"invalid option".  (also hoorah.. of sorts..)

It's all good so far... now the annoying bit...

If want help I should just type: "opt2.pl -h"

But because I have not typed something after the -h then the value $opt_h is
empty. Even though the option is activated.

Specifically: How do I test $opt_h to see if is true or false? or rather to
see if -h has been invoked?
Generally: How can you test a variable to see if it's "not null" / if
there's something there/ id it's true/false/1/0 etc etc...

Any help (which doesn't include RTFM) would be greatly appreciated

Pete

#!/usr/bin/perl
use Getopt::Std;

getopt('eh');

print "
P1 Option -e $opt_e
P2 Option -h $opt_h
\n" ;

if ($opt_h ne "" ) {&hlp();
  }
elsif ($opt_e ne "" ) {&proc1($opt_e) ;
  }
else {print "invalid option \n" ;
  }

sub hlp{ print "
Usage opt2.pl -[eh]
-e environment
-h help \n" ;
 return 1;
}

sub proc1 { print "yeah it works \n" ; return 1 ;}




------------------------------

Date: Sun, 29 Jun 2003 04:00:05 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Testing perlfuncs (getopt) for true/false. (yeah i'm newbie.)
Message-Id: <3EFE6443.9FD78413@acm.org>

ThePotPlants wrote:
> 
> I keep seeing in the documentation about functions returning 1 or 0 true or
> false... But I can't see how to test for it.
> I want to know how to "test" something to see if it is true or false. Both
> in general, and specifically for my problem.

if ( $scalar ) {
    print "$scalar is true\n"
    }
else {
    print "$scalar is false\n"
    }


unless ( $scalar ) {
    print "$scalar is false\n"
    }
else {
    print "$scalar is true\n"
    }


> My particular problem is using Getopt::Std;
> My code works.. (sort of), but I know i'm not using it properly.
> 
> Getopt takes command line options and the following values (which is pretty
> cool.)
> 
> Essentially I'm testing to see if the associated value is null to decide
> whether to call the sub routines, rather than testing if the option has been
> invoked.
> 
> See my programme below.
> 
> If no options are supplied the else condition should complain "invalid
> option".
> 
> In my programme -e is the first valid option and -h is for help.
> If I type: "opt2.pl -e arg1" then the argument arg1 is passed so that
> variable $opt_e = arg1. And it calls the sub. (hoorah!)
> If I type "opt2.pl -e " i.e with no argument then it fails, and complains
> "invalid option".  (also hoorah.. of sorts..)
> 
> It's all good so far... now the annoying bit...
> 
> If want help I should just type: "opt2.pl -h"
> 
> But because I have not typed something after the -h then the value $opt_h is
> empty. Even though the option is activated.
> 
> Specifically: How do I test $opt_h to see if is true or false? or rather to
> see if -h has been invoked?
> Generally: How can you test a variable to see if it's "not null" / if
> there's something there/ id it's true/false/1/0 etc etc...

perldoc -f defined


> Any help (which doesn't include RTFM) would be greatly appreciated

Oops, too late.  :-)

> #!/usr/bin/perl

use warnings;
use strict;


> use Getopt::Std;
> 
> getopt('eh');

You might want to use getopts() instead of getopt(), it has better
features.  Also the two argument form of getopt() or getopts() will work
better when warnings and strict are enabled.

my %opt;
getopts( 'e:h', \%opt );

> print "
> P1 Option -e $opt_e
> P2 Option -h $opt_h
> \n" ;
> 
> if ($opt_h ne "" ) {&hlp();
>   }
> elsif ($opt_e ne "" ) {&proc1($opt_e) ;
>   }
> else {print "invalid option \n" ;
>   }

if    ( exists $opt{ h } ) { hlp() }
elsif ( exists $opt{ e } ) { proc1( $opt{ e } ) }


> sub hlp{ print "
> Usage opt2.pl -[eh]
> -e environment
> -h help \n" ;
>  return 1;
> }
> 
> sub proc1 { print "yeah it works \n" ; return 1 ;}


John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Sun, 29 Jun 2003 01:03:24 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: transform 3*0.0 into 0.0, 0.0, 0.0
Message-Id: <3EFE3ABD.5050309@rochester.rr.com>

Brian McCauley wrote:

> CM <starobs99@yahoo.com> writes:
 ...
> s/(\d+)\*(^[,]+)/join ", ", ( $2 ) x $1/eg;

[^----------^^

-- 
Bob Walton



------------------------------

Date: 28 Jun 2003 17:41:17 -0700
From: mandy100@ihug.com.au (Mandy)
Subject: URL checking
Message-Id: <6522b540.0306281641.4bbf5b23@posting.google.com>

Hi.
I can't seem to find any examples that will help me learn how to check
2 things using a perl script.

1. Does a given page exist on a remote site
e.g.  If i want to check that my homepage's pictures.html page exists.

2. Does a page contain a url that I specify
e.g. does my pictures.html page contain a link to my diary.html page


Of course they are not the pages I want to check. I've just tried to
make what I want to do easy to understand :-)

I know there must be examples out there but my choice of keywords
hasn't been too productive yet.

Thanks
Mand.


------------------------------

Date: 29 Jun 2003 00:57:02 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: URL checking
Message-Id: <Xns93A8D51F8AA49asu1cornelledu@132.236.56.8>

mandy100@ihug.com.au (Mandy) wrote in news:6522b540.0306281641.4bbf5b23
@posting.google.com:

> Hi.
> I can't seem to find any examples that will help me learn how to check
> 2 things using a perl script.
> 
> 1. Does a given page exist on a remote site
> e.g.  If i want to check that my homepage's pictures.html page exists.

see http://www.perldoc.com/perl5.8.0/lib/LWP.html#An-Example

 
> 2. Does a page contain a url that I specify
> e.g. does my pictures.html page contain a link to my diary.html page

HTML::Parser is your friend.

-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


------------------------------

Date: Sat, 28 Jun 2003 21:23:50 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: URL checking
Message-Id: <slrnbfsjdm.6f7.tadmc@magna.augustmail.com>

Mandy <mandy100@ihug.com.au> wrote:

> 1. Does a given page exist on a remote site


Try and "fetch" it, if you get a good-looking response, then
the resource exists.


> 2. Does a page contain a url that I specify
                           ^^^
                           ^^^

> I know there must be examples out there but my choice of keywords
> hasn't been too productive yet.


Errr, OK.


   perldoc -q fetch

      How do I fetch an HTML file?

   perldoc -q url

      How do I extract URLs?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 5151
***************************************


home help back first fref pref prev next nref lref last post