[13121] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 531 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 14 20:07:30 1999

Date: Sat, 14 Aug 1999 17:05:10 -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, 14 Aug 1999     Volume: 9 Number: 531

Today's topics:
    Re: Another newbie brain fart... <rick.delaney@home.com>
    Re: array and file processing <habfan2@my-deja.com>
        Automatic web links in Perl? <sunfox@sunwerx.com>
        containing results???confused <mcmike123@worldnet.att.net>
    Re: containing results???confused (brian d foy)
    Re: containing results???confused <bwalton@rochester.rr.com>
        Could someone explain these error messages?? <rhystucker@yahoo.com>
    Re: detecting if the same script is already running ? <phony@nospam.com>
    Re: How to view code as text in working cgi script (Bill Moseley)
    Re: How to view code as text in working cgi script <cassell@mail.cor.epa.gov>
    Re: Looking for gibberish generator (Anno Siegel)
    Re: mod_perl is in the Fortune 500 <elaine@chaos.wustl.edu>
    Re: mv UNIX shell command doesn't work? armatage_shanks@my-deja.com
    Re: mylib.pl now MyLib.pm <cassell@mail.cor.epa.gov>
    Re: New User Q: Shell script to Perl Equivalent <cassell@mail.cor.epa.gov>
    Re: Newbie question about $_ <elaine@chaos.wustl.edu>
    Re: Newbie question about $_ <cassell@mail.cor.epa.gov>
        Newbie-how do I get a cgi program(perl) to put +signs b <jeff@247sk8mag.com>
    Re: Please repost URL encoded directions for protected  <bwalton@rochester.rr.com>
    Re: Regexp newbie (Anno Siegel)
    Re: Regexp newbie <rick.delaney@home.com>
    Re: Search algorithm in Perl <dheera@usa.net>
        Things my math teacher forgot to tell me <jbc@shell2.la.best.com>
    Re: Why use comp.lang.python when you've got comp.lang. <dgris@moiraine.dimensional.com>
    Re: Why use Perl when we've got Python?! (John Stevens)
    Re: Why use Perl when we've got Python?! (Martijn Faassen)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Sat, 14 Aug 1999 21:23:07 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Another newbie brain fart...
Message-Id: <37B5DE24.1699838F@home.com>

[posted & mailed]

Bryon Bean wrote:
> 
> Inventory::new(\@prop_name,\@prop_value);
> 
> The Inventory constructor looks like this:
> 
> sub new {
> 
>  my ($names,$values) = @_;

It's customary to allow the constructor to be called as a method as
well, meaning the first parameter passed is the package or an object
ref.

perldoc perlobj
perldoc perltoot 

[snip]

>   $this->{"@$property_name[$i]"} = @$property_value[$i];

You won't get a warning for this like you would with a regular array,
but since you are only accessing one element of @$property_* you should
indicate that by using $ instead of @.  And lose those useless quotes.

    $this->{ $$property_name[$i] }  = $$property_value[$i];
or
    $this->{ $property_name->[$i] } = $property_value->[$i];

[snip]
 
> foreach $item(%part_number) {

You are iterating over the list of alternating keys and values of the
hash %part_number.  So every second list element is an object ref.

perldoc perldata

>  if(ref($item)) {
> 
>   print ("$item->{'descrptn'}\n");
>   print ("$item->{'wieght'}\n");
>   print ("$item->{'price'}\n");
> 
>  }
> }

Since you seem only interested in the references, which are stored in
the values of %part_number, ask for a list of the values only.

    foreach $item (values %part_number) {

or to get at both the key and value, use each

    while ( my ($name, $obj) = each %part_number) {

perldoc -f values
perldoc -f each

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 14 Aug 1999 23:38:59 GMT
From: Teacher Guy <habfan2@my-deja.com>
Subject: Re: array and file processing
Message-Id: <7p4umj$chp$1@nnrp1.deja.com>

In article <7p159j$h1j$1@news.mch.sbs.de>,
  michel.dalle@usa.net (Michel Dalle) wrote:
> In article <7outfv$c44$1@nnrp1.deja.com>, Teacher Guy <habfan2@my-
deja.com>
> wrote:
> [order of reply changed]
> >> Have a look at perllol and perldsc for more information on
> >> how to build such structures... There are some nice examples.
> >
> >I presume perllol is part of CPAN??
>
> No, it's part of the standard documentation that comes with Perl.
> Normally, if you type 'perldoc perllol', you should see the 'perllol'
> document.
>
> Or if you use the ActiveState distribution, you can also find it from
> the "Online Documentation" under "ActivePerl" in your Start Menu.
> You'll find perllol as part of the "Core Perl Docs".
>
> Same thing for 'perldoc perldsc', etc.
>
> >> What do you mean by "without screwing up order of other fields" ?
> >
> >If I sort on a field do all the other fields of record sort in sync?
>
> Yes, of course. That's the idea of keeping some data structure...
>
> >MY DATA IS AS FOLLOWS:
> >
> >stud1|4|10|course1
> [snip]
> >Thus, $testave = $score/$tottest
> >
> >then I need the $testave to serve as index to sort all incoming data.
>
> OK, so calculate the average while you're reading each line (see
below),
> or do it when you're sorting (but that's a bit more complex).
>
> >> And can the same student appear several times, e.g. for several
> >courses ?
> >
> >Yes, a future consideration for sure.
> >
> >> And should the average be the average of the ten top scores, or the
> >> average of all courses followed by the top 10 students ?
> >
> >Top 10 average test (percent) results for all incoming data.
>
> You'll have to decide now whether you want just the top 10 scores, or
the
> 10 students with the top scores, or the 10 students with the highest
average
> scores, or ... Your data structure may be totally different if this
is a
> requirement.
>
> >Thank you very much for the help and I'd appreciate any enlightenment
> >that you can offer.
>
> First, have a look at the two documents above. Then think hard about
> exactly what you want to calculate, sort, print, save etc.
>
> Here is one way to get the top 10 students with their respective
> (sorted) scores : (watch out for line wrapping in the newsreader)
> But remember, there's more than one way to do it :-)
>
> #!/usr/local/bin/perl -w
> use strict;
> my(%hash,%topscore);

I have a couple of syntax questions:
Why do you use "my"?

> while (<DATA>) {
>         chomp;
>         my ($student,$score,$tottest,$course) = split(/\|/);
> # calculate percentage (and show with 1 digit precision)
>         my $percent = sprintf("%.1f",$score/$tottest*100);
>         $hash{$student}{$course} = $percent;
> }

What are you assigning $percent to actually?
What is difference between $hash{$student} and $hash{$stud}?
Why do you choose $student and $course when you assign $percent to
$hash?


> #
> # get the top score of each student
> #
> foreach my $stud (keys %hash) {
>         $topscore{$stud} = (sort {$b <=> $a} values %{$hash{$stud}})
[0];
> }
> #
> # sort the students by top score (top 10)
> #
> my $maxidx = keys %topscore;
> $maxidx = $maxidx > 10 ? 9 : $maxidx - 1;

What is "10 ? 9" ............

> foreach my $stud ((sort {$topscore{$b} <=> $topscore{$a}} keys %
topscore)[0 ..
> $maxidx]) {
>         print "$stud --> $topscore{$stud}\n";
>         foreach my $course (sort {$hash{$stud}{$b} <=> $hash{$stud}
{$a}} keys
> %{$hash{$stud}}) {
>                 print "\t$course : $hash{$stud}{$course}\n";
>         }
> }

Q on keys:

keys %$hash{stud}{$course}   <--- a hash of hashes??



> exit;
> __DATA__
> stud1|4|10|course1
> stud1|20|60|course2
> stud1|50|80|course3
> stud2|90|120|course1
> stud2|8|10|course2
> stud2|7|10|course3
> stud3|85|180|course1
> stud3|70|110|course2
> stud3|62|80|course3
> stud4|32|35|course1
> stud4|6|15|course2
> stud4|5|5|course3
>
> This uses a hash of hashes for the input data, and a simple hash for
the
> top score per student. Notice that this is very much oriented towards
> using 'student' as primary key. If you'll also need to loop over the
> different courses and get the top students per course etc., you may
> want to use a more 'neutral' data structure like an array of arrays.
>
> But this is probablly getting way beyond your assignment anyway :-)
>
> Michel.
>



Again, thank you for your insight.

Kiley


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Sat, 14 Aug 1999 23:32:52 GMT
From: "Sunfox" <sunfox@sunwerx.com>
Subject: Automatic web links in Perl?
Message-Id: <E0nt3.83228$U42.108670@news1.rdc1.bc.home.com>

I'm trying to search a string variable containing several 'basic' URLs. For
example,

"I was on http://www.microsoft.com yesterday and it linked me to
http://www.windows95.com."

I'd like to be able to create hotlinks out of each of those. I figure what I
have to do is search for all references to http://, take the entire string
thereafter in a new variable, say http://www.microsoft.com, and then
search/replace so it prints the full A HREF tag.

Unfortunately, I have no clue as to how to do this properly, especially if
there are multiple addresses in a single string. I'm still quite new to
Perl, but so far am very pleased at the results. I've been fairly
self-sufficient up until now with my reference book, but this one has eluded
me for weeks now and I'm going crazy trying to figure it out. Can anyone
point me in the right direction?

Thanks very much!




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

Date: Sat, 14 Aug 1999 17:52:34 -0400
From: "mike" <mcmike123@worldnet.att.net>
Subject: containing results???confused
Message-Id: <7p4od3$5qs$1@bgtnsc03.worldnet.att.net>

I can see how you could write a script to send keyword searches to a search
engine like altivista or excite but how can you contain the results, What im
trying to do is send a query to a search engine and get the results back
into my own search result page. A guy at work said it could be done in about
an hour but i haven't seen it. and im failing misserabley at my attempts.
please post a solution to this dillema.




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

Date: Sat, 14 Aug 1999 18:53:45 -0400
From: brian@pm.org (brian d foy)
Subject: Re: containing results???confused
Message-Id: <brian-ya02408000R1408991853450001@news.panix.com>

In article <7p4od3$5qs$1@bgtnsc03.worldnet.att.net>, "mike" <mcmike123@worldnet.att.net> posted:

> I can see how you could write a script to send keyword searches to a search
> engine like altivista or excite but how can you contain the results, What im
> trying to do is send a query to a search engine and get the results back
> into my own search result page. A guy at work said it could be done in about
> an hour but i haven't seen it. and im failing misserabley at my attempts.

* make the query.

* put the response data in a string.

* munge the string, perhaps with HTML::Parser or some such.

* display the results.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: Sat, 14 Aug 1999 19:05:36 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: containing results???confused
Message-Id: <37B5F640.66EA988A@rochester.rr.com>

mike wrote:

> I can see how you could write a script to send keyword searches to a search
> engine like altivista or excite but how can you contain the results, What im
> trying to do is send a query to a search engine and get the results back
> into my own search result page. A guy at work said it could be done in about
> an hour but i haven't seen it. and im failing misserabley at my attempts.
> please post a solution to this dillema.

Mike, actually, it can be done in about 10 seconds:

use LWP::Simple;
$content=get("http://www.altavista.com/cgi-bin/query?pg=q&kl=XX&stype=stext&q=mike");

print $content;

will get the contents of Altavista's first page on "Mike" in variable $content,
and then print it.



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

Date: Sun, 15 Aug 1999 00:09:12 +0000
From: rhys <rhystucker@yahoo.com>
Subject: Could someone explain these error messages??
Message-Id: <934675875.998892370@news.freenet.co.uk>

I'm a newbie to Perl - could someone please explain these error messages. The
url I'm trying to pass to referer looks fine to me. What's happening?

Uncaught exception from user code:
	Unexpected field value http://www.oracle.com/appserver/ at /usr/lib/perl5/site_perl/5.005/HTTP/Message.pm line 189
	Carp::croak ('Unexpected field value http://www.oracle.com/appserver/') called at  /usr/lib/perl5/site_perl/5.005/HTTP/Headers.pm line 162
	HTTP::Headers::referer('HTTP::Headers=HASH(0x83e5d3c)', 'http://www.oracle.com/appserver/') called at /usr/lib/perl5/site_perl/5.005/HTTP/Message.pm line 189
	HTTP::Message::AUTOLOAD('HTTP::Request=HASH(0x8443454)', 'http://www.oracle.com/appserver/') called at tebot2.3htb line 45

	

if (defined $referer{$url})	{	
			$ref = $referer{$url};
			$req->referer($ref);			# this line 45
	 			}



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

Date: 14 Aug 1999 23:01:20 GMT
From: "Bart Simpson" <phony@nospam.com>
Subject: Re: detecting if the same script is already running ?
Message-Id: <7p4sg0$681$0@216.39.133.1>


<marcza@my-deja.com> wrote in message news:7p3ocp$jpr$1@nnrp1.deja.com...
<snip, removed code>
> Now someone is either starting this script or a second instance of it
> (again).
> How do I check if another instance of this same script is already
> running (or currently in sleep mode) ? ->In this case the script should
> exit.
>

Create a flag file before sleeping.  When the script first runs, if the flag
file exists, exit.

You could flock a flag file instead, then if the script is run again, when
it reaches the flock line, it will sit and wait for the first to finish.




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

Date: Sat, 14 Aug 1999 14:51:02 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: How to view code as text in working cgi script
Message-Id: <MPG.121f84a49d4e2d449896b6@nntp1.ba.best.com>

Warren Bell (resource@ERASEjps.net) seems to say...
> How can I call a cgi program on the web to see it's code?  Is there a
> way to do this? Any adjustments I can do to my browser?

Try the contrast knob on your monitor.


No, you can't do what you want.


-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Sat, 14 Aug 1999 15:09:06 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to view code as text in working cgi script
Message-Id: <37B5E902.F3BF7B31@mail.cor.epa.gov>

Warren Bell wrote:
> 
> How can I call a cgi program on the web to see it's code?  Is there a
> way to do this? Any adjustments I can do to my browser?
> 
> Can you do this with Unix, I've got wget and lynx?

In general, you can't see more than what is visible if you
just use your browser and have it show the page source.

If that's what you want to snag, you could use lynx or wget,
or you could use the LWP::Simple module.

If you want more than that, you might have to look for a
URL where the site lets people look at specific chunks of
their code.  Or e-mail the webmaster and politely ask for
a copy of the code.  Or else try the infamous PSI::ESP 
module.  :-)

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 14 Aug 1999 22:51:20 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Looking for gibberish generator
Message-Id: <7p4rt8$uba$1@lublin.zrz.tu-berlin.de>

Elaine -HFB- Ashton  <elaine@chaos.wustl.edu> wrote in comp.lang.perl.misc:
>Kim Eggleston wrote:
> 
>> These Markov Chains... never heard of that.. what are they?
>
>http://dimacs.rutgers.edu/~dbwilson/exact/
>
>This might help. 

_The Practice of Programming_ (Kernighan, Pike) has an example of
Markov chains over arbitrary text done in Perl.  It's about 20 lines.

Anno


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

Date: Sat, 14 Aug 1999 17:41:34 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: mod_perl is in the Fortune 500
Message-Id: <37B5E275.50D26AF8@chaos.wustl.edu>

brian d foy wrote:
> 
> after a quick server of the web servers of the Fortune 500 companies,
> i found several using mod_perl:

Who needs the fortune 500 when the Atlantic Monthly (Sept.) carries an
article about Linux? ;) Reasonably done no less.

And mod_perl isn't a good metric for Perl usage as companies often don't
run their own web servers and leave it to places like GTEI who are owned
by Netscape Enterprise Server. However, GTEI uses Perl extensively, or
did, in managing the servers, etc and I'm sure many other SysAdmins are
hidden in a cube in each of these companies thanking heaven for 7-11 and
Perl. 

You should cross post the original list to a few of the Unix Admin
groups. Perl, it ain't just for the web. :)

e.


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

Date: Sat, 14 Aug 1999 22:55:38 GMT
From: armatage_shanks@my-deja.com
Subject: Re: mv UNIX shell command doesn't work?
Message-Id: <7p4s57$b34$1@nnrp1.deja.com>

Obviously your up on the names of toilet companyies in the UK. Great!
Wonderful nationalistic spirit and all, but my name comes from a song by
a band in the US.  A play on words on the name of the aforementioned
toilet company.  But thanks for the tip, there Guy.

-armatage shanks


In article <slrn7rbm8a.f53.M.Ray@carlova.ulcc.ac.uk>,
  M.Ray@ulcc.ac.uk (Malcolm Ray) wrote:
> On Sat, 14 Aug 1999 20:33:10 GMT, armatage_shanks@my-deja.com
> <armatage_shanks@my-deja.com> wrote:
> >Hello, I am having a little problem with the mv command in the
snippet
> >of code below:
> >
> >
> >foreach $file (@Filename) {
> >        @newName = split("_", $file);
> >            foreach $list (@List) {
> >                if ($newName[0] =~ /$list/) {
> >                $rightFile = join("_", @newName);
> >                print "Great! $rightFile\n";
> >                `mv $rightFile .$rightFile`;
> >                last;
> >                }else{
> >                print "Ugggg!\n";
> >                print "$newName[0]\n";
> >
> >            }
> >        }
> >    }
> >
> >
> >When I run my prog. I get this shell error:
> >
> >mv: missing file argument
> >Try `mv --help' for more information.
> >sh: .falcon.txt: command not found
> >
> >
> >All I am doing is putting the contents of an "ls" command into an
array,
> >splitting the filenames that have an underscore, and matching the
first
> >part of the filename against another list I genarated.
>
> You have forgotten to get rid of the newlines.  Before the first line
> of the code shown above, add this:
>
> chomp @Filename;
>
> BTW, you ought to read up on the significance of backticks in perlop,
> since the line above renaming the file is pretty bogus.  In any case,
> it would be better to do:
>
> rename($rightFile, ".$rightFile") or die "Error renaming $rightFile:
$!";
>
> You might also like to check out the opendir and readdir functions.
>
> Oh, and you've misspelled 'Armitage'!
> --
> Malcolm Ray                           University of London Computer
Centre
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Sat, 14 Aug 1999 15:03:32 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: mylib.pl now MyLib.pm
Message-Id: <37B5E7B4.42E0AF5F@mail.cor.epa.gov>

Nick Downey wrote:
[here's an un-attributed response from Rick Delaney:]
> > I'm not sure what this gains you, since you still have to type them.
> > Anyway, the goal is to get the symbol names into @EXPORT (though you
> > really should read what the docs on Exporter have to say about this).
> >
> > You do this in any way that you get elements in an array.
> 
> Thanks Rick,
> 
> Why do I want to do it that way, well style I guess. I want the finished
> result to be clean and aesthetically pleasing to people who are going to
> use the module down the road.
> 
> I have over 50 constant strings and I will gladly take suggestions on how
> to format the text of the export statement to accommodate those constants
> in a readable fashion.

I tend to group in logical chunks when I have a lot of stuff
to shove into qw// as in this silly example:

@EXPORT = qw (
    CONST1 CONST2 CONST3 CONST4
    STRING1 STRING2 STRING3
    LABEL_A LABEL_B LABEL_C LABEL_D LABEL_E
    FILENAME01 FILENAME02 FILENAME03
    DIRNAME01
    BADWORDS1 BADWORDS2
    );

But it's usually a matter of personal preference.

> I appreciate your pointing out my obvious error all the same.
> 
> What is "OW", Oh Well?

One Way.  From TMTOWTDI == There's More Than One Way To Do It.
 
HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Sat, 14 Aug 1999 15:05:14 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: New User Q: Shell script to Perl Equivalent
Message-Id: <37B5E81A.2FBC70C2@mail.cor.epa.gov>

Uri Guttman wrote:
> 
> >>>>> "KN" == Kevin Newman <knewman@mcs.com> writes:
> 
>   KN> What is the perl equivalent of the following shell statement
> 
>   KN> executable <<EOD
>   KN> command1
>   KN> command2
>   KN> EOD
> 
> just use system and here docs:
> 
>         system( <<EOD ) ;
> command1
> command2
> EOD

Or else review one's code, change shell statements to
Perl functions, change the shell pipe-mentality structure
to something better, and get big increases in speed for
your efforts...

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Sat, 14 Aug 1999 17:35:42 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: Newbie question about $_
Message-Id: <37B5E115.7AE4A7E1@chaos.wustl.edu>

Ronald J Kimball wrote:
> >   A> Danger, Will Robinson, danger! Exterminate! Exterminate! Exterminate!
> >
> > lost in space; nomad the son of kirk space probe;
> 
> No, the Daleks in Dr. Who.

Don't forget Robby the Robot from Lost in Space. Unless the Daleks made
a guest appearance to rid the show of Dr. Smith. :)

> >   A> Fear is the path
> >   A> to the dark side. Fear leads to anger. Anger leads to hate. Hate leads
> >   A> to suffering. I sense much fear in you.
> 
> SW: The Phantom Menace.

Close...but it was The Empire Strikes Back...Yoda speaking to Luke in
the hut. 

e.


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

Date: Sat, 14 Aug 1999 15:20:16 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Newbie question about $_
Message-Id: <37B5EBA0.D05B05A2@mail.cor.epa.gov>

Elaine -HFB- Ashton wrote:
> 
> Ronald J Kimball wrote:
> > >   A> Danger, Will Robinson, danger! Exterminate! Exterminate! Exterminate!
[snip]
> Don't forget Robby the Robot from Lost in Space. Unless the Daleks made
> a guest appearance to rid the show of Dr. Smith. :)

We should have been so lucky.

<Jonathan Harris>
Oh!  The pain!  The pain!
</Jonathan Harris>
 
> > >   A> Fear is the path
> > >   A> to the dark side. Fear leads to anger. Anger leads to hate. Hate leads
> > >   A> to suffering. I sense much fear in you.
> >
> > SW: The Phantom Menace.
> 
> Close...but it was The Empire Strikes Back...Yoda speaking to Luke in
> the hut.

I thought it was TomC replying to a flamed newbie.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Sat, 14 Aug 1999 17:53:18 -0500
From: "twentyfour seven" <jeff@247sk8mag.com>
Subject: Newbie-how do I get a cgi program(perl) to put +signs between keyword search terms?
Message-Id: <37b5e6e6.0@news.advancenet.net>

I recently installed SFE search from http://www.hostfacts.com/scripts/ . It
works good, Iike it alot. Except whenever I put in more than one word in the
search box. It will only show one page of results. When I attempt to hit
next (at the bottom of the page) It will take the +sign out from in between
the two words and I'll get an error message about malformed syntax. I am on
an NT server.

Thank you
Jeff Turner


--
[--Twentyfour seven online skateboarding magazine--]
URL: http://www.247sk8mag.com
email: jeff@247sk8mag.com




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

Date: Sat, 14 Aug 1999 18:51:13 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Please repost URL encoded directions for protected directories
Message-Id: <37B5F2E0.474ADB70@rochester.rr.com>

>

 ...

> how to allow people access to
> your protected directories without requiring the user to use the
> htaccess login
>
> something like
>
> http://userid:@pasword:www.yourdomain.com/protected_directory/
>

 ...
Although it has absolutely nothing to do with Perl:

http://userid:password@www.whatever.com/directory

or

ftp://userid:password@www.whatever.com/directory




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

Date: 14 Aug 1999 21:31:45 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regexp newbie
Message-Id: <7p4n81$u8r$1@lublin.zrz.tu-berlin.de>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in comp.lang.perl.misc:

[replacing all leading blanks by a string]

>s/^( +)/$string x length $1/e;

If anyone still cares...

The above is still a bit unsatisfactory, the /e modifier doesn't look
right for this simple problem.  Of course, if we had variable length
lookbehind zero width assertions, (or left context, as I'd prefer to
say), the immediate solution would be

s/(?<=^ *) /$string/g

that is, replace each blank that follows a chain of blanks that stretch
to the start of the string.  But all we get is "variable length
lookbehind not implemented", which is hope-inspiring and disappointing
at the same time.

But _Effective Perl Programming_ offers this:

s/\G /$string/g

which is even shorter, though a bit obscure.  It does have the
advantage of working with current perls though.  EPP attributes it
to Randal, in reply to a question on this very newsgroup back in
1996, so it's come a long way.

Anno


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

Date: Sat, 14 Aug 1999 21:46:58 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Regexp newbie
Message-Id: <37B5E3BB.CD18773D@home.com>

[posted & mailed]

Anno Siegel wrote:
> 
> But _Effective Perl Programming_ offers this:
> 
> s/\G /$string/g
> 
> which is even shorter, though a bit obscure.  It does have the
> advantage of working with current perls though.  EPP attributes it
> to Randal, in reply to a question on this very newsgroup back in
> 1996, so it's come a long way.

It's also in perlfaq6

    What good is \G in a regular expression?

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 14 Aug 1999 22:41:33 GMT
From: Dheera <dheera@usa.net>
Subject: Re: Search algorithm in Perl
Message-Id: <7p4ras$ako$1@nnrp1.deja.com>

Thanks for your help guys. May I please make one more request - on the
modules themselves? I tried to download the Search::InvertedIndex, or
the DBFile modules, but they simply created Makefiles.

I do not run Linux - I am running the Win32 version of Perl on Windows
98. Could you please direct me on how to dissect the makefile to get
the module working with Windows?

Thanks a lot,
Dheera
dheera@usa.net


In article <V%Hs3.201$DI3.19834@typhoon01.swbell.net>,
  snowhare@long-lake.nihongo.org (Benjamin Franz) wrote:
> In article <7oarns$dng$1@nnrp1.deja.com>, Dheera  <dheera@my-
deja.com> wrote:
> >Hi,
> >  I'm trying to build a search-engine (in Perl) which can search
about
> >1 million database records in less than 1 second (if possible) on my
hz
> >Pentium II.
> >  I can afford to use upto 8 GB for this size of database - and I
have
> >64 MB of RAM available.
> >
> >Could someone help me with what algorithms I could program, or what
> >freeware search engines are available to meet these?
> >
> >I am pretty sure it can be done - even if it takes a lot of disk
space
> >it is okay.
> >
> >I have tried using a gigantic hash table with truncation for key
> >selection, but it is quite slow... and so is ODBC.
> >
>
> Look at the 'Search::InvertedIndex' module on CPAN
<URL:http://www.cpan.org/>.
> It is designed for precisely this kind of problem.
>
> --
> Benjamin Franz
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 14 Aug 1999 23:57:19 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Things my math teacher forgot to tell me
Message-Id: <37b6025f$0$199@nntp1.ba.best.com>

Disclaimer: Nothing to do with Perl. Followups to that effect endured
silently, with head hung low.

There are some mathematical subjects that got short shrift in the math
classes I attended many years ago, but which seem to be so basic for
Perl professionals that they get passed over pretty lightly in the
documentation. I get the impression that these are mostly things
covered in any first-year computer science curriculum, but which I, by
virtue of my Perl-as-a-0th-language script-kiddiehood, have mostly
missed out on. I'd appreciate pointers to more appropriate groups to
ask about such things (newbie-tolerant general programming
newsgroups?), as well as recommendations of good books (or other
resources) for filling in those gaps in my knowledge.

Examples of what I'm talking about are the modulus operator (%) (which
is actually described more or less completely in perlop, so it's
probably not the best example), and the specific meanings of terms for
different number representations, like signed vs. unsigned integers. My
assumption in reading the perlfunc documentation for sprintf, for
example, is that an unsigned integer is just an integer treated without
regard for whether it is positive or negative, or something like that.
But I'm nervous about trying to map my own naive interpretations onto
specific technical language when I lack the background that the writer
(by virtue of such statements as "the following universally-known
conversions") obviously assumes that I have.

I don't know; it's also possible that I'm being too cautious in
worrying about such things. Sometimes language just means what it
sounds like, even when experts intone it with that special emphasis
that gives newbies pause. Like Garp's son, going around in fear of the
dreaded Under-toad, I spent the longest time in terror of invoking the
much-warned-against Race Condition, picturing some horrible low-level
malfunctioning of the computer, like a steam engine without its
governor spinning out of control. When I finally realized what the term
actually meant it was quite a relief.

This is silly, I know. But new immigrants often look silly as they try
to contend with the unfamiliar ways of their new environment. Like I
said, any pointers on how to address my remedial educational needs will
be appreciated.

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: 14 Aug 1999 15:23:29 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Why use comp.lang.python when you've got comp.lang.perl.misc?
Message-Id: <m3ogga6oq6.fsf@moiraine.dimensional.com>

Christian Tismer <tismer@appliedbiometrics.com> writes:

<snip>
> I see that someone of the perl newsgroup managed to
> post about 35 messages in just a couple of minutes
> both to comp.lang.python and comp.lang.perl.misc .

I just want to point out that the troll who dumped all of these
crossposts is the person advocating Python in this thread.  The
perlers have been reasonable, thoughtful, and respectful through 
most of this.

<super-snip>

dgris
-- 
To program is to be.


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

Date: Sat, 14 Aug 1999 21:45:04 GMT
From: jstevens@bamboo.verinet.com (John Stevens)
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <slrn7rbor0.6b2.jstevens@bamboo.verinet.com>

On Sat, 14 Aug 1999 11:39:14 GMT, Dave <dave@see.sig.for.address> wrote:
>John, please refrain from cross-posting all your messages to
>comp.lang.python.

I didn't cross post.  I responded to somebody who cross posted.

I never add or remove news groups from the list.

>The 'my language is better than yours' debates are always pointless
>and counterproductive,

Not always.  Such a thread lead me to Python in the first place.

You may be cursing your unlucky stars that that occurred, but
such is life! :-)

>Incidentally you are wrong about perl arrays and python lists being
>different data structures - internally they are both implemented as C
>arrays, only the names are different. 

Which is equivalent to saying that all languages are identical,
because they all end up being machine code, in the end.

Sorry, but that is an over simplification.

>All great ideas start as heresy and end as dogma.

Yes.  The thought that it is actually possible to make objective
measurements and from those measurements determine that one programming
language really *IS* better than another language for a given set
of tasks or environments is, currently (Obviously! ;-> )

HERESY.

;_>

John S


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

Date: 14 Aug 1999 23:40:42 GMT
From: m.faassen@vet.uu.nl (Martijn Faassen)
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <7p4upr$kre$2@newshost.accu.uu.nl>

Sean McAfee <mcafee@waits.facilities.med.umich.edu> wrote:
> In article <37AAFAD1.A032765B@NOSPAM.strs.co.uk>,
> Ian Clarke  <I.Clarke@NOSPAM.strs.co.uk> wrote:
>>I know this sounds like flame-bait, but I am genuinely curious as to
>>what Perl might have to offer that Python doesn't.

> Here's one anecdotal data point:

[snip Perl FTP example]
> I began the conversion by looking for an FTP module for Python.  It turns
> out that one comes with the standard distribution.  I began reading the
> documentation for the module, and before long I couldn't believe what I was
> reading.  You actually have to know the FTP protocol to use Python's FTP
> module!  You need to open your own destination file and send a command to the
> remote FTP server by calling ftp.retrlines('RETR ' + filename, myfile.write).
> Ridiculous!  Modules are supposed to hide such implementation details from
> the user, not force the user to deal with them.

Agreed. I wrote a SimpleFTP module that hides implementation details
for that (unreleased and slightly buggy :). There ought to be something like
that in the standard distribution.

> Meanwhile, Perl's FTP
> module uses essentially the same interface as the "ftp" program I've always
> used.

Which is completely intuitive and easy, and anybody new to ftp programs on
the command line (having used a GUI), could instantly grasp what's going
on. :)

But I agree that for you and me using the same interface is easier.

Anyway, this is one datapoint. I'm sure one can find examples that work
the other way around.

> As for why I use Perl, one reason is that I often need to perform small
> data-munging tasks that can often be done in one line or less of Perl.

[snip one liner examples]

> Even Python advocates concede that Python isn't well-suited to one-liners
> like this.  Well, guess what?  I use one-liners more often than I write
> larger, more permanent programs.

Conceded readily. :)

> Oh, and there's also the fact that Perl is faster than Python at darn near
> everything.  That's the icing on the cake.

I don't think it's entirely correct; the comparison is not that simple.
Benchmarks are difficult to do right, as everybody knows.
Though it is true that Perl is faster than Python in quite a few areas, 
especially when munging through text. Your description of 'icing' seems
correct.

Regards,

Martijn



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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu. 

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 V9 Issue 531
*************************************


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