[12064] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5664 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 14 15:07:31 1999

Date: Fri, 14 May 99 12:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 14 May 1999     Volume: 8 Number: 5664

Today's topics:
    Re: calling runtime added functions (Andrew Allen)
    Re: Conditional search and replace within a text file <revjack@radix.net>
        Conference for Win NT System Management (Especially UNI (Jennifer Radtke)
    Re: Cperl mode on NTEmacs help. Also simple newbie perl <cassell@mail.cor.epa.gov>
    Re: FAQ 4.14: How can I find the Julian Day? <cassell@mail.cor.epa.gov>
    Re: Finding x^y? <dhenders@cpsgroup.com>
    Re: Finding x^y? <tchrist@mox.perl.com>
    Re: GETting a Web-Site with IO::Socket::INET <dhenders@cpsgroup.com>
    Re: I need some help (Randal L. Schwartz)
        Locks on DBM Hashes manju5405@my-dejanews.com
    Re: Perl "constructors" <cassell@mail.cor.epa.gov>
    Re: perlscript ADO problems (DSN) <jwarner@tivoli.com>
    Re: PerlSjop Mailing List <cassell@mail.cor.epa.gov>
    Re: read file assign variables (Larry Rosler)
    Re: REGULAR EXPRESSION Problem 2 <cassell@mail.cor.epa.gov>
    Re: SimNet - Perl proxy governor project (Randal L. Schwartz)
        Small amount of Perl CGI script work needed for site. (Mike Arndt)
    Re: Small amount of Perl CGI script work needed for sit dalehend@flash.net
    Re: Sorting is too slow for finding top N keys... - GOT (Larry Rosler)
        Using cmp on data fetched via Odbc <Bradford.Trainham@m1.irs.gov>
    Re: Which book do you recommend? (Charles R. Thompson)
    Re: Win32::Process question (Michel Dalle)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 14 May 1999 18:09:27 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: calling runtime added functions
Message-Id: <7hhosn$psu$1@fcnews.fc.hp.com>

Ben (neb@one.net) wrote:
: I am adding a function with the Safe package which I need to
: call with a argument later on in order to continue my program.
: I am currently doing something like this:

: foreach ...... (&{$::{$nameofcall}}($argument)) {..etc.

ech.. i'd probably write:

no strict 'refs';
&{$nameofcall}($argument);

The more I mess around with namespace hashes, the more I fear (and
understand) them.  They're weird. You can't modify them and have them
work like you want. The syntax is baroque at best.

: to do this.  It doesnt work when I use the Safe package.

Of course; Safe runs its code in an different namespace than main::.

: Specifically I am calling rdo on a filehandle and then checking
: to see if it has constructed a function of name with the varglob
: method.  I can't figure out how to do this correctly.

: I need the results (in a array) of the call so and I don't know the
: name ahead of time so doing something like:
: eval {
:   push @tmp, $nameofcall($argument);
: }
: doesnt seem to work.

how about:

  &{$compartment->varglob($nameofcall)}($argument);

Andrew


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

Date: 14 May 1999 18:11:33 GMT
From: Susan Africa <revjack@radix.net>
Subject: Re: Conditional search and replace within a text file
Message-Id: <7hhp0l$ms4$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight

David L. Cassell explains it all:

:My PSI::ESP module tells me that.. umm.. you're using a Perl
:older than 5.005 .

I had several telnet windows open at that time, and in the one where I
typed 'perldoc Benchmark', that system is running 5.004_04. The one where
I was doing the actual testing is running 5.005_02, and has the proper
docs. Thanks. 

As for the actual timing - I took this:

  #!/usr/local/bin/perl -w
  use strict;
  use Benchmark;
  timethis 6_000_000, q{my $line='NOTES:'; $line =~ s/^NOTES:$//}

and saved it as temp.pl, and ran thusly (under Solaris):

  time temp.pl

The results:

  timethis 6000000: 65 wallclock secs (65.47 usr +  0.00 sys = 65.47 CPU)
  
  real    1m41.482s
  user    1m40.860s
  sys     0m0.030s


As you can see, those 65 wallclock seconds took a lot longer than 65
seconds to transpire. That's why I was wondering what a wallclock second
is. 

-- 
  /~\  bumptious Corinth flycatcher occident Aztecan filthy telephotog
 C oo  summit cervix bremsstrahlung Arragon suffix Schmidt Libya These
 _( ^) 1 , 0 0 0 , 0 0 0   m o n k e y s   c a n ' t   b e   w r o n g
/___~\ http://www.radix.net/~revjack/mnj             revjack@radix.net


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

Date: Fri, 14 May 1999 17:45:54 GMT
From: jennifer@usenix.org (Jennifer Radtke)
Subject: Conference for Win NT System Management (Especially UNIX Interoperabillity)
Message-Id: <FBqHCI.A92@usenix.org>
Keywords:  USENIX, SAGE, LISA, System Administration, Windows NT, LISA NT, Training, tutorial, unix,  network management, homogeneous networks, PC, heterogeneous environments, Large-scale solutions, tools, utilities, security, software, engineering, developement, applications, debugging, Remote management, Distributed, Backups, restores, User accounts, NT Integration, high performance, Windows 2000, cross-platform distributed services, Remote access, NT tools, E-mail, domain, controller, Central name service, Software licensing, firewall, fixes, The registry, invited talks, tutorials, refereed papers, crash dump analysis, authentication, Samba servers

How to Manage, Scale & Integrate NT  (Especially with UNIX)-
The Premiere Conference for Managers of Windows NT

LISA-NT
2ND LARGE INSTALLATION SYSTEM ADMINISTRATION
OF WINDOWS NT CONFERENCE
July 14-17, 1999
Seattle, Washington, USA

(Co-Located with USENIX Windows NT Symposium, July 12-15, 1999)
----------------------------------------------------------------------
Save.  Register by June 18.
See the Program at http://www.usenix.org/events/nt99
----------------------------------------------------------------------
Sponsored by the USENIX Association
Co-sponsored by SAGE, The System Administrators Guild

Direct from Microsoft Project Leaders-What's Coming in NT
*Report From the Windows 2000 Beta Team
William Gloyeske, Team Manager, Windows 2000 Beta Team
*Inside the Microsoft Network (MSN)
Chris Pinto, Director, Information Technology Group for MSN

Keynote Address-A Perspective on NT
Kevin McGilloway, CIO, Lehman Brothers

Refereed Papers & Invited Talks-Technology to Help You Do Your Job
*Remote Administration
*Software Installation
*NFS and SMB Data Sharing
*Connectivity to NT Networks
*With special concentration on NT Security

TUTORIALS-Training in Technologies You Need to Know
July 14-15, 1999
Courses on:  *NT and UNIX Integration; ; *NT Security; ; *Internals;
*Kernel Debugging & Crash Dump Analysis; *DHCP/DNS; * COM(+) Programming
Model; *DCOM for Systems Administrators; *Perl; *Samba; *Performance
Monitoring, Benchmarking and Tuning

Plus...
NT Products Exhibition--answers from informed product reps
Interactive sessions and demonstrations
Works-in-Progress Reports
Hosted receptions and plenty of get-together time with your peers

"Deals with the "real world". Not marketing hype or expensive solutions,
just people showing and discussing tools that work. Many free!"
         Chad Conrow, Primex Aerospace Co.

"Very good program to learn how to incorporate NT and UNIX environments."
         Kevin Hansen, West Group

------------------------------------------------------------------------
The USENIX Association is a nonprofit association of scientists,
engineers, and systems administrators from around the world.  Since 1975
we've been reporting on cutting-edge software and systems developments in
an atmosphere of peer review and vendor-neutrality.  SAGE, the System
Administrators Guild, is devoted to the advancement and recognition of
system management as a profession.  USENIX and SAGE are co-sponsors of
the highly regarded LISA-System Administrators Conference.




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

Date: Fri, 14 May 1999 10:06:41 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
To: Phillip Lord <plord@hgmp.mrc.ac.uk>
Subject: Re: Cperl mode on NTEmacs help. Also simple newbie perl question
Message-Id: <373C5821.47D1E776@mail.cor.epa.gov>

[courtesy e-mail copy to poster]

Phillip Lord wrote:
> 
> >>>>> "Eric" == Eric The Read <emschwar@rmi.net> writes:
> [SNIP]
>   Eric> No shebang line (it's still useful on PoB boxen!), no -w, no
>   Eric> use strict.
> 
>   Eric> Minus several hundred for those.
> 
>         Whoops sorry about this. Actually I had those lines (well the
> -w not the use strict) but they were before my comments on how I was
> going to implement this. Quite long and not worth posting I though!

Agreed.  There's no point in showing hundreds of lines of irrelevant
code.  But many posters here have no clue about -w and `use strict;'
so lots of us tend to harp on this.  Ofttimes you will want to
actually reduce the code to a "working" 20-liner which illustrates
the problem.  Then the experts see what you did, and what you
didn't do.  [You can also make a casual aside, "I have -w and
use strict at the top of the script, but that's a hundred lines
above."]
 
> [more snippage]
>   Eric> wheel; you should be using File::Find.
> 
>         Indeed. I agree it is academic, I am trying to learn perl,
> and am trying this one out because it seemed like a nice idea. It's
> also along the lines of a tool that I wanted to make, so it seemed a
> good place to start. Clearly what I have so far aint much shakes, and
> could be done with ls, or find or even some native windows utilities,
> but Im trying to get something working which cant be done with
> either. I could even write it in one of several other languages I
> know, but I thought Id give perl a go. You can see the point in this?

It is entirely reasonable to try your hand at writing code to
mimic a module.  But you could have warned Eric that you already
knew about File::Find and were just doing this as a learning
experience.  Eric's psychic abilities are sadly limited.  Poor
kid.  :-)  You might also want to take File::Find apart once you
get your code working, and see how a Perlite wrote it.  I learn
more from studying others' code, but YMMV. 

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


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

Date: Fri, 14 May 1999 11:13:16 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
To: Tom and Gnat <perlfaq-suggestions@perl.com>
Subject: Re: FAQ 4.14: How can I find the Julian Day?
Message-Id: <373C67BC.A89A2345@mail.cor.epa.gov>

[cc to perlfaq-suggestions]

Tom Christiansen wrote:
> 
> (This excerpt from perlfaq4 - Data Manipulation
>     ($Revision: 1.46 $, $Date: 1999/04/20 18:59:53 $)
> part of the standard set of documentation included with every
> valid Perl distribution, like the one on your system.
> See also http://language.perl.com/newdocs/pod/perlfaq4.html
> if your negligent system adminstrator has been remiss in his duties.)
> 
>   How can I find the Julian Day?
> 
>     Neither Date::Manip nor Date::Calc deal with Julian days. Instead,
>     there is an example of Julian date calculation that should help you
>     in
>     http://www.perl.com/CPAN/authors/David_Muir_Sharnoff/modules/Time/J
>     ulianDay.pm.gz .

      But before you immerse yourself too deeply in this, be sure to
      verify that it is the *Julian* Day you really want.  There is too
      much confusion on this issue to cover in this FAQ.  But the term is
      applied (correctly) to a calendar now supplanted by the Gregorian
      Calendar, with the Julian Calendar failing to adjust properly for
      leap years on centennial years (among other annoyances).  The term
      is also used (incorrectly) to mean: [1] days in the Gregorian
      Calendar; and [2] days since a particular starting time or `epoch',
      usually 1970 in the Unix world and 1980 in the MS-DOS/Windows world.
      If you find that it is not the first meaning that you really want, 
      then check out the Date::Manip and Date::Calc modules.

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


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

Date: 14 May 1999 12:35:54 -0500
From: Dale Henderson <dhenders@cpsgroup.com>
Subject: Re: Finding x^y?
Message-Id: <87pv43v9j9.fsf@camel.cpsgroup.com>

>>>>> "Tom" == Tom Christiansen <tchrist@mox.perl.com> writes:

    Tom> Because it's not a FAQ.  It's just a simple operator, right
    Tom> out of the perlop manpage.  It's just basic C programming.
    Tom> If you want BASIC, you know where to find it.
     
     C programming  huh? C has no eponation operator. One has to use
     pow. The ** syntax is from Fortran.  (And the basic I learned on
     a C64 uses an eponation character that I can't reproduce on this
     keyboard :)


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

Date: 14 May 1999 12:27:56 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Finding x^y?
Message-Id: <373c6b2c@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, Dale Henderson <dhenders@cpsgroup.com> writes:
:    Tom> Because it's not a FAQ.  It's just a simple operator, right
:    Tom> out of the perlop manpage.  It's just basic C programming.
:    Tom> If you want BASIC, you know where to find it.

:     C programming  huh? C has no eponation operator. One has to use
:     pow. The ** syntax is from Fortran.  (And the basic I learned on
:     a C64 uses an eponation character that I can't reproduce on this
:     keyboard :)

The x^y is right out of C, where it means bitwise xor just as it does in Perl.  
The Fortran provenance for x**y is likewise correct.  

--tom
-- 
Can you sum up plan 9 in layman's terms? It does everything 
    Unix does only less reliably    --Ken Thompson


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

Date: 14 May 1999 11:44:15 -0500
From: Dale Henderson <dhenders@cpsgroup.com>
Subject: Re: GETting a Web-Site with IO::Socket::INET
Message-Id: <87r9ojvbxc.fsf@camel.cpsgroup.com>

>>>>> "Joe" == Joe  <keitgen@keitgen.de> writes:

    Joe> Hello, I got this far, but I would like to know how I can get
    Joe> the HTML-Code of a Web-Page and have it be printed or placed
    Joe> in a variable...


    Joe> Thanks Joe

    Joe> #!/usr/bin/perl -w
     
    Joe> use IO::Socket;

    Joe> $url = "http://www.yahoo.com";

    Joe> $this_socket = IO::Socket::INET->new (PeerAddr => $url,
    Joe>                                 Timeout => '9',
    Joe>                                 PeerPort => 'http(80)',
    Joe>                                 Proto => 'tcp');

    Joe> $get_request = ("GET $url HTTP/1.0\r\n" .  
    Joe> "Content-type:application/x-www-form-urlencoded\r\n");
     
     Try adding another "\r\n"; it requires a blank line to end the
     request.      

    Joe> $test = $this_socket->print ($get_request); print $test;

     I would recomend (as others have) using LWP.



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

Date: 14 May 1999 10:27:55 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: I need some help
Message-Id: <m1k8ub5zok.fsf@halfdome.holdit.com>

>>>>> "tex2121" == tex2121  <tex2121@my-dejanews.com> writes:

tex2121>  I am trying to write a Perl program that displays the n most freqent m
tex2121> word sequences in an arbitrary number of input files. n , m and the
tex2121> input file names should be specified on the command line.  The program
tex2121> should display the word sequences as well as the count of the number of
tex2121> times each occurs in the input files. The format of the command line
tex2121> arguments should be as follows:

tex2121> Program n m [list of input files]

tex2121> Also disreguard punctuation, case sensitivity numbers.

tex2121> I am stuck on how to start this problem.  I have not done much
tex2121> programing in perl, other than some tests of stuff that I am reading
tex2121> from a book I have. Any ideas would be appreciated.  Thanks

It was determined on alt.perl that this was a homework problem.
Let's not be helping the poor student, please. :(

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Fri, 14 May 1999 18:15:38 GMT
From: manju5405@my-dejanews.com
Subject: Locks on DBM Hashes
Message-Id: <7hhp84$ikj$1@nnrp1.deja.com>

How do I obtain locks on DBM hashes?



***************************************
---- Give the world the best you have
---- And the best comes back to you
***************************************


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


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

Date: Fri, 14 May 1999 11:50:13 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Perl "constructors"
Message-Id: <373C7065.B83251D3@mail.cor.epa.gov>

armchair@my-dejanews.com wrote:
> 
> I think it is a questionable "feature" of Perl that the user can define
> any name for an object constructor.

I like to name mine 'Fred'.

> I think this should be changed.

Okay, from now on I'll call it 'Barney'.  But Wilma may become
quite upset about this.  Not to mention poor little Pebbles.
I think you're being quite heartless about this.

>                                                              And
> an object should be able to consist of more than just a reference.

Well, it's also a dessert topping.  And a floor wax!

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


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

Date: Fri, 14 May 1999 13:47:56 -0500
From: John Warner <jwarner@tivoli.com>
Subject: Re: perlscript ADO problems (DSN)
Message-Id: <373C6FDC.667240FA@tivoli.com>

Your error message is telling you that it doesn't like the fact that you
didn't provide a user name and password to access SQL server and SQL server
doesn't know to trust where you are coming from.  Do you have to use an ADO
connection for this project?  I prefer to use DBI and the appropriate DBD
module as I tend to work with a variety of db types.  Using DBI and DBD
simplifies my life.

The DBI/DBD equivalent to your code below is:

use DBI;
use DBD::Oracle;  #...or whatever DB you are using.  I use Oracle and Sybase
a lot

# read in values for DBI->connect params

 die "Cannot do \$dbh->connect: $DBI::errstr\n" unless $dbh =
DBI->connect($srvr,$uname,$upwd,$dbtype);

You may need to use the DBD:Sybase module to access your MS SQL server if
you can't find a DBD module specifically for MS SQL.  (MS SQL server is
based on Sybase 10 which is why it should work.)

lamj@softhome.net wrote:

> I have a problem with my perlscript that connects to a DSN (MSSQL7)
>
> Part of my code:
> ------------------------------------
> my $SQL = "SELECT * FROM tablename";
> my $DSN = "dsnnamehere";
> my $Connection=$Server->CreateObject("ADODB.Connection");
> $Connection->Open($DSN) || die "Can't find DSN";
> my $Result = $Connection->Execute($SQL);
> ------------------------------------
>
> Problem is with DSN, it cannot connect to this DSN. Trace on the server
> side is:
>
> DIAG [37000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed
> for user '(null)'. Reason: Not associated with a trusted SQL Server
> connection. (18452)
>
> Obviously, this is the problem of no username being passed to the
> server, my question is how do I pass username and passwd in the
> perlscript, or should i do it that way? Can't I set the passwd in the
> dsn data source settings so I don't have to mess around with it in the
> perlscript.
>
> Any help is greatly appreciated.
>
> Jason Lam
>
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---

--

John Warner                           Tivoli Systems Inc.
Sales Support Engineer           9442 Capital Of Texas Hwy North
Sales Infrastructure Group       Austin, TX 78759
john_warner@tivoli.com




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

Date: Fri, 14 May 1999 11:32:18 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
To: Debbie Doerrlamm <wkdwich@unix.asb.com>
Subject: Re: PerlSjop Mailing List
Message-Id: <373C6C32.C5371375@mail.cor.epa.gov>

[courtesy cc to newsgroup]

Debbie Doerrlamm wrote:
> 
> After reading some of the obnoxious nasty replies to plea of help on
> PerlShop here, I decided to set up a mailing list for dicussion and
> trouble shooting.
> The list can be subscribed to by sending a blank email to:
> perlshop-subscribe@topica.com

Debbie,
    That is extremely considerate of you.  Would you take it
amiss if in future I directed some PerlShop questioners here to
your listserv?  There is usually not anyone around in this ng
who works with PerlShop, and hence your odds of getting good
support are not high.  For instance, I have never even seen the
code, much less tried to download or use it.
    And, while you may have found some of the posters rather
rude, that usually indicates that someone has done something
which offended *them* in the first place.  Please try to be
as considerate of the regular posters here as you are being
with users of PerlShop. 

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


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

Date: Fri, 14 May 1999 10:59:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: read file assign variables
Message-Id: <MPG.11a60478ea1f3ccc989a64@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7hhdg1$86u$1@nnrp1.deja.com> on Fri, 14 May 1999 14:54:58 
GMT, mikecard@my-dejanews.com <mikecard@my-dejanews.com> says...
> i changed the code as larry suggested and it worked great...then i
> thought i'd get all fancy and create a hash and output all hashes as
> formatted HTML.   I had it working and then i broke it and i cannot
> figure out how i broke it.

You broke it by having an extra (blank) line at the end of the input!

> the script is:
> 
> #!/usr/bin/perl -w
> 
> my ($link, $description);
> 
> open (LINKS, "linkdata.txt") or die "can't open file\n";
> until (eof LINKS) {
> 	chomp ($link = <LINKS>);
> 	chomp ($description = <LINKS>);
> 	$link_list{$link} = $description;
> }
> close LINKS;
> 
> foreach $key (keys (%link_list)) {
> 	print "<a href=\"http://www.$key\">$key</a>\n";
> 	print "\&nbsp\;$link_list{$key}<br><br>\n";
> }
> #end
> 
> 
> the "linkdata.txt is a text document like this:
> 
> mike.org
> mikes place, come here if you want its cool
> my.com
> go here you'll be glad you did
> 
> when i run this i get this error:
> 
> Use of uninitialized value at links.cgi line 8, <LINKS> chunk 5.
> <a href="http://www."></a>
> Use of uninitialized value at links.cgi line 16.
> &nbsp;<br><br>
> 
> then it outputs the entries in the text document as wanted:
> 
> <a href="http://www.my.com">my.com</a>
> &nbsp;go here its cool<br><br>
> <a href="http://www.firefighting.org">firefighting.org</a>
> &nbsp;resource of fire departments, fundraising campaigns, and
> more<br><br>
> 
> am i doing something stupid again?

Recall that I said that my fix to your code wasn't 'the best way' to do 
it.  Now you see why.

The best way is to read each line and test whether it is there right 
away, instead of reading and testing pairs of lines.

#!/usr/bin/perl -w
# Good, but there is still no 'use strict;' here!
use strict;
 
my ($link, $description);
# Good.  'use strict;' likes declarations of all variables.  So:
my %link_list;

open (LINKS, "linkdata.txt") or die "can't open file\n";
# Good, but there is still no $! in the diagnostic.

while () {
    defined ($link = <LINKS>) or last;
# Or, in one line:
# while (defined ($link = <LINKS>)) {
 
    defined ($description = <LINKS>) or last;
    chomp ($link, $description);
    $link_list{$link} = $description;
}
close LINKS;

foreach my $key (keys (%link_list)) {
	print "<a href=\"http://www.$key\">$key</a>\n";
 	print "\&nbsp\;$link_list{$key}<br><br>\n";
}
__END__

The latter is the Perl way of ending the input source, if necessary.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 14 May 1999 10:35:57 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: REGULAR EXPRESSION Problem 2
Message-Id: <373C5EFD.6232B991@mail.cor.epa.gov>

Ryan Ngi wrote:
> 
> Hi
> 
> i have another REGULAR EXPRESSION problem that i cant solve for a long
> time..... it is
> 
> 2. give  $Var='a bat is on the rat, the rat is on the pig';
>     i want $1 to store 'bat is on the rat'......
> i use this to do the work
> -------------------------------------------
> $Var='a bat is on the rat, the rat is on the pig';
> $Var=~/(b.*rat)/;
> print $1;
> ------------------------------------------
> the screen print out  "bat is on the rat, the rat"

Which is just what you told it to do...
 
> oh yeah, you see, it's wrong,

But clearly, not what you meant.
 
> This is only my stupid example, but if the sentense is not easy....
> good regular expression will be needed.

Your example is sufficient.  The problem is that regex pattern
matches like .* or [abt]* or .+ are all 'greedy'.  They match
from that leftmost point, and go as far as they possibly can in
the text so that the remaining patterns in your regex can still
match.  So it goes to the *last* occurrence of 'rat', instead of
the first.  Use .*? instead of .* to get a non-greedy match.
 
> what is the regular expression to use in this case??? please help as
> fast as possibleeeeeeee.....

If you want fast solutions, you really need to use your own
computer instead of usenet.  The answer was waiting for you,
in more than one place.  I suggest you read perlfaq6, which
has a lot of FAQ on regexen.  And read perlre to learn about 
the regex features.  The info on s/// and m// is in perlop.

If you don't know how to access these, try typing at a command
prompt these lines (one at a time):

perldoc perlfaq6
perldoc perlre
perldoc perlop

And note that you can search through the text to find the
pieces you want.  If you're still having trouble using the 
documentation, go to:

http://www.perlmonth.com/articles//rtfm.html

and read Dave Cross's article on using the Perl docs.

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


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

Date: 14 May 1999 10:39:53 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: SimNet - Perl proxy governor project
Message-Id: <m1btfn5z4m.fsf@halfdome.holdit.com>

>>>>> "Charles" == Charles R Thompson <design@raincloud-studios.com> writes:

Charles> I don't even know if this is possible, but it sure would be a
Charles> kick to see. Off the top of my head I would think a CGI based
Charles> script using LWP to 'filter' the page with some sort of
Charles> timing system might work, but now that I say that I see that
Charles> once a link to an image was provided, the image would pop up
Charles> instantly, so that's not the way to go. It needs to be
Charles> something that could work right in the stream and 'chug' out
Charles> bits of data in increments. I know there are a few things
Charles> like this out there for WinDoZe that somehow simulate this(
Charles> where, I have no clue ) but I think it might be possible to
Charles> do this and more in Perl.

You could base it on a combination of work I've already done for my
WebTechniques columns... in particular, I have a throttling CGI, and a
pre-forking web-proxy-server... you'd just need to combine the two. :)

My columns are online (thank you Miller Freeman!) at

	http://www.stonehenge.com/merlyn/WebTechniques/

print "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Fri, 14 May 1999 17:23:53 GMT
From: webmaster@film.tierranet.com (Mike Arndt)
Subject: Small amount of Perl CGI script work needed for site.
Message-Id: <373c5cba@newsbox.grin.net>

Hello,

I'm interested to know if anyone can program a Perl CGI which can do the 
following.

I'm designing an e-commerce site and I want there to be a way that people can 
e-mail product information from the web page to friends. I'd like it to look 
something like this.

<form action=cgiscript.cgi8>
<input type=text name="SV-4000W" size=14 VALUE="enter e-mail"><br>
<input type=button value="Send Info"></form>

Let's say this script existed on a web page called 
http://www.example/products/product1234.html

I'd like the user to input their friends e-mail address and the friend would 
receive an e-mail that reads as follows:

------------
From: Sales@example.com
Subject: SV-4000W Product Alert
Body: 

Hello,

A friend or associate has informed us that you may be interested in the 
following product. 

SV-4000W
For more information and for pricing information go to the following URL.
http://www.example/products/product1234.html

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


Is this possible and how much would you charge to have such a script made. 
Please e-mail or at least CC me any replies. Thanks.


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

Date: Fri, 14 May 1999 18:58:05 GMT
From: dalehend@flash.net
Subject: Re: Small amount of Perl CGI script work needed for site.
Message-Id: <373c720e.92890389@news.flash.net>


Mike,

I do Perl customizations and small projects. My fee for this would be
$200.

Regards,
Dale Henderson


On Fri, 14 May 1999 17:23:53 GMT, webmaster@film.tierranet.com (Mike
Arndt) wrote:

>Hello,
>
>I'm interested to know if anyone can program a Perl CGI which can do the 
>following.
>
>I'm designing an e-commerce site and I want there to be a way that people can 
>e-mail product information from the web page to friends. I'd like it to look 
>something like this.
>
><form action=cgiscript.cgi8>
><input type=text name="SV-4000W" size=14 VALUE="enter e-mail"><br>
><input type=button value="Send Info"></form>
>
>Let's say this script existed on a web page called 
>http://www.example/products/product1234.html
>
>I'd like the user to input their friends e-mail address and the friend would 
>receive an e-mail that reads as follows:
>
>------------
>From: Sales@example.com
>Subject: SV-4000W Product Alert
>Body: 
>
>Hello,
>
>A friend or associate has informed us that you may be interested in the 
>following product. 
>
>SV-4000W
>For more information and for pricing information go to the following URL.
>http://www.example/products/product1234.html
>
>---------------
>
>
>Is this possible and how much would you charge to have such a script made. 
>Please e-mail or at least CC me any replies. Thanks.



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

Date: Fri, 14 May 1999 11:22:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting is too slow for finding top N keys... - GOT IT !
Message-Id: <MPG.11a609c55e38f3db989a65@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7hbql2$j0a$1@news.mch.sbs.de> on Wed, 12 May 1999 12:03:07 
GMT, Michel Dalle <michel.dalle@usa.net> says...
 ...
> Here is a simple test I ran with 411406 entries (actual time spent, not CPU
> time) :
> 
> Michel1 (simple sort) : 252 seconds
> Michel3 : 74 seconds
> Larry1 : 16 seconds
> Larry2 : 16 seconds
> Larry4 : 202 seconds
> Bart1 : interrupted after 10 minutes
> ..
> Only Larry1 and Larry2 seemed to be using the CPU at more than 10%.
> And in this case, Larry4 (with binary insertion) is actually worse than Larry2
> (linear insertion).
> 
> So, since the CPU penalty for using Larry1/Larry2 is quite small compared
> to the potential gain, I'll go that way any day :-)
> 
> I haven't tested yet whether the problem I had with 31013 entries with Perl
> 5.004 and 5.003 was also due to paging... Can anyone else verify that for
> large hashes, simple sorting with Perl5.005.0x can slow down excessively
> due to paging, and that LarryX (and other algorithms) are more appropriate ?

Well, I let my desktop machine run overnight on this problem, and the 
results are (I hope) eye-opening.

The extremes() function was my fourth version (binary insertion sort, 
which I insist is faster than linear insertion sort whenever it 
matters).  The data are your data set iterated 32 times to get to almost 
a million entries.

my %hash;
sub create {
    my $key = 'aaaaa';
    for my $n (1 .. 32) {
        seek DATA, 0, 0;
        while (<DATA>) {
            my ($value, $number) = /(\d+)\s+(\d+)/;
            $hash{$number . $key++} = $value while $number--;
        }
    }
}
sub sort_sub { $hash{$b} <=> $hash{$a} } 

my $n = 20;
use Benchmark;
timethese(1 << (shift || 0), {
  Create   => sub { &create; print scalar keys %hash, "\n" },
  External => sub { extremes(\%hash, $n, \&sort_sub) },
  Internal => sub { extremes(\%hash, $n, 1, 1) },
  Sort     => sub { (sort sort_sub keys %hash)[0 .. $n - 1] },
});
__END__

Benchmark: timing 1 iterations of Create, External, Internal, Sort...
992384
    Create:   240 wallclock secs (71 usr +   2 sys =  73 CPU)
  External:  5951 wallclock secs (98 usr +  30 sys = 128 CPU)
  Internal:  5005 wallclock secs (49 usr +  29 sys =  78 CPU)
      Sort: 32612 wallclock secs (91 usr + 201 sys = 293 CPU)

[Insignificant decimal fractions and iteration-count warnings removed 
for readability.]

Now everything is clear, I hope.  The extremum sorts (slice-and-sort) 
take much less clock time and much less I/O (swap) time, while using 
user time comparable to the sort() function (sort-and-slice).

I will revise the description of extremes() to include this new 
understanding of the performance issues.  What matters is the size of 
the data relative to the physical memory, not any pathological nature of 
the data.

System information:

Hewlett-Packard HP Vectra XU 6/200; 96 MB RAM; 157 MB swap.
Windows NT 4.0 SP3.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 14 May 1999 12:23:35 -0500
From: Trainham Bradford <Bradford.Trainham@m1.irs.gov>
To: comp.lang.perl.misc@list.deja.com
Subject: Using cmp on data fetched via Odbc
Message-Id: <EDBFE92200BED211BAA60060083A074E3DB9AB@au01s010.aus.swr.irs.gov>


I'm using the win32::odbc module against an Informix database to generate
a list of hotels on the fly that perspective travelers to various sites
can pull up. Everything works but the fragment of code below in which
I try to determine whether or not a identification badge is required at the
hotel. 
The indicator is defined in the database as a char of length 1. 
When I say: 

print "IRS badge required \n") if (($data{h_idind} cmp "X") == 0);
I've made certain my test data does indeed contain an X in tha field, and
by the resulting output of the program every other field is being processed
correctly. 
Other than that I work for the IRS, what might I be doing wrong? 
Thanks,
Brad Trainham



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

Date: Fri, 14 May 1999 17:13:49 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: Which book do you recommend?
Message-Id: <MPG.11a6252f150648439896c6@news>

[ Congratulations, Lacrosse_20 you could be a winner! Return to 
comp.lang.perl.misc to claim your prize. ]

In article <7hhjkn$d1t$1@nnrp1.deja.com>, Lacrosse_20 says...
> Hey guys.  I just posted this, but it isn't showing up in my list, so
> I'm reposting.  

Don't do that. :) Sometimes it takes a bit of time before something will 
pop up.

I'm going to assume you already have Learning Perl?!?!? If so, here's my 
thoughts...

> The ones I'm looking at are Perl Cookbook; Tom Christiansen, et
> al, 

An excellent book. If you learn by example like I do this is a no-
brainer. Until I see something, I rarely understand it. The code examples 
have really helped lately. There *might* be a few things that give you 
pause in there if you are coming straight from Learning Perl. I haven't 
gotten through the entire book, so I really can't commit to that comment.

> Programming Perl, 2nd Edition (covers Perl 5.0); Larry Wall
> (Editor), et al, 

You'd probably be better off going with this book first before the 
CookBook. I'm really getting alot out of Programming Perl. Chapter 4 
(References and Data Structures) has been extremely beneficial this week! 
Again, the examples helped. My money is on Programming Perl overall. :)

> Mastering Regular Expressions: Powerful Techniques for
> Perl and Other Tools; Jeffrey E. F. Friedl, and 

It would be a toss up after Programming Perl between this and the 
CookBook. I don't see myself really getting the most out of it until 
after Programming Perl and midway through the CookBook.. but that's just 
my learning timeline. I have this book but am nowhere close to really 
getting much out of it yet as it's a bit beyond my understanding. I'm 
toggling between Programming Perl and the Cookbook (and still referencing 
Learning).

> Advanced Perl
> Programming; Sriram Srinivasan.  

Don't have that one. No clue.

-- 
Charles R. Thompson
RainCloud Studios


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

Date: Fri, 14 May 1999 17:25:24 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Win32::Process question
Message-Id: <7hhm8g$q03$3@xenon.inbe.net>

In article <373C3C40.898180C4@colorado.edu>, Collin Starkweather <collin.starkweather@colorado.edu> wrote:
[snip]
>With $ProcessObj a Win32::Process object, one can wait a specified
>number of seconds for the process to die a la $ProcessObj->Wait(1000).
>
>After the Wait, how does one tell whether the Wait timed out or whether
>the process terminated; i.e., is there a method for determining whether
>a process is still active?
>
>I checked the exit code with GetExitCode prior to process termination,
>and it was 259.  Is this a way to tell?  Is the exit code of a running
>process 259 on Win9x systems as well?  Is 259 part of the Win32 specs
>and unlikely to change across machines and/or Windows versions?
[snap]

259 = 0x103 = STATUS_PENDING = STILL_ACTIVE = return code for
GetExitCodeProcess when the process is ... still active.

The only thing that is defined for Win32 is that GetExitCodeProcess may
return STILL_ACTIVE. The rest is up to Bill... Is he consistent ?

Michel.


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5664
**************************************

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