[16879] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4291 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 11 21:06:16 2000

Date: Mon, 11 Sep 2000 18:05:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968720716-v9-i4291@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 11 Sep 2000     Volume: 9 Number: 4291

Today's topics:
    Re: 5.6.0 shebang under NT (was Re: how to match the ho (Andrew J. Perrin)
    Re: [Q] Matching newlines using . and /s <apandey@u.washington.edu>
    Re: Adding filename to top of file ()
        avoiding do {} while() <gopalan@cs.sc.edu>
    Re: avoiding do {} while() <lr@hpl.hp.com>
    Re: Call another CGI-Script with POST Method <elephant@squirrelgroup.com>
        Check data by using Perl patern match function <sshieh2@visteon.com>
    Re: Converting PHP to Perl - Expert needed ! (David H. Adler)
        cwd reporting incorrect directory in ActiveState 613? <scotts@itinet.com>
    Re: cwd reporting incorrect directory in ActiveState 61 <tony_curtis32@yahoo.com>
    Re: cwd reporting incorrect directory in ActiveState 61 <scotts@itinet.com>
    Re: cwd reporting incorrect directory in ActiveState 61 <tony_curtis32@yahoo.com>
    Re: Does anyone have a nice solution to this problem? <elephant@squirrelgroup.com>
        File Upload using a require .pm grover_muppit@hotmail.com
    Re: File::Basename and file upload problem with Macs <elephant@squirrelgroup.com>
        format @<<< rathmore@tierceron.com
    Re: help in writing a card game <godzilla@stomp.stomp.tokyo>
    Re: Holy moly! Substitution on 10-kb scalar takes over  (Ilya Zakharevich)
    Re: How long does flock take? (Ilya Zakharevich)
    Re: how to match the hole string by first word? (need h (Gwyn Judd)
        How to set userid of a forked process <sherry@zeroknowledge.com>
    Re: Including Files rathmore@tierceron.com
    Re: Is there a file rename function? <elephant@squirrelgroup.com>
        Launched process not terminating in Win2000 <brendans@worldfree.net>
    Re: LittleProblem (Abigail)
    Re: LittleProblem (Maurice E. Jarrell)
    Re: LittleProblem <stephenk@cc.gatech.edu>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 11 Sep 2000 18:59:07 -0400
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: 5.6.0 shebang under NT (was Re: how to match the hole string by first word? (need help))
Message-Id: <ur96qo7r8.fsf@demog.berkeley.edu>

Randy <randy_734@my-deja.com> writes:

> The problem is with the method I am using to run the script.
> 
> @rem = '
> @echo off
> e:\perl\bin\perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
> goto EndOfPerl
> @rem ';
> 
> #!perl -w
> print "foo\n";
> print $foo;
> 
> __END__
> :EndOfPerl
> 
> It is the DOS "wrapper" that is keeping -w from working.

Indeed - more specifically, it's because the shebang is not the first
line of the script. 

ap

-- 
----------------------------------------------------------------------
Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
       aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
----------------------------------------------------------------------


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

Date: Mon, 11 Sep 2000 14:38:08 -0700
From: Anshuman Pandey <apandey@u.washington.edu>
Subject: Re: [Q] Matching newlines using . and /s
Message-Id: <Pine.A41.4.21.0009111419050.86676-100000@vergil01.u.washington.edu>


On Thu, 7 Sep 2000, Larry Rosler wrote:

> + I have a small program which processes text found within a specified 
> + delimiter. The program is supposed to modify text found only between 
> + "{\macro" and "}", e.g. "{\macro abcdef}.  Here is the program:

[program code snipped]

> + However, the program works only on text which does not contain
> + newlines [...] I understand that "." does not match newlines unless
> + the "s" operator is specified. I also added the "m" operator to the
> + operator list, but that did not grant success either [...]
> 
> Indeed.  Your code reads one line at a time, so the regex cannot match a 
> string that spans line boundaries.  You will have to read the entire 
> file into one string before processing it.

Understood. I added the line "local $/ = undef;" to my program. Now the
program will match text split across lines. However, I wish to add
"processing instructions" in the text which will control the manner in
which the text is handled. With $/ = undef, the following code does not
work. But, if I set $/ = "", the code works.

In the following the scalar $pet is assigned the string matched by
/\@(\w+)/ in the input text. This pattern indicates a "processing
instruction" in the input text. For this program the valid values are
"@bat" and "@cat". The existence of these "instructions" causes the
program to handle the search-and-replace differently.

   #local $/ = undef;
   local $/ = "";

   while (<>) {
     ($pet = $1) if (/\@(\w+)/);
     s/\{\\mac (.*?)\}/transform()/gse;
     print;
   }

   sub transform {
     $buffer = $1;
     $buffer =~ tr/a/i/ if ($pet eq "bat");
     $buffer =~ tr/a/u/ if ($pet eq "cat");
     "{\\mac $buffer}";
    }
  
   
Here is some sample input:

     @bat
     {\mac bat hat
     pat

     fat}

     @cat
     {\mac bat hat
     pat

     fat}

The "instruction" @bat tells the program that the text within {\mac ...}
should be modified so all occurances of "a" are replaced with "i".

The "instruction" @cat tells the program that the text within {\mac ...}
should be modified so all occurances of "a" are replaced with "u".

With $/ = undef, the program fails to recognize the @cat "instruction" and
applies the rules for @bat globally. With $/ = "", the program fails to
work due to the double-line-breaks with the pattern to be matched. If I
remove the double-line-breaks from the input, eg:

     @bat
     {\mac bat hat
     pat
     fat}

     @cat
     {\mac bat hat
     pat
     fat}

the program produces the desired output.

I understand the elementary differences between $/ = undef and $/ = "".
Might there be a way that I can convince the program to recognize and
apply each of the "instructions" upon the pattern to be matched, switching
to new "instructions" as they arise in the text?

I appreciate your advice.

Regards,
Anshuman Pandey



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

Date: Mon, 11 Sep 2000 23:55:48 GMT
From: sjs@yorku.ca ()
Subject: Re: Adding filename to top of file
Message-Id: <slrn8rqs9d.dmj.sjs@john.sympatico.ca>

Tom Christiansen <tchrist@perl.com> wrote:

> "Why" "do" "you" "quote" "things" "that" "you" "do" "not" "need"
> "to" "quote"?

I didn't realize how much I missed TomC around here until he
started posting again.  This stuff is priceless. :-)

WB, Tom.

Steve


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

Date: Mon, 11 Sep 2000 17:26:04 -0400
From: Gopi Sundaram <gopalan@cs.sc.edu>
Subject: avoiding do {} while()
Message-Id: <Pine.OSF.4.21.0009111718410.915-100000@onyx.cs.sc.edu>

Hello all,

I'm trying to eliminate the do-while loop in the following code
snippet, because, well, it's ugly.
------------------------------------
#!/usr/local/bin/perl -w

use strict;                                        # Save me from stupidity
                                                   #
my @sigs = </path/to/files/*>;                     # Get all files in the
                                                   # specified directory
my $index;                                         #
                                                   #
do                                                 # Choose a file, making
{                                                  # sure that it is a
    $index = rand ($#sigs + 1);                    # text file.
} while ( !defined $sigs[$index] || ! -T $sigs[$index] );
-----------------------------------

Yes, that's how I comment my code. Sorry if it wraps around.

I tried this code instead of the loop:

my $index = rand ($#sigs + 1) until -T $sigs[$index];

But then that apparently evaluates the until condition first, and so I
get warnings that I can't eliminate.

Any ideas ?

Gopi.

-- 
Gopi Sundaram
gopi@cs.sc.edu



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

Date: Mon, 11 Sep 2000 16:41:53 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: avoiding do {} while()
Message-Id: <MPG.14270d9f63b83d5098ad59@nntp.hpl.hp.com>

In article <Pine.OSF.4.21.0009111718410.915-100000@onyx.cs.sc.edu> on 
Mon, 11 Sep 2000 17:26:04 -0400, Gopi Sundaram <gopalan@cs.sc.edu> 
says...
> Hello all,

Hello back at ya'.
 
> I'm trying to eliminate the do-while loop in the following code
> snippet, because, well, it's ugly.

Why?  It is a good expressive use:  Do something, then test it.

> ------------------------------------
> #!/usr/local/bin/perl -w
> 
> use strict;                                        # Save me from stupidity
>                                                    #
> my @sigs = </path/to/files/*>;                     # Get all files in the
>                                                    # specified directory
> my $index;                                         #
>                                                    #
> do                                                 # Choose a file, making
> {                                                  # sure that it is a
>     $index = rand ($#sigs + 1);                    # text file.
> } while ( !defined $sigs[$index] || ! -T $sigs[$index] );
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
That seems unnecessary; all the elements of @sigs are defined.

> -----------------------------------
> 
> Yes, that's how I comment my code. Sorry if it wraps around.

Then don't outdent them so far!

> I tried this code instead of the loop:
> 
> my $index = rand ($#sigs + 1) until -T $sigs[$index];
> 
> But then that apparently evaluates the until condition first, and so I
> get warnings that I can't eliminate.
> 
> Any ideas ?

Indeed.

First of all, as written, you have the possibity of an infinite loop if 
none of the files in the directory is a text file.  I would do a grep to 
select only the ones that are text files, so the loop will terminate.

Then, there need be no loop at all!

  my @sigs = grep -T, </path/to/files/*>;
  my $index = rand @sigs;

That avoided do {} while (), didn't it?  :-)

Against this approach is the need to examine every file, while your 
probing method quits as soon as it finds one file that is a text file.  
But you'd better get rid of the entries already tested.

  my @try = my @sigs = </path/to/files/*>;
  my $found;
  1 while @try && ! -T ($found = splice @try, rand @try, 1);
  @try or die "All files tried!\n";

The name of the desired file is in $found.

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


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

Date: Tue, 12 Sep 2000 11:43:07 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Call another CGI-Script with POST Method
Message-Id: <MPG.14281913c09384b2989779@localhost>

Yves Lustenberger <lu@bbi.ch> wrote ..
>I need some help frome you.
>I don't find any solution to call from a Perl-CGI Script another
>CGI-Script with the POST Method.
>
>Could anyone please tell me how this works.
>
>By the way, both Scripts are on the same Server.
>Is there maybe another solution than use the Webinterface ?

have a look at the following built-in Perl functions: eval, do, require 
and use .. you can use the built-in perldoc utility to see the docs like 
so

  perldoc -f eval
  perldoc -f do
  perldoc -f require
  perldoc -f use

>If you cold show me an example-Code, this would be enough.

examples are in the docs

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 11 Sep 2000 18:29:33 -0400
From: Lisa Shieh <sshieh2@visteon.com>
Subject: Check data by using Perl patern match function
Message-Id: <39BD5CCD.2E296107@visteon.com>

Hi, everyone:
I would like to use Perl patern match function to check the data user
entered through form. Does anyone have sample code?

Thank you for your help.

Lisa


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

Date: 11 Sep 2000 23:46:08 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Converting PHP to Perl - Expert needed !
Message-Id: <slrn8rqrm0.mea.dha@panix6.panix.com>

On Sat, 9 Sep 2000 05:19:08 +0100, Sunil Jaiswal
<Sunil@dukeswell.co.uk> wrote:

>----> Apologies if this is the wrong place for this post ! <-----

Oh boy is it...

>I'm looking for a PHP / Perl Expert who can help me out with some
>work :

You have posted a job posting or a resume in a technical group.

Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.

Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :)  (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)

Please do not explain your posting by saying "but I saw other job
postings here".  Just because one person jumps off a bridge, doesn't
mean everyone does.  Those postings are also in error, and I've
probably already notified them as well.

If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.

There is a Perl Jobs Announce list that may be more helpful to you.  See
<http://www.pm.org/mailing_lists.shtml> for details.

Yours for a better usenet,

dha


-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Damn, if this doesn't win me "Pedant of the Year", I don't know what
will.	 - Mark Rogaski


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

Date: Mon, 11 Sep 2000 17:39:34 -0500
From: "Scott Schaumann" <scotts@itinet.com>
Subject: cwd reporting incorrect directory in ActiveState 613?
Message-Id: <Fbdv5.600$dw6.65278@nnrp1.sbc.net>

I'm running the following script:

#require 5.000;  # Perl 5 or better...
#use strict;

use CGI;
use Cwd;
use Win32;
use File::Spec;
use Env

$html = CGI::new();
print $html->header();
print $html->p("CWD = " . cwd());
print $html->p("CWD = " . getcwd());
print $html->p("CWD = " . fastcwd());
print $html->p("CWD = " . pwd);
print $html->p("curdir = " . File::Spec->curdir);

And getting the follwing result:

CWD = E:/src/aacsb

CWD = E:/src/aacsb

CWD = E:/src/aacsb

CWD = pwd

curdir = .

The script is actually in e:\src\aacsb\surveys-sse. Any bright ideas on
what's going wrong? Is there a better way to test for cwd?

Scott Schaumann
Interchange Technologies
scotts@itinet.com




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

Date: 11 Sep 2000 17:46:32 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: cwd reporting incorrect directory in ActiveState 613?
Message-Id: <87r96qo8c7.fsf@limey.hpcc.uh.edu>

>> On Mon, 11 Sep 2000 17:39:34 -0500,
>> "Scott Schaumann" <scotts@itinet.com> said:

> use CGI;

> CWD = E:/src/aacsb
> CWD = E:/src/aacsb
> CWD = E:/src/aacsb

> The script is actually in e:\src\aacsb\surveys-sse. Any
> bright ideas on what's going wrong? Is there a better
> way to test for cwd?

The file might be in that directory, but it doesn't
necessarily mean its process is *running*
there. Especially with the webserver starting CGI
processes.

hth
t
-- 
WWNKD?


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

Date: Mon, 11 Sep 2000 17:59:28 -0500
From: "Scott Schaumann" <scotts@itinet.com>
Subject: Re: cwd reporting incorrect directory in ActiveState 613?
Message-Id: <judv5.926$d42.58240@nnrp3.sbc.net>

You are probably right. Unfortunately that doesn;t solve my problem. My
original problem was that if ( - e filename) is failing in this directory.
Is there a way to get if(-e...) to correctly determine the directory the
perl script is running in?

-Scott


"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87r96qo8c7.fsf@limey.hpcc.uh.edu...
> >> On Mon, 11 Sep 2000 17:39:34 -0500,
> >> "Scott Schaumann" <scotts@itinet.com> said:
>
> > use CGI;
>
> > CWD = E:/src/aacsb
> > CWD = E:/src/aacsb
> > CWD = E:/src/aacsb
>
> > The script is actually in e:\src\aacsb\surveys-sse. Any
> > bright ideas on what's going wrong? Is there a better
> > way to test for cwd?
>
> The file might be in that directory, but it doesn't
> necessarily mean its process is *running*
> there. Especially with the webserver starting CGI
> processes.
>
> hth
> t
> --
> WWNKD?
>




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

Date: 11 Sep 2000 18:02:19 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: cwd reporting incorrect directory in ActiveState 613?
Message-Id: <87og1uo7lw.fsf@limey.hpcc.uh.edu>


[ please put original first, then add your reply to the
relevant portions of the text ]

>> On Mon, 11 Sep 2000 17:59:28 -0500,
>> "Scott Schaumann" <scotts@itinet.com> said:

> You are probably right. Unfortunately that doesn;t solve
> my problem. My original problem was that if ( - e
> filename) is failing in this directory.  Is there a way
> to get if(-e...) to correctly determine the directory
> the perl script is running in?

Carpe diem.  Use chdir() to change directory to where you
want to be.  Then it's easy: you're in "." :-)

hth
t
-- 
WWNKD?


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

Date: Tue, 12 Sep 2000 11:08:41 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Does anyone have a nice solution to this problem?
Message-Id: <MPG.1428110817c79014989776@localhost>

Joe Kennedy <j.kennedy@hamiltonrenata.co.uk> wrote ..
>I am currently writing a web-based database using perl and MS Access, and I
>have the following problem.
>
>Is there an easy way to re-print a results page (with many lines of summary
>data), only re-ordered by a different field (or column)??
>
>Currently when the user prints a summary results page, I have given them a
>hyperlink on each column field name, so that they can re-print the page,
>only re-sorted by a different column. However, some of the 'SELECT' calls
>are very complex, and currently what I do is to call the same Perl scripts,
>passing the 'SELECT' variables within the URL. I think this is a very clumsy
>solution, and am sure there is an easier way. Any help would be greatly
>appreciated!!

this is the most common way of doing this .. to get around this you 
could save the query in some form of storage (a temporary database table 
or a temporary file for instance) and then send the browser a unique key 
to that temporary storage location (so you can differentiate between 
different browsers)

then on subsequent calls - instead of doing the expensive select again 
 .. you just grab the data from the temporary storage and re-order it

you might want to use something like the Storable module from CPAN to 
store a complete data structure that you created in Perl to enable rapid 
re-ordering

this will make the initial select a little more expensive - but 
subsequent ones much cheaper

>I also have a (related) query that's been bugging me for some time.....
>
>Is it possible to call a perl script somewhere in the middle, rather than
>starting at the beginning each time? If so, how do I do it?

yes .. your Perl program would look something like...

  #!/usr/bin/perl -w
  use strict;

  use CGI;
  my $q = new CGI;

  middleFunction() if $q->param('someFlag') eq 'someValue';

  beginningFunction();

  sub beginningFunction
  {
    # blah code

    middleFunction();
  }

  sub middleFunction
  {
    # some other code
  }

  __END__

>Also, would this possibly help me resolve the above problem, where I could
>simply by-pass the 'SELECT' part, and call the 'Print Summary Results' part?

no .. because without special tools - CGI is a stateless environment - 
meaning that on the second call there's no way for that script to know 
that it's being called by the same browser that just retrieved that 
'select' without you manually telling it somehow (as I explained above)

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 12 Sep 2000 00:25:15 GMT
From: grover_muppit@hotmail.com
Subject: File Upload using a require .pm
Message-Id: <8pjt4k$p38$1@nnrp1.deja.com>

I have an file upload quirk that is baffling me and I hope someone can
help.

A simple explanation of the problem is as such:

I have a PERL CGI which has come code like the following:

my $file_name = $q->param('uploadfile');

print "<h2>File: $file_name</h2>";

while (my $line = <$file_name>) {
   print "$line<br>";
}


THIS WORKS FINE!  Prints the contents of the text file uploaded through
the HTML form.

BUT ..... if I wish to take this code and place it into a PERL module
such as:

#! /usr/local/pd/bin/perl5
package file_stuff;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(upload_file);

sub upload_file { my($file_name) = @_;

   print "<h2>File: $file_name</h2>";

   while (my $line = <$file_name>) {
      print "$line<br>";
   }
}

1;



AND then in the CGI program use the following:

require 'file_stuff.pm';

&file_stuff::upload_file($file_name);


It does not print the file contents.

If I instead use a .pl instead of a .pm as follows:

#! /usr/local/pd/bin/perl5
sub upload_file { my($file_name) = @_;

   print "<h2>File: $file_name</h2>";

   while (my $line = <$file_name>) {
      print "$line<br>";
   }
}

AND then in the CGI program use the following:

require 'file_stuff.pl';

&upload_file($file_name);

It works!


So, after all that ..... can someone expain to me why the PERL module
is not working as I am expecting it to??


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 12 Sep 2000 11:47:48 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: File::Basename and file upload problem with Macs
Message-Id: <MPG.14281a2b8cf056e598977a@localhost>

Gary Nielson <gnielson@charlotte.infi.net> wrote ..
>I wish we had a Macintosh here! I am using a module I found on the Net
>so that I can take a form variable ( <input type="file" name="file_type"
>value=$file_type> ) and upload a file to a directory through a Web
>browser. I am using File::Basename to parse the name of the file being
>uploaded. Works great... except when the user's computer is a Macintosh.
>I have a problem getting access to a Macintosh, though I know that file
>paths and names on Macs are pretty different. I am looking for advice
>from someone who has set up file upload scripts who might know how to
>make the upload compatible with Macs. Not having a Mac to play around
>with makes this problem harder to solve. I have listed the script I
>wrote below and included the CGI_LIB module as well. Any advice
>appreciated.

you really need to learn how to break your examples down into small 
samples - it's unreasonable to expect people here to sift through all 
that messy code

I haven't been through your code .. and I have no experience in doing 
what you want to do .. but - just in case this helps - the MacOS file 
separator character is the colon .. ie. the file 'bar' in the directory 
'foo' has a full path of

  foo:bar

on MacOS

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 11 Sep 2000 23:41:56 GMT
From: rathmore@tierceron.com
Subject: format @<<<
Message-Id: <8pjqk0$m09$1@nnrp1.deja.com>

Hello, I'm reading a long line of data from a text file and unpacking
it into an array of scalars. The last two scalars sometimes do not get
any data so they equal "" after I've unpacked them.

When I write the data to a file using the "format" and "write" commands
the last two fields don't print anything if they are "". What I want to
happen is for them to print spaces equal to the format that I set up.
How do I force this to happen?

format FILE =
@<<<@<<<
$y, $z
 .

If $y and $z = "" then:
It looks like this when it writes to the file: ""
I want it to look like this: "      "

Thanks!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 11 Sep 2000 17:37:08 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: help in writing a card game
Message-Id: <39BD7AB4.11022B6C@stomp.stomp.tokyo>

Kelley Kent wrote:

(misc.snip)
 
> So I was bored last night and decided to write
> a card program in Perl.

Right. Actually you thought about writing a card
game and discovered doing this is extremely difficult
and reserved for imaginative programmers who know
Perl 4 inside and out.


> With regards to the deck: At first a 2 dimension
> array seemed ok (rows=suits, columns=values),
> and then 4 seperate arrays (one for each suit)
 
> Any thoughts? Ideas? Suggestions?


Study mathematics for a few years, at least up to
an Analytical Calculus level. Once you are very
comfortable with complex mathematical equations,
practice writing even more complex Euclidian
algorithms before ever attempting to deal with
a dealt deck of cards, much less multiple decks.

Absolutely no need for associative arrays to
accomplish this task, regardless of complexiety.
Waste of time, waste of memory and most illogical.
The "Secret" of card games, is number crunching,
pure number crunching and little else.


Godzilla!
-- 
Robby The Remarkable Robot
  Cowboy Song Writer
    http://la.znet.com/~callgirl/android/cowboy.cgi


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

Date: 11 Sep 2000 23:53:54 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Holy moly! Substitution on 10-kb scalar takes over *one second*!
Message-Id: <8pjrai$nfc$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Sean McAfee
<mcafee@waits.facilities.med.umich.edu>],
who wrote in article <Bh7v5.2869$O5.58769@news.itd.umich.edu>:
> What the heck happened between 5.005 and 5.6 to cause this dramatic
> performance degradation?

A lot of significant optimization got added.  As a side effect, rarely
some linear things became quadratic.  ;-) ;-( It was my oversight...

Do you mean this one:

 perl5.6.0 -wle '$_ = "a" x 70 . "\n"; $_ x= 100; $_ .= "\t"; /.*?\t/'

?  I do not think I knew about this particluar case.  There are two
different slowdowns, one without '?', another with.

Run with -Mre=debugcolor to see the details.  (I did not yet.)

Ilya


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

Date: 11 Sep 2000 23:38:34 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: How long does flock take?
Message-Id: <8pjqdq$n7a$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to 
<cfedde@sl3d.com>],
who wrote in article <fB8v5.83$W3.171109888@news.frii.net>:
> In article <8phlko$sqn$1@charm.magnus.acs.ohio-state.edu>,
> Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:

[This was Cc'ed without marking it as such.  Please always mark
postings which are Cc'ed by mail.]

> >I do not see what the processor has to do with this - unless you use
> >something like Linux, which (wrongly) use CPU cycle count for time
> >measurements.  But it looks like on Solaris Ultra5 the results are

> My comment about pentium boxen has more to do with motherboard
> architecture used on these critters.  It was my intent to point
> out that most of these systems have similar hardware to count
> passage of realtime.  Typically that hardware has a resolution
> around 100 pico seconds.

I have no idea what you mean here.  I do not recollect the clocking
hardware to change from the time of 386.  Unless you mean the
instructor counter of 586, which should not be used for clocking purposes.

It is just that the APIs of yesterday were not querying the hardware at
all, it was just reading the updated-each-tick memory locations.  APIs
of today use a slower method, but gives better resolution by actually
going to the hardware.

Ilya


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

Date: Tue, 12 Sep 2000 00:54:01 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: how to match the hole string by first word? (need help)
Message-Id: <slrn8rqvl7.7oe.tjla@thislove.dyndns.org>

I was shocked! How could Larry Rosler <lr@hpl.hp.com>
say such a terrible thing:
>In article <39BCFF74.9762CE52@nwu.edu> on Mon, 11 Sep 2000 10:51:16 -
>0500, Alexandr Kogan <a-kogan@nwu.edu> says...
>
>...
>
>> I need to go through a huge text file find strings that start with
>> the same word and convert the whole line to lowercase. I'm having 
>> problems getiing a hold of a whole string, that's what I'm doing:
>> 
>> while (<INPUT>) {
>>         if ($s =~ /^objectclass: /i) {
>>         chop $_;
>>         $_ = lc($_);
>>         print OUTPUT $_;}
>>         else {print OUTPUT $_;}	
>>     }
>> 
>> Could someone tell me what is wrong and how to do it right? 
>
>Good answers are already posted.  This is for the folks who object to 
>compact syntax, including the ternary conditional operator:
>
>  print OUTPUT /^objectclass: /i ? lc : $_ while <INPUT>;
>
>This is 'clean' Golf -- clear, expressive, no superfluities.

how about:

perl -wpe 's/^(objectclass: .*)/lc $1/ie' < input > output

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
NONSENSE

n. The objections that are urged against this excellent dictionary.


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

Date: Mon, 11 Sep 2000 20:38:03 -0400
From: sherry <sherry@zeroknowledge.com>
Subject: How to set userid of a forked process
Message-Id: <39BD7AEB.78C96837@zeroknowledge.com>

Hi ,

Problem: I would like to run a script as root, and find all users of a
machine and
run a program as each user. All these users are non privileged users.

I would like to fork a process,  set userid of that process as userA and
exec programA.
How can I do this?



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

Date: Mon, 11 Sep 2000 23:36:17 GMT
From: rathmore@tierceron.com
Subject: Re: Including Files
Message-Id: <8pjq9g$lr3$1@nnrp1.deja.com>


> How do I include the file Order_Methods.pm within OrderMan.pl when I
> compile? In C++ it would look like this:

For others who might read this later, the actual syntax is:

use Order_Methods;

Note that the Order_Methods file needs to end in .pm extension NOT .pl
(in NT anyway).

It seems so easy once you see the answer, but it took longer than I'd
like to admit to figure it out. :(

Rathmore


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 12 Sep 2000 11:35:36 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Is there a file rename function?
Message-Id: <MPG.142817528c751b8d989778@localhost>

Tom Christiansen <tchrist@perl.com> wrote ..
>In article <39BB22FC.A929D601@hotmail.com>, Ken  <kenn_mar@hotmail.com> wrote:
>>Hi all,
>>The subject title says it all. Any doc on how file rename can be done? I
>>know I did come across it somewhere but just couldn't recall.
>
>The answer, of course, is to grep the fine manual.  If it's a function
>you want, it's in perlfunc.
>
>    % man perlfunc | grep rename
>
>or, using the new perlman tool,
>
>    % perlfunc rename
>
>or 
>
>    % perlhelp rename

or the existing tools on a system without 'grep' and/or 'man'

  perldoc -f rename

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 11 Sep 2000 16:47:58 -0700
From: "Brendan" <brendans@worldfree.net>
Subject: Launched process not terminating in Win2000
Message-Id: <Saev5.266$PX3.102207@news.pacbell.net>

I launch a simple console executable from a Perl CGI script on a Windows
2000 web server.  Output is OK but the executable process does not
terminate, and I cannot terminate the process via Task Manager.

Can anyone help with this one??

Brendan




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

Date: 11 Sep 2000 22:15:27 GMT
From: abigail@foad.org (Abigail)
Subject: Re: LittleProblem
Message-Id: <slrn8rqma1.pg4.abigail@alexandra.foad.org>

Larry Rosler (lr@hpl.hp.com) wrote on MMDLXVIII September MCMXCIII in
<URL:news:MPG.1426ed8946d0a14898ad56@nntp.hpl.hp.com>:
?? 
?? Easily.
?? 
??   $,=$\;print aaaa..zzzz

You want that (without -l):

     $,=$\=$/;print aaaa..zzzz

or else there's no final newline.

?? 16 or22.

16 would print all characters together. Hence, 22 or 25.



Abigail
-- 
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_=sub{print/::(.*)/};
$\=$/;q<Just another Perl Hacker>->();


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

Date: Tue, 12 Sep 2000 00:15:05 GMT
From: mejarrell@worldnet.att.net (Maurice E. Jarrell)
Subject: Re: LittleProblem
Message-Id: <m3lmwy239y.fsf@localhost.localdomain>

abigail@foad.org (Abigail) writes:

> Larry Rosler (lr@hpl.hp.com) wrote on MMDLXVIII September MCMXCIII in
> <URL:news:MPG.1426ed8946d0a14898ad56@nntp.hpl.hp.com>:
> ?? 
> ?? Easily.
> ?? 
> ??   $,=$\;print aaaa..zzzz
> 
> You want that (without -l):
> 
>      $,=$\=$/;print aaaa..zzzz
> 
> or else there's no final newline.
> 
> ?? 16 or22.
> 
> 16 would print all characters together. Hence, 22 or 25.
> 

Thanks for the pe(a)rls.  You guys are golfing... I'm in the woods
trying to find my ball.

Mo.


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

Date: Mon, 11 Sep 2000 20:45:32 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: LittleProblem
Message-Id: <39BD7CAC.6F242FC0@cc.gatech.edu>

nezarite wrote:

> Dr. Peter Dintelmann <Peter.Dintelmann@dresdner-bank.com> wrote in message
> news:8pip2b$slb2@intranews.bank.dresdner.net...
>
> >     which can even be shortend to
> >
> >         print "$_\n" for 'aaaa'..'zzzz';
> >
>
> Or even:
>
>     $\ = "\n";
>     print for aaaa..zzzz;
>

On the subject of shortening Perl code:
$,="\n";
print aaaa..zzzz;

This works under strict, but triggers a warning without the quotes.

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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