[23258] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5478 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 10 14:08:46 2003

Date: Wed, 10 Sep 2003 11: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)

Perl-Users Digest           Wed, 10 Sep 2003     Volume: 10 Number: 5478

Today's topics:
    Re: "between" function equivalent in Perl? <sagittaur@ftml.net>
    Re: "between" function equivalent in Perl? <sagittaur@ftml.net>
    Re: "between" function equivalent in Perl? <sagittaur@ftml.net>
    Re: "between" function equivalent in Perl? <sagittaur@ftml.net>
    Re: "between" function equivalent in Perl? <uri@stemsystems.com>
    Re: "between" function equivalent in Perl? <uri@stemsystems.com>
    Re: "between" function equivalent in Perl? <uri@stemsystems.com>
    Re: "between" function equivalent in Perl? <uri@stemsystems.com>
    Re: "between" function equivalent in Perl? <dave.nospam@ntlworld.com>
    Re: Best ways of using a username & password? <abigail@abigail.nl>
    Re: Best ways of using a username & password? <gary@abertron.co.uk>
    Re: Best ways of using a username & password? <jurgenex@hotmail.com>
    Re: Best ways of using a username & password? <gregs@trawna.com>
    Re: calculation in string <tom@nosleep.net>
    Re: calculation in string <jurgenex@hotmail.com>
        Converting pdf to text (Chandramohan Neelakantan)
    Re: Help me beef up my cruddy program <dover@nortelnetworks.com>
    Re: Help me beef up my cruddy program <jurgenex@hotmail.com>
    Re: Help me beef up my cruddy program <uri@stemsystems.com>
    Re: Help me beef up my cruddy program <tassilo.parseval@rwth-aachen.de>
        Installing libwww-perl-5.69 on Mac OSX <mike.edwards@rocksoft.demon.co.uk>
    Re: looping every x seconds <jurgenex@hotmail.com>
    Re: Perl Arguements <michael.p.broida@boeing.com>
    Re: Perl Arguements <michael.p.broida@boeing.com>
    Re: Printing a hash of hashes using an array for the he <usenet@dwall.fastmail.fm>
    Re: Printing a hash of hashes using an array for the he <mothra@nowhereatall.com>
    Re: Slice an array of hashes? <mpapec@yahoo.com>
    Re: Speeding up LWP::Simple <2mb@umama.com>
        Standards in Artificial Intelligence (Arthur T. Murray)
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 10 Sep 2003 09:49:39 -0700
From: "Alexandra" <sagittaur@ftml.net>
Subject: Re: "between" function equivalent in Perl?
Message-Id: <bjnkn4$rhk$1@lumberjack.rand.org>


"Anno Siegel" wrote:
> Alexandra wrote in comp.lang.perl.misc:

> > I'm attempting to extract a substring of characters from an alphanumeric
> > text string. [...] Here's what I'm trying to do:
> >
> > $mystring = 'aaa @ bbbb @ c @ dd @ eeeeee @ FFFFF=xxxx @ ggg @ h'
> >
> > The goal is to extract the 'xxxx' substring between the '=' sign and the
> > next whitespace character. (There is no fixed length for the 'xxxx'
> > substring.)
>
> The notion of "between" can very well be expressed in regular expressions.
> If $from and $to are regular expressions, the expression /$from(.*)$to/
> catches everything between the first match of $from and the last
> match of $to.  If you want to delimit from the first match of $from
> to the first match of $to after that point, use a non-greedy pattern in
the
> middle: /from(.*?)$to/.  In your case it doesn't matter:
>
> my $from = qr/=/; # a "="
> my $to = qr/\s/;  # any white space
> my ( $between) = $mystring =~ /$from(.*?)$to/;
> print "$between\n";
>
> That prints "xxxx".

If only it would... <g>. For some reason, I'm receiving a 1 as the return
value. I did some debugging to ensure the $to and $from values are correct
and that the string is a valid string value. I also tried using other valid
character values in the $to and $from fields to see if the '=' was the
culprit and still the expression evaluated to 1.

Alexandra




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

Date: Wed, 10 Sep 2003 09:49:31 -0700
From: "Alexandra" <sagittaur@ftml.net>
Subject: Re: "between" function equivalent in Perl?
Message-Id: <bjnkmv$rhj$1@lumberjack.rand.org>

"David Oswald" wrote:
> "Alexandra" wrote:

> > Hello All-
> >
> > I'm attempting to extract a substring of characters from an alphanumeric
> > text string. I've read a lot of Perl documentation on the 'index' and
> > 'substring' functions; however, I cannot find a regular expression (or
an
> > example of one) that is the equivalent of a "between" function in Perl.
> Perl
> > is very good at string manipulation so I assume there must be a way to
do
> > this. Here's what I'm trying to do:
>
> You read a "lot" of Perl documentation, and regular expression discussion,
> and didn't find anything therein that inspired a solution?

Actually, it inspired me to take up hieroglyphics.

> > $mystring = 'aaa @ bbbb @ c @ dd @ eeeeee @ FFFFF=xxxx @ ggg @ h'
> >
> > The goal is to extract the 'xxxx' substring between the '=' sign and the
> > next whitespace character. (There is no fixed length for the 'xxxx'
> > substring.)
>
> Assuming there is only one occurrence per string, and that there are no
> newlines in the string, this works.
> my $matched = $mystring =~ m/=(.*?)\s/;

This also evaluated to 1. I had tried this statement with and without the
leading 'm' and came up with the same result. I'm wondering if the
expression is evaluating at all or if Perl is just seeing it as a true or
valid expression. When I do type in something incorrect I do get a Server
Error. So the expression must be evaluating on some level. Any insight or
further suggestions would be appreciated.

> If there is more than one occurrence per string, and equals may also be
> embedded in the portion of the string you're attempting to extract, it
> becomes more complicated.  Assuming that the space character is unique in
> that it is always a delimiter, then you probably should make your life a
> little easier by first splitting on space, just so that you don't have to
> write a regexp that handles embedded equals differently from
> string-initiated equals signs, and stuff like that.

There is only one occurrence of the '=' per string. I'm not sure what
embedded means in Perl terms. (Does that mean the '=' is not preceded by a
word boundary or space?) I looked in the "Programming Perl" reference and
didn't find any index or glossary references for embedded or
string-initiated, and I don't have enough sense of Perl yet to distinguish
this intuitively. The '=' in the string does not have any leading or
trailing spaces; it is smashed between two characters.

I've played with the index and substr functions to work with a smaller
initial value for $mystring, but I still get the same Boolean result. I will
try playing with splitting to see if I can get it to work that way, but I
suspect it may return the same result.

> > Rather than use a series of clunky index and substring calls, does
anyone
> > have a better suggestion? If anyone can recommend a good Perl language
> > reference website (or book) that has some excellent examples of regular
> > expressions, that would be helpful too.
>
> Have you tried the perldocs, specifically 'perldoc perlbook' for book
> suggestions?  The bible is the Camel book (Programming Perl), and the
sunday
> school lesson manual is Learning Perl (the Llama book).

We do have Learning Perl and Programming Perl. I find them excellent
references but slow to digest. There are simply not enough examples for me
to work backwards and easily "decode" the language explanations. When
something clicks (from the examples provided) and I re-read that section in
the O'Reilly references, the explanations then make perfect sense. <g> I
suppose it will just mean sheer time and effort in seeking more examples out
on the web as well as helpful hints from groups such as this one.

Alexandra






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

Date: Wed, 10 Sep 2003 09:50:08 -0700
From: "Alexandra" <sagittaur@ftml.net>
Subject: Re: "between" function equivalent in Perl?
Message-Id: <bjnko2$rk8$1@lumberjack.rand.org>

"Matija Papec" wrote:

> "Alexandra" wrote:
> >example of one) that is the equivalent of a "between" function in Perl.
Perl
> >is very good at string manipulation so I assume there must be a way to do
> >this. Here's what I'm trying to do:
> >
> >$mystring = 'aaa @ bbbb @ c @ dd @ eeeeee @ FFFFF=xxxx @ ggg @ h'
> >
> >The goal is to extract the 'xxxx' substring between the '=' sign and the
> >next whitespace character. (There is no fixed length for the 'xxxx'
> >substring.)
>
> my($match) = $mystring =~ /=(\S+)/;

Thanks for your reply. Unfortunately, I only received a "1" as the return
value, as I also did with some of the other suggestions. I'm not sure if
this means it's evaluating to Boolean (or why). I did some debugging to
ensure $mystring is a valid text value, and it seems to be.

> >Rather than use a series of clunky index and substring calls, does anyone
> >have a better suggestion? If anyone can recommend a good Perl language
> >reference website (or book) that has some excellent examples of regular
> >expressions, that would be helpful too.
>
> I've heard that "Mastering regular expression" is very good.

We do have some of the O'Reilly books in the office but not that one. Thank
you, I'll check it out.

Alexandra




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

Date: Wed, 10 Sep 2003 09:49:47 -0700
From: "Alexandra" <sagittaur@ftml.net>
Subject: Re: "between" function equivalent in Perl?
Message-Id: <bjnknd$rk7$1@lumberjack.rand.org>


"Brian Wakem" wrote:

> "Alexandra" wrote:

> > this. Here's what I'm trying to do:
> >
> > $mystring = 'aaa @ bbbb @ c @ dd @ eeeeee @ FFFFF=xxxx @ ggg @ h'
> >
> > The goal is to extract the 'xxxx' substring between the '=' sign and the
> > next whitespace character. (There is no fixed length for the 'xxxx'
> > substring.)
> >
> > Rather than use a series of clunky index and substring calls, does
anyone
> > have a better suggestion? If anyone can recommend a good Perl language
> > reference website (or book) that has some excellent examples of regular
> > expressions, that would be helpful too.
>
>
> print $mystring =~ m/=([^\s]+)/;

Thanks for your reply. For some reason this also evaluated to 1, instead of
the desired substring. And there is not a "1" character in the initial
string ($mystring). I tried placing brackets [] around the equal sign and
still no dice.

The expression seems, somehow, to be evaluating for a truth value. (??)

Alexandra




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

Date: Wed, 10 Sep 2003 17:14:50 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: "between" function equivalent in Perl?
Message-Id: <x74qzkd0qe.fsf@mail.sysarch.com>

>>>>> "A" == Alexandra  <sagittaur@ftml.net> writes:

  >> my($match) = $mystring =~ /=(\S+)/;

  A> Thanks for your reply. Unfortunately, I only received a "1" as the return
  A> value, as I also did with some of the other suggestions. I'm not sure if
  A> this means it's evaluating to Boolean (or why). I did some debugging to
  A> ensure $mystring is a valid text value, and it seems to be.

the above will not evaluate to 1. your code is not the same as that line
of code. wanna bet you don't have () around your $match var?

  >> I've heard that "Mastering regular expression" is very good.

  A> We do have some of the O'Reilly books in the office but not that one. Thank
  A> you, I'll check it out.

this is covered in perlre, perlretut and perlrequick. you need to learn
how regexes work in different contexts.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class


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

Date: Wed, 10 Sep 2003 17:15:31 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: "between" function equivalent in Perl?
Message-Id: <x71xuod0p8.fsf@mail.sysarch.com>

>>>>> "A" == Alexandra  <sagittaur@ftml.net> writes:

  >> Assuming there is only one occurrence per string, and that there are no
  >> newlines in the string, this works.
  >> my $matched = $mystring =~ m/=(.*?)\s/;

  A> This also evaluated to 1. I had tried this statement with and without the
  A> leading 'm' and came up with the same result. I'm wondering if the
  A> expression is evaluating at all or if Perl is just seeing it as a true or
  A> valid expression. When I do type in something incorrect I do get a Server
  A> Error. So the expression must be evaluating on some level. Any insight or
  A> further suggestions would be appreciated.

and that line of code is wrong. see my other post.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class


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

Date: Wed, 10 Sep 2003 17:16:50 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: "between" function equivalent in Perl?
Message-Id: <x7y8wwbm2m.fsf@mail.sysarch.com>

>>>>> "A" == Alexandra  <sagittaur@ftml.net> writes:

  >> middle: /from(.*?)$to/.  In your case it doesn't matter:
  >> 
  >> my $from = qr/=/; # a "="
  >> my $to = qr/\s/;  # any white space
  >> my ( $between) = $mystring =~ /$from(.*?)$to/;
  >> print "$between\n";
  >> 
  >> That prints "xxxx".

  A> If only it would... <g>. For some reason, I'm receiving a 1 as the return
  A> value. I did some debugging to ensure the $to and $from values are correct
  A> and that the string is a valid string value. I also tried using other valid
  A> character values in the $to and $from fields to see if the '=' was the
  A> culprit and still the expression evaluated to 1.

SHOW YOUR CODE. saying it doesn't work without showing your code is a
waste of everyone's time. the above code is fine. obviously yours is not
but we can't fix it without seeing it.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class


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

Date: Wed, 10 Sep 2003 17:19:14 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: "between" function equivalent in Perl?
Message-Id: <x7vfs0blzv.fsf@mail.sysarch.com>

>>>>> "A" == Alexandra  <sagittaur@ftml.net> writes:

  >> print $mystring =~ m/=([^\s]+)/;

  A> Thanks for your reply. For some reason this also evaluated to 1, instead of
  A> the desired substring. And there is not a "1" character in the initial
  A> string ($mystring). I tried placing brackets [] around the equal sign and
  A> still no dice.

gack, you don't get context. print is returning the 1. or you are not
realizing print provides list context. this is a poor example since it
isn't clear why the grabbed string is printed.

  A> The expression seems, somehow, to be evaluating for a truth value. (??)

again, SHOW YOUR CODE.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class


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

Date: Wed, 10 Sep 2003 18:22:13 +0100 (BST)
From: "Dave Saville" <dave.nospam@ntlworld.com>
Subject: Re: "between" function equivalent in Perl?
Message-Id: <qnirfnivyyragyjbeyqpbz.hl0rh1h.pminews@text.news.ntlworld.com>

I just cut n pasted the code from previous posts

use strict;
use warnings;
my $mystring = 'aaa @ bbbb @ c @ dd @ eeeeee @ FFFFF=xxxx @ ggg @ h';
my $from = qr/=/; # a "="
my $to = qr/\s/;  # any white space
my ( $between) = $mystring =~ /$from(.*?)$to/;
print "$between\n";


Prints xxxx here. Perl 5.8.0 on OS/2. Something odd your end I feel.



Regards

Dave Saville

NB switch saville for nospam in address




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

Date: 10 Sep 2003 15:06:19 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Best ways of using a username & password?
Message-Id: <slrnbluffb.6me.abigail@alexandra.abigail.nl>

Gary Mayor (gary@abertron.co.uk) wrote on MMMDCLXII September MCMXCIII in
<URL:news:2NG7b.983$lj5.564143@newsfep2-win.server.ntli.net>:
``  
``  How can this be in the wrong group. This is a Perl Misc group and most 
``  of the people on here will have there own methods of using passwords. My 
``  topic is about perl I wasn't asking about any other language. 
``  Miscellaneous means anything relating to Perl right so why the hell is 
``  this in the wrong group. If people spent less time moaning and more 
``  doing this world would be a better place.


*PLOINK*


Abigail
-- 
END   {print "Hacker\n"}
BEGIN {print "Just "   }
INIT  {print "Perl "   }
CHECK {print "another "}


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

Date: Wed, 10 Sep 2003 16:34:56 +0100
From: Gary Mayor <gary@abertron.co.uk>
Subject: Re: Best ways of using a username & password?
Message-Id: <CqH7b.993$lj5.583458@newsfep2-win.server.ntli.net>

Abigail wrote:
> Gary Mayor (gary@abertron.co.uk) wrote on MMMDCLXII September MCMXCIII in
> <URL:news:2NG7b.983$lj5.564143@newsfep2-win.server.ntli.net>:
> ``  
> ``  How can this be in the wrong group. This is a Perl Misc group and most 
> ``  of the people on here will have there own methods of using passwords. My 
> ``  topic is about perl I wasn't asking about any other language. 
> ``  Miscellaneous means anything relating to Perl right so why the hell is 
> ``  this in the wrong group. If people spent less time moaning and more 
> ``  doing this world would be a better place.
> 
> 
> *PLOINK*
> 
> 
> Abigail

hahahahaha



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

Date: Wed, 10 Sep 2003 16:14:57 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Best ways of using a username & password?
Message-Id: <56I7b.18443$98.2300@nwrddc03.gnilink.net>

Gary Mayor wrote:
> Hi,
> I'm placing a username and password form on my site but can't decide

For how to read a password please see "perldoc -q password".

Forms: Perl does not have forms.

> on the best way to do it. I've looked at
> Apache Session ID

Perl does not have Apache Session IDs

> Encrypted cookies

Perl does not have cookies

> and a couple of other things that are crap. What's the best method of
> doing it. I need them to enter a username and password and I need the
> site to remember there using it and timeout after 20 minutes of
> inactivity. Is there an industry standard for doing this?

As your question is in no way specific to Perl you may want to ask in a
Newsgroup where people actually care about CGI programming.
Or do you believe that just because I manage my cooking recipies with Perl a
question about the WestIndian Fire Pot would be on topic here, too?

jue




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

Date: Wed, 10 Sep 2003 16:35:41 GMT
From: Greg Schmidt <gregs@trawna.com>
Subject: Re: Best ways of using a username & password?
Message-Id: <n2kulvs3uo042it3okr2e3219acb4r22e5@4ax.com>

On Wed, 10 Sep 2003 15:50:36 +0100, Gary Mayor <gary@abertron.co.uk>
wrote:

>A. Sinan Unur wrote:
>> 
>> None of this is topical for this group. Try 
>> comp.inforsystems.www.authoring.cgi for general questions, and find the 
>> appropriate group for your server for server-specific questions.
>> 
>> You may want to consult the WWW Security FAQ 
>> (http://www.w3.org/Security/Faq/www-security-faq.html) and the Login 
>> Tutorial (http://www.webthing.com/tutorials/LOGIN1.html). 
>> 
>> Sinan.
>
>How can this be in the wrong group. This is a Perl Misc group and most 
>of the people on here will have there own methods of using passwords. My 
>topic is about perl I wasn't asking about any other language.

Your topic is not actually about Perl.  Your topic is about CGI.  People
can implement CGI in Perl, C/C++, Python, and many other languages.  The
methods of handling usernames and passwords will be well known to CGI
programmers regardless of what languate they are using.  These people
hang out in the newsgroup Sinan pointed you to, and will be able and
happy to help you with the concepts.  If you have a problem
*implementing* your chosen solution in Perl, then this is the right
place to ask about it.

Conversely, Perl is used for many things other than CGI.  There are many
people here who have been programming in Perl for many years and have
never written a CGI script.

>Miscellaneous means anything relating to Perl right so why the hell is 
>this in the wrong group. If people spent less time moaning and more 
>doing this world would be a better place.

The name ".misc" is a historical artifact, and is not meant to suggest
that a post with only a remote connection to Perl is acceptable.

If people posted their messages to the right place the first time
around, the world would be a better place.  If people knew to accept a
message like Sinan's as being a friendly pointer to a place they can get
better help, the world would be a better place.  The world is not made
better by someone blustering around in a Starbucks insisting that they
should sell books on how to grow your own coffee.

-- 
Greg Schmidt (gregs@trawna.com)
  Trawna Publications (http://www.trawna.com/)


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

Date: Wed, 10 Sep 2003 08:27:57 -0700
From: "Tom" <tom@nosleep.net>
Subject: Re: calculation in string
Message-Id: <3f5f425b$1@nntp0.pdx.net>

and what would be the mainstream perl newsgroups?

"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:bjmr18$2ce$2@mamenchi.zrz.TU-Berlin.DE...
> Trent Curry <tcurrey@no.no.no.i.said.no> wrote in comp.lang.perl.misc:
> > "Daniel" <dvdoord@planet.nl> wrote in message
> > news:3f4c7dbf$0$49114$e4fe514c@news.xs4all.nl...
> > > I've a dynamic variable
> > > $var_tmp = "/18";
> > > where the "/18" can also be "/18+100"
> > > I also got a variable
> > > $var_prize = 2000
> > > now the thing is I have to get this
> > > $var_total = 2000/18+100;
> > >
> > > anybody knows how this works ?!?
> >
> >    $var_total = eval($var_tmp);
> > will do what you want.
> >
> > Also, alt.comp.lang.perl & comp.lang.perl are very rare if not virtually
> > extinct news groups. I don't think too many people get them. Though
there
> > seems to be SOME activity in those two said groups...
> >
> > Or is alt.comp.lang.perl just a lesser known group?
>
> alt.comp.lang.perl is a legit alternative to the mainstream Perl groups.
> comp.lang.perl has been decommissioned many years ago -- it *shouldn't*
> exist anywhere, but a sizeable minority of news server still carry it.
>
> Anno




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

Date: Wed, 10 Sep 2003 15:56:22 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: calculation in string
Message-Id: <GQH7b.18421$98.13891@nwrddc03.gnilink.net>

Tom wrote:
> and what would be the mainstream perl newsgroups?

Please see "perldoc -q usenet".
And don't top-post-full-quote!

jue




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

Date: 10 Sep 2003 08:32:18 -0700
From: knchandramohan@yahoo.com (Chandramohan Neelakantan)
Subject: Converting pdf to text
Message-Id: <69d11688.0309100732.5bedb300@posting.google.com>

Hello all, 

Problem:

Need to  extract text information  from a pdf file , write the  text
to a file  for a hardware project .
The text is  contained in a table and has the width and height
information of different layers for a chip
The widthe and height information would be used to create test layouts
for different layers using Cadence SKILL.


OS: Hp-UX

Other tools used: Cadence SKILL



I wanted to do this  initial pdf parsing in Perl  because: 

- it comes with the OS
- No point in writing the pdf parsing tool (which wld be an independen
project then)
- someone must have experienced the parsing  proble before

I hope Im clear so far


Searching: 

I tried module search on search.cpan.org but as far I have seen, I
dint notice any that  extracts the text information from a pdf file.


I also tried seaarching on google but there seems to be pdf2text for
Linux



Solutions:

- I would  appreciate if someone could point me to a module/script
that converts pdf 2 text

- any other suggestions in tackling the problem welcome



Many thanks 
CM


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

Date: Wed, 10 Sep 2003 10:22:52 -0500
From: "Bob Dover" <dover@nortelnetworks.com>
Subject: Re: Help me beef up my cruddy program
Message-Id: <bjnfin$jfq$1@zcars0v6.ca.nortel.com>

"Helgi Briem" wrote...
> "Bernard El-Hagin" wrote:
> >Eric J. Roode wrote:
> >> What's wrong with it?
> >It's lacking in beef, according to the Subject.
> $beef++;

Chuckle...  Thanks, I needed that!




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

Date: Wed, 10 Sep 2003 16:24:25 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Help me beef up my cruddy program
Message-Id: <ZeI7b.18454$98.14784@nwrddc03.gnilink.net>

Dan Jacobson wrote:
> Help me beef up my cruddy program.  It should then even run on
> Microsoft, by the way.
>
> #!/usr/bin/perl -ws
> #use strict; #can't use due to -s.
> $, = "\t";
> $\ = "\n";

What is this supposed to do?

> my $A = 0.00001549;
> my $B = 0.000006521;
> my $C = 807.8;
> my $D = 248.6;

By convention people use upper case variables for file descriptions only.

> if ( $I ) {
>     foreach my $i ( $A, $B, $C, $D ) { $i = -$i }
> }

Why the condition? The body will never be executed because $I will never be
true.
Didn't perl warn you about undefined value?

> while (<>) {
>     my @F = split;
>     print $F[0] - $C - $A * $F[0] - $B * $F[1],
>       $F[1] + $D - $A * $F[1] - $B * $F[0], "@F";
> }

And what is this supposed to do versus what does it do?
You naming convention is ---shall we say--- suboptimal?

jue




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

Date: Wed, 10 Sep 2003 17:12:39 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Help me beef up my cruddy program
Message-Id: <x77k4gd0u0.fsf@mail.sysarch.com>

>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:

  >> #!/usr/bin/perl -ws
  >> #use strict; #can't use due to -s.

  >> if ( $I ) {
  >> foreach my $i ( $A, $B, $C, $D ) { $i = -$i }
  >> }

  JE> Why the condition? The body will never be executed because $I will
  JE> never be true.  Didn't perl warn you about undefined value?

conditional tests don't warn on undef. and his comment on strict and -s
tells me he was passing -I on the command line and -s would then set $I
which would negate the 4 values.

  >> while (<>) {
  >> my @F = split;
  >> print $F[0] - $C - $A * $F[0] - $B * $F[1],
  >> $F[1] + $D - $A * $F[1] - $B * $F[0], "@F";
  >> }

  JE> And what is this supposed to do versus what does it do?
  JE> You naming convention is ---shall we say--- suboptimal?

and he still hasn't responded so i guess a hit and run troll. notice his
other post which made some useless comment on sub locations.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class


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

Date: 10 Sep 2003 17:40:15 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Help me beef up my cruddy program
Message-Id: <bjnnlv$lfn$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Uri Guttman:

>>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:

>  >> while (<>) {
>  >> my @F = split;
>  >> print $F[0] - $C - $A * $F[0] - $B * $F[1],
>  >> $F[1] + $D - $A * $F[1] - $B * $F[0], "@F";
>  >> }
> 
>  JE> And what is this supposed to do versus what does it do?
>  JE> You naming convention is ---shall we say--- suboptimal?
> 
> and he still hasn't responded so i guess a hit and run troll. notice his
> other post which made some useless comment on sub locations.

It was a question about where to place subroutine-definitions. Looking
at other languages (where the place of the definition could matter; for
Perl it even does matter when using prototypes), it wasn't quite so
useless.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Wed, 10 Sep 2003 17:38:04 +0100
From: Mike Edwards <mike.edwards@rocksoft.demon.co.uk>
Subject: Installing libwww-perl-5.69 on Mac OSX
Message-Id: <mike.edwards-3F1AE5.17380410092003@news.news.demon.net>

Hi,

I'm trying to install libwww-perl-5.69 on my OSX machine to run under 
Perl 5.8.0. The build appears to have gone okay but when I run 'make 
test' I get the following output:

/usr/bin/perl t/TEST 0
base/common-req.......ok                                                     
base/cookies..........ok                                                     
base/date.............ok                                                     
base/headers-auth.....ok                                                     
base/headers-etag.....ok                                                     
base/headers-util.....ok                                                     
base/headers..........ok                                                     
base/http.............ok                                                     
base/listing..........ok                                                     
base/mediatypes.......ok                                                     
base/message..........ok                                                     
base/negotiate........ok                                                     
base/response.........ok                                                     
base/status...........ok                                                     
base/ua...............ok                                                     
html/form.............ok                                                     
robot/rules-dbm.......ok                                                     
robot/rules...........ok                                                     
robot/ua-get..........NOK 7HTTP Server terminated                            
robot/ua-get..........FAILED tests 1-3, 5, 7                                 
        
Failed 5/7 tests, 28.57% okay
robot/ua..............NOK 7HTTP Server terminated                            
robot/ua..............FAILED tests 1-3, 5, 7                                 
        
Failed 5/7 tests, 28.57% okay
local/autoload-get....ok                                                     
local/autoload........ok                                                     
local/get.............ok                                                     
local/http-get........NOK 8Can't call method "is_redirect" on an 
undefined value at local/http-get.t line 214, <DAEMON> line 1.
HTTP Server terminated
local/http-get........dubious                                                
        
Test returned status 22 (wstat 5632, 0x1600)
DIED. FAILED tests 1-19
        Failed 19/19 tests, 0.00% okay
local/http............NOK 8Can't call method "is_redirect" on an 
undefined value at local/http.t line 188, <DAEMON> line 1.
HTTP Server terminated
local/http............dubious                                                
        
Test returned status 22 (wstat 5632, 0x1600)
DIED. FAILED tests 1-18
        Failed 18/18 tests, 0.00% okay
local/protosub........ok                                                     
Failed Test      Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------
------
local/http-get.t   22  5632    19   19 100.00%  1-19
local/http.t       22  5632    18   18 100.00%  1-18
robot/ua-get.t                  7    5  71.43%  1-3 5 7
robot/ua.t                      7    5  71.43%  1-3 5 7
Failed 4/26 test scripts, 84.62% okay. 47/343 subtests failed, 86.30% 
okay.
make: *** [test] Error 2


The errors seem to refer to this line in ./t/local/http-get.t and 
 ./t/local/http.t although I don't understand it enough to work out what 
the problem is.

print "ok 8\n";      
print "not " unless $res->previous->is_redirect
                and $res->previous->code == 301;

Can anyone suggest why things are going wrong and how I can fix it 
please?

Thanks,

Mike


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

Date: Wed, 10 Sep 2003 16:32:18 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: looping every x seconds
Message-Id: <mmI7b.18462$98.11652@nwrddc03.gnilink.net>

kernal32 wrote:
> In PERL how do I execute a block of code every "x" seconds?
> I'm talking a loop or similar but it runs every x seconds, where x is
> given.

That is not possible from Perl.
You can put your the Perl program to rest for x seconds using sleep(). But
this is different from running the loop every x seconds.
Just imagine it takes y seconds to run the loop. Then the next start of the
loop will happen x+y seconds after the previous start.

If you really want/need to run the code every x seconds then you may need to
set up an external timer (depending on your needs for precision could be
another program or a system task or a hardware timer) which sends a signal
to your program and thus triggers the loop.

jue




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

Date: Wed, 10 Sep 2003 17:33:30 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Perl Arguements
Message-Id: <3F5F606A.95310F0E@boeing.com>

John Bokma wrote:
> 
> Michael P. Broida wrote:
> 
> > John Bokma wrote:
> >
> >>And for those who really want the same experience on Windows:
> >>http://www.cygwin.com/
> >
> >
> >       I am interested in Cygwin, but we need to keep all of
> >       our systems here in pretty nearly the same configuration
> >       so we don't introduce problems from dependencies on a
> >       particular tool.
> 
> So why can you use tool Perl but not tool Cygwin?

	Perl has been approved.  Cygwin has not.
	I don't do the approving, so I don't know their reasons.

		Mike


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

Date: Wed, 10 Sep 2003 17:43:42 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Perl Arguements
Message-Id: <3F5F62CE.D8BCB9F1@boeing.com>

Bart Lateur wrote:
> 
> Michael P. Broida wrote:
> 
> >       We had problems on an older project under Solaris when
> >       one person decided to use "tcsh" instead of our "standard"
> >       csh.  Some of his scripts didn't work correctly for the
> >       rest of us or for our customers.  :)
> 
> That's what the shebang line is for.

	Yeah, but...   (It's been 7+ years, so my recall is a bit
	spotty...)

	The problem surfaced when the user's DEFAULT shell was tcsh.
	We tracked it down to some builtin function that behaved VERY
	slightly differently in tcsh than in csh.  I don't recall now
	which function it was, but that TINY difference screwed up one
	of:
	  - the setup commands we required in the .login/.cshrc files
	  - the actual startup scripts for the project app
	I don't recall which.

	The simple fix was to require csh for all testing/running of
	that app.  NONE of our customers were "techie" enough to find
	or use tcsh themselves; it was only ONE of our developers that
	liked using it.  :)  He was able to use tcsh for his general
	work as long as he set his default shell to csh and opened a
	fresh csh for testing/running.

		Mike


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

Date: Wed, 10 Sep 2003 16:16:50 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Printing a hash of hashes using an array for the headings and getting the columns to line up
Message-Id: <Xns93F27CE764669dkwwashere@216.168.3.30>

Mothra <mothra@nowhereatall.com> wrote:

>  I am trying to print out a report using a Hash of Hashes and am
>  having 
> trouble
> getting the columns to print out correctly. I have an array that
> contains the column
> headings in the correct order but I am stuck as how to get the HoH
> to use this information. I have provided a test script as to what
> I have tried. How can I get the script to print the columns in the
> correct order. 
> 
> Thanks
> 
> Mothra
> 
> 
> 
> #!/app/perl5.8.0/bin/perl
> use strict;
> use warnings;
> 
> my @family = qw(UNIGRAPHICS_NX UNIGRAPHICS SOLID_EDGE WEBTOOLS
> other); 

# Add this to construct a format strinf for printf()

my $form_str = '%9s ' . join '', map '%' . (1 + length $_) . 's' 
    	=> @family;


> 
> my %people = (
>   'wattsl' => {
>       'SOLID_EDGE'     => 3,
>       'WEBTOOLS'       => 10,
>       'UNIGRAPHICS'    => 19,
>       'UNIGRAPHICS_NX' => 57
>  },
>   'friasd' => {
>       'other'          => 2,
>       'SOLID_EDGE'     => 10,
>       'WEBTOOLS'       => 25,
>       'UNIGRAPHICS'    => 21,
>       'UNIGRAPHICS_NX' => 81
>  },
>   'yamaguch' => {
>       'other'          => 4,
>       'SOLID_EDGE'     => 12,
>       'WEBTOOLS'       => 11,
>       'UNIGRAPHICS'    => 9,
>       'UNIGRAPHICS_NX' => 56
>  },
>   'jung' => {
>       'other'          => 2,
>       'SOLID_EDGE'     => 5,
>       'WEBTOOLS'       => 16,
>       'UNIGRAPHICS'    => 13,
>       'UNIGRAPHICS_NX' => 39
>  },
>   'riches' => {
>       'other'          => 2,
>       'SOLID_EDGE'     => 18,
>       'WEBTOOLS'       => 24,
>       'UNIGRAPHICS'    => 10,
>       'UNIGRAPHICS_NX' => 83
>  },
> 
> );
> 
> printf "%24s %10s %10s %8s %5s \n", @family;
> 
> foreach my $person( sort keys %people ) {
> 
>     printf "%9s     %2d     %2d     %2d     %2d     %2d\n",
>     $person, 
>       map { $people{$person}{$_} } sort keys %{ $people{$person}
>       }; 
> 
>}

printf "$form_str\n", ' ', @family;

foreach my $person( sort keys %people ) {
    printf "$form_str\n", $person,
      map { $people{$person}{$_} } @family;
}


-- 
David Wall


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

Date: Wed, 10 Sep 2003 09:56:28 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Printing a hash of hashes using an array for the headings and getting the columns to line up
Message-Id: <3f5f575b@usenet.ugs.com>

Hi David,

"David K. Wall" <usenet@dwall.fastmail.fm> wrote in message
news:Xns93F27CE764669dkwwashere@216.168.3.30...
> Mothra <mothra@nowhereatall.com> wrote:
>
[snipped]

Thanks for replying  :)

> # Add this to construct a format strinf for printf()
>
> my $form_str = '%9s ' . join '', map '%' . (1 + length $_) . 's'
>     => @family;
>
>
Ok, generate a form.

[more snippage]

> printf "$form_str\n", ' ', @family;
>
> foreach my $person( sort keys %people ) {
>     printf "$form_str\n", $person,
>       map { $people{$person}{$_} } @family;
> }
>
I added this and receive:
Use of uninitialized value in printf at F:\scripts\rep.pl line 52.
I think this is because of the wattsl value is missing the
'other' key value. After checking the orginal test script I found
that I was forcing a  %2d  in the format line.

I went back and reran the test script I orginally wrote and did not
receive the uninitialized value warning. I wonder why I did not receive
a warning? Any way, for now  do you know of a good
way to remove the warning? (other that commenting out the use warnings
line).

Thanks

Mothra




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

Date: Wed, 10 Sep 2003 18:40:38 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Slice an array of hashes?
Message-Id: <2ukulv88lrlgihfu4iiuus1ei9hhi3t6ms@4ax.com>

X-Ftn-To: Graham 

GrahamWilsonCA@yahoo.ca (Graham) wrote:
>           while ( $i < $numLev )
>             {       
>               $line = <$fh>;                                # Take
>next line
>               $line =~ s/^\s+|\s+$//g;               # Strip
>whitespace
>               $line =~ s/,/ /g;                              #
>Replace commas
>               @prf = ( @prf, (split /\s+/, $line) ); # Get the data

You'll be beter with 
push @prf, ..
rather then 
@prf = @prf, ..

>               $i = $#prf + 1;                                # Update

$i = @prf is more classic way to do the same thing.

>           @data = (@data, {"id"=>$id, "units"=>$units,
>"data"=>[@prf]});
>I want to find all the indices of atm where $id = "foo" or "bar" and
>extract them into a new data array called data2.

You don't have atm in above example but I'll /guess/ it looks like @data,

#untested
my @idx = grep $atm[$_]{id} =~ /^(?:foo|bar)$/, 0 .. $#atm;

>Alas, at this point I cannot even slice into @data and select the "id"
>fields.
>
>    print $atm[(0..2)]; # Gives: HASH(0x121064)

This is same as $atm[0], as you're here refering to scalar, not array slice.
btw, you don't need braces around range.

>    print @atm[(0..2)]; # Gives:
>HASH(0x121064)HASH(0x11a0e0)HASH(0x112ce8)
>    print @atm[(0..2)]{"id"}; # Gives: compilation error.
>    print $atm[(0..2)]{"id"}; # Gives: string id tag for index 2

perldoc perlref is your friend.
Try,
use Data::Dumper;
print Dumper @atm;



-- 
Matija


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

Date: Wed, 10 Sep 2003 17:10:07 GMT
From: "2mb" <2mb@umama.com>
Subject: Re: Speeding up LWP::Simple
Message-Id: <pan.2003.09.10.17.09.59.425458@umama.com>

David,
Why not just use one of the commercially available email harvesting
packages. Most are available for 19.99. If you are going to spam, it is better
to get your list built and operational as soon as possible, before more
legislation goes into effect.

Better yet, just kill the email servers by using a dictionary/shotgun approach.
You will either be killing web servers or email servers with your load. 
May as well take the shortest distance. You can put some html banner in 
there to populate your "good" list for the poor suckers that open it. 

So much for opt-in eh?

Oh... that's right. The dictionary method could be
prosecuted as a DoS attack. The www site email harvest trick is much more
covert. Don't forget to set the User-agent request header so your script looks
like IE.

Got any Viagra? How about some pR0n? I could use some junk mail with more
of this. I only get 400+ a day. Fill it up dude. Maybe you should cross
post this question to 2-300 lists. That should get your spam-on for at
least a few minutes.

l8,
2mb



On Tue, 09 Sep 2003 16:55:08 -0700, David Morel wrote:

> Hi all,
> 
> I am looking to collect the HTML of approximately 30 million urls, in
> as simple a manner as possible, perhaps using the LWP::Simple module.
> If I choose to use LWP::Simple, how can I speed up the process?
> 
> It seems that it would be too time consuming to collect the HTML one
> url at a time... is there any way to collect, say, 10 urls at a time?
> 20 urls at a time?
> Any ideas on how I might implement this or how long it might take to
> gather the information?
> 
> Thanks,
> David Morel



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

Date: 10 Sep 2003 10:22:11 -0800
From: uj797@victoria.tc.ca (Arthur T. Murray)
Subject: Standards in Artificial Intelligence
Message-Id: <3f5f5dc3@news.victoria.tc.ca>
Keywords: AI, AI4U, artificial intelligence, standards

A webpage of proposed Standards in Artificial Intelligence is at 
http://mentifex.virtualentity.com/standard.html -- updated today.


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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


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