[18154] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 322 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 20 18:05:56 2001

Date: Tue, 20 Feb 2001 15:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982710312-v10-i322@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 20 Feb 2001     Volume: 10 Number: 322

Today's topics:
        calling other executables from a perl script (Jayant V Rajan)
    Re: calling other executables from a perl script (Steven Smolinski)
    Re: calling other executables from a perl script (Abigail)
    Re: calling other executables from a perl script (Gwyn Judd)
    Re: calling other executables from a perl script (Jayant V Rajan)
    Re: calling other executables from a perl script (Abigail)
    Re: Change unknown filenames (BUCK NAKED1)
    Re: Change unknown filenames <bart.lateur@skynet.be>
    Re: chop and chomp (Another Way)
    Re: covert =?iso-8859-1?Q?=22=F8Y=22=22?= (embeded hex) (Abigail)
    Re: covert =?iso-8859-1?Q?=22=F8Y=22=22?= (embeded hex) (Gwyn Judd)
    Re: covert =?iso-8859-1?Q?=22=F8Y=22=22?= (embeded hex) (Abigail)
    Re: Execution external programs <bertilow@chello.se>
    Re: FAQ 4.48:   How do I select a random element from a <godzilla@stomp.stomp.tokyo>
    Re: FAQ 4.48:   How do I select a random element from a <uri@sysarch.com>
    Re: FAQ 4.48:   How do I select a random element from a <godzilla@stomp.stomp.tokyo>
    Re: FAQ 4.49:   How do I permute N elements of a list? (Chris Fedde)
    Re: FAQ 4.49:   How do I permute N elements of a list? <godzilla@stomp.stomp.tokyo>
        inconsistent behavior in CGI->param()? <fchanny@lbl.gov>
        Interpolate filehandle <soso@open.net>
    Re: Interpolate filehandle (Gwyn Judd)
    Re: Java servlets and CGI (Chris Fedde)
    Re: MacPerl help for a newbie (Gwyn Judd)
    Re: MacPerl help for a newbie <mbeards@altavista.com>
    Re: Newbie Question:  How to upload a file from a form  (David H. Adler)
        Newbie:  can Perl make HTTP connections? <dwake@stanford.edu>
    Re: Newbie:  can Perl make HTTP connections? (Steven Smolinski)
    Re: PROPOSAL: Graphics::ColorNames (Ilya Zakharevich)
    Re: Specifying the length of regular expression (Abigail)
    Re: Specifying the length of regular expression <elijah@workspot.net>
    Re: term::readline gnu/stub current_history (Ilya Zakharevich)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 20 Feb 2001 21:04:47 GMT
From: jrajan@blue.seas.upenn.edu (Jayant V Rajan)
Subject: calling other executables from a perl script
Message-Id: <96um5f$i7r$1@netnews.upenn.edu>

I'm writing a perl script to automate a task that a colleague of mine has 
been doing by hand. Here's the essence: I have two lists (list 1 and list 
2), and the executable I'm running gives me instances of list1 in list2. 
It doesn't give me everything, however, so I re-run the executable with 
different parameters, but before I do that, I compare the results of the 
first run and remove all IDs for which I get a hit from list1, creating 
list 1a. I then re-runthe script with the different parameters, using 
list1a and list2. I do this several times, successively eliminating IDs 
from list 1x. 

I've implemented the procedure (logically) in a loop, and have been using 
the system command to call the executable, whose output I redirect into 
an output file. In theory, each iteration of the loop should compare the 
output from the previous iteration with list1x, the difference being 
placed in list1y. Unfortunately, the perl script _does not_ do what it's 
supposed to. I know I'm running into some kind of parent-child process 
problem here, but am not sure of exactly what's going on or of how to fix 
it. I'd appreciate any help that anyone out there could give me. Thanks!

JR


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

Date: Tue, 20 Feb 2001 21:14:27 GMT
From: sjs@linux.ca (Steven Smolinski)
Subject: Re: calling other executables from a perl script
Message-Id: <slrn995s14.5ad.sjs@ragnar.stevens.gulch>

Jayant V Rajan <jrajan@blue.seas.upenn.edu> wrote:
> [...]             Unfortunately, the perl script _does not_ do what it's 
> supposed to. I know I'm running into some kind of parent-child process 
> problem here, but am not sure of exactly what's going on or of how to fix 
> it. I'd appreciate any help that anyone out there could give me. Thanks!

Now you've done it.  There will soon be three or more posts about how
various PSI::ESP modules are predicting a bug in your code at line 17.

Let's try and beat them to it, so I don't have to see the same jokes
again. :-)  So why don't you write the smallest piece of code that
constitues a runnable program which illustrates your problem, and post
it here.  You may even solve it yourself trying to get a decent piece of
code to post.

Steve
-- 
Steven Smolinski => http://www.steven.cx/


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

Date: 20 Feb 2001 21:21:54 GMT
From: abigail@foad.org (Abigail)
Subject: Re: calling other executables from a perl script
Message-Id: <slrn995nvi.t03.abigail@tsathoggua.rlyeh.net>

Jayant V Rajan (jrajan@blue.seas.upenn.edu) wrote on MMDCCXXX September
MCMXCIII in <URL:news:96um5f$i7r$1@netnews.upenn.edu>:
\\ I'm writing a perl script to automate a task that a colleague of mine has 
\\ been doing by hand. Here's the essence: I have two lists (list 1 and list 
\\ 2), and the executable I'm running gives me instances of list1 in list2. 
\\ It doesn't give me everything, however, so I re-run the executable with 
\\ different parameters, but before I do that, I compare the results of the 
\\ first run and remove all IDs for which I get a hit from list1, creating 
\\ list 1a. I then re-runthe script with the different parameters, using 
\\ list1a and list2. I do this several times, successively eliminating IDs 
\\ from list 1x. 
\\ 
\\ I've implemented the procedure (logically) in a loop, and have been using 
\\ the system command to call the executable, whose output I redirect into 
\\ an output file. In theory, each iteration of the loop should compare the 
\\ output from the previous iteration with list1x, the difference being 
\\ placed in list1y. Unfortunately, the perl script _does not_ do what it's 
\\ supposed to. I know I'm running into some kind of parent-child process 
\\ problem here, but am not sure of exactly what's going on or of how to fix 
\\ it. I'd appreciate any help that anyone out there could give me. Thanks!
\\ 


I think you have a bug on line 17.

HTH. HAND.


Abigail
-- 
perl -wle'print"Κυστ αξοτθες Πεςμ Θαγλες"^"\x80"x24'


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

Date: Tue, 20 Feb 2001 21:50:31 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: calling other executables from a perl script
Message-Id: <slrn995pl6.up.tjla@thislove.dyndns.org>

I was shocked! How could Steven Smolinski <sjs@linux.ca>
say such a terrible thing:
>Jayant V Rajan <jrajan@blue.seas.upenn.edu> wrote:
>> [...]             Unfortunately, the perl script _does not_ do what it's 
>> supposed to. I know I'm running into some kind of parent-child process 
>> problem here, but am not sure of exactly what's going on or of how to fix 
>> it. I'd appreciate any help that anyone out there could give me. Thanks!
>
>Now you've done it.  There will soon be three or more posts about how
>various PSI::ESP modules are predicting a bug in your code at line 17.

Too late

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Q:	How do you know when it's time to wash the dishes?
A:	Look inside your pants; if you have a penis, it's not time.


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

Date: 20 Feb 2001 22:15:47 GMT
From: jrajan@red.seas.upenn.edu (Jayant V Rajan)
Subject: Re: calling other executables from a perl script
Message-Id: <96uqaj$sl7$1@netnews.upenn.edu>

Steven Smolinski (sjs@linux.ca) wrote:
: Jayant V Rajan <jrajan@blue.seas.upenn.edu> wrote:
: > [...]             Unfortunately, the perl script _does not_ do what it's 
: > supposed to. I know I'm running into some kind of parent-child process 
: > problem here, but am not sure of exactly what's going on or of how to fix 
: > it. I'd appreciate any help that anyone out there could give me. Thanks!

: Now you've done it.  There will soon be three or more posts about how
: various PSI::ESP modules are predicting a bug in your code at line 17.

Unfortunately, it looks like I was too late with my followup post! 
Anyway, here's the smallest piece of code that I could put together:

begin code...

system("e-pcr stsfile.0 $seqfile M=50 N=00 W=07 > run0.txt");

@M = ("1000","50","1000","50","1000"); #both are just lists of parameters
@N = ("00","01","01","02","02");

$i = 1;

while ($i < 6) {

    $j = $i - 1;

    open(EPCRRUNFILE,"run$j.txt");

    %sts = ();

    while(<EPCRRUNFILE>) {
	#I cut out reg-exp stuff to parse the line
	$sts{"$line1[1]"} = 1; #keep track of hits 
    }

    close(EPCRRUNFILE);

    open(PREVSTSFILE, "stsfile.$j");
    open(NEWSTSFILE, ">stsfile.$i");

    while(<PREVSTSFILE>) {

	#cut out more line parsing stuff
	if ($sts{"$line2[0]"} == 1) {}
	else {
	    print NEWSTSFILE $_;
	}
    }

    close(NEWSTSFILE);
    close(PREVSTSFILE);

    system("e-pcr stsfile.$i $seqfile M=$M[$j] N=$N[$j] W=07 > run$i.txt");

    $i++;
}

 ...end code

I appreciate any insight folks can offer. I've done a fair amount of perl 
hacking in the past, but it's mainly been text processing stuff, and I've 
never actually had to call anything from within a perl script. Also, I'm 
pretty murky on processes/threads in Perl, so if anyone knows the 
appropriate place to look in the camel book, let me know so that I can 
actually understand my problem. Thanks!

Jay R


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

Date: 20 Feb 2001 22:36:35 GMT
From: abigail@foad.org (Abigail)
Subject: Re: calling other executables from a perl script
Message-Id: <slrn995sbj.t03.abigail@tsathoggua.rlyeh.net>

Jayant V Rajan (jrajan@red.seas.upenn.edu) wrote on MMDCCXXX September
MCMXCIII in <URL:news:96uqaj$sl7$1@netnews.upenn.edu>:
-: Steven Smolinski (sjs@linux.ca) wrote:
-: : Jayant V Rajan <jrajan@blue.seas.upenn.edu> wrote:
-: : > [...]             Unfortunately, the perl script _does not_ do what it's 
-: : > supposed to. I know I'm running into some kind of parent-child process 
-: : > problem here, but am not sure of exactly what's going on or of how to fix 
-: : > it. I'd appreciate any help that anyone out there could give me. Thanks!
-: 
-: : Now you've done it.  There will soon be three or more posts about how
-: : various PSI::ESP modules are predicting a bug in your code at line 17.
-: 
-: Unfortunately, it looks like I was too late with my followup post! 
-: Anyway, here's the smallest piece of code that I could put together:


But what kind of problems do you get? When do they happen?
Why aren't you checking your return values of open()?
What are @lines1 and @lines2?



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


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

Date: Tue, 20 Feb 2001 13:52:51 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Change unknown filenames
Message-Id: <4598-3A92CB13-119@storefull-242.iap.bryant.webtv.net>

use File::Find;
        find sub { 
                        -f or return; 
                        (my $new = $_) =~ s/\.(pl|cgi|exe)$/.txt/i and
                rename $_, $new; 
                }, $tmpdir;

Thanks, Bart for pointing out the rename function that I forgot, but I
still can't get it to work. I've spent 4 hours trying to get this to
work and studying perlsub. I even tried "chdir $tmpdir;" before calling
out the sub with &find, and still nothing changes. 

And what's that "$tmpdir;" at the end for anyhow? I'm not used to seeing
braces followed by a comma instead of a semicolon. And don't I need a };
to close the block. This has me confused.

To make it crystal clear, here is my file/directory structure...

"wkdir" is my parent directory and the only file or directory that I
know the name of. Within that directory is another directory. Now,
within this directory, it could either be a file or directory that has
other files and directories. And I want to search though the entire tree
and change any filenames that are .pl, .exe. or .cgi to .txt.

Can you help a little further please?

--Dennis



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

Date: Tue, 20 Feb 2001 22:01:53 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Change unknown filenames
Message-Id: <dpp59t4lgcdtm4hrmbk76c3o6sfmohhj5l@4ax.com>

BUCK NAKED1 wrote:

>And what's that "$tmpdir;" at the end for anyhow? I'm not used to seeing
>braces followed by a comma instead of a semicolon. And don't I need a };
>to close the block. This has me confused.

This is the format of the find call:

	find sub { ... whattodo ... }, @DIRLIST;

The "}" is the closing of the block that belongs to the (callback) sub
that is the first parameter for the find call. That sub is calld once
for every file and directory it finds. Try it:

     use File::Find;
     find sub { print "$_\t@{[-f $_?'F':'D']}\t$File::Find::name\n" },
        @ARGV;

and try passing this scriplet some directory paths from the command
line. You'll soon  see what this does.

> I even tried "chdir $tmpdir;" before calling
>out the sub with &find, and still nothing changes. 

It chdirs by itself right before starting its descent.

I hope $tmpdir is an absolute path, or it might not work 100% reliably
for some subs, because $File::find::name won't be a valid path.

-- 
	Bart.


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

Date: 20 Feb 2001 22:12:30 GMT
From: anotherway83@aol.com (Another Way)
Subject: Re: chop and chomp
Message-Id: <20010220171230.04899.00000413@ng-ch1.aol.com>

er...i was being flamed?

i thought everybody was being pretty polite, thanks to all those who replied

peace


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

Date: 20 Feb 2001 20:21:55 GMT
From: abigail@foad.org (Abigail)
Subject: Re: covert =?iso-8859-1?Q?=22=F8Y=22=22?= (embeded hex) to F89F how?
Message-Id: <slrn995kf2.rpv.abigail@tsathoggua.rlyeh.net>

Ty (leinfidel@netscape.net) wrote on MMDCCXXX September MCMXCIII in
<URL:news:3A92AB8C.4040909@netscape.net>:
@@ Hello all,
@@ 
@@ I using regular expressions to deal with some documents that have a 
@@ number of true embeded hex codes such as "ψY"".  I have no problem 
@@ finding them using \x, but I need to replace them with their true hex code.
@@ 
@@ For the life of me I can find a way to figure out the value of ψY" in 
@@ hex,  within a script, anyone know how?
@@ 
@@ The only reason I know it's F89F is I dropped it in a hex editor...


I'm not sure which bytes are "true" hex codes and which aren't,

Anyway, the following should work:

    s/[\x00-\xFF]/sprintf "%02X" => ord $1/eg;

as long as you don't use Unicode.

You may want to replace [\x00-\xFF] with your idea of "true" hex codes.


Abigail
-- 
use   lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";


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

Date: Tue, 20 Feb 2001 20:44:17 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: covert =?iso-8859-1?Q?=22=F8Y=22=22?= (embeded hex) to F89F how?
Message-Id: <slrn995m36.rk.tjla@thislove.dyndns.org>

I was shocked! How could Abigail <abigail@foad.org>
say such a terrible thing:

>Anyway, the following should work:
>
>    s/[\x00-\xFF]/sprintf "%02X" => ord $1/eg;

Not quite, you need to capture $1 before you can refer to it:

s/([\x00-\xFF])/sprintf "%02X" => ord $1/eg;

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
If a free society cannot help the many who are poor,
it cannot save the few who are rich.
		-- John F. Kennedy, Inaugural Address, 20 January 1961


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

Date: 20 Feb 2001 20:54:01 GMT
From: abigail@foad.org (Abigail)
Subject: Re: covert =?iso-8859-1?Q?=22=F8Y=22=22?= (embeded hex) to F89F how?
Message-Id: <slrn995mb9.rpv.abigail@tsathoggua.rlyeh.net>

Gwyn Judd (tjla@guvfybir.qlaqaf.bet) wrote on MMDCCXXX September MCMXCIII
in <URL:news:slrn995m36.rk.tjla@thislove.dyndns.org>:
`' I was shocked! How could Abigail <abigail@foad.org>
`' say such a terrible thing:
`' 
`' >Anyway, the following should work:
`' >
`' >    s/[\x00-\xFF]/sprintf "%02X" => ord $1/eg;
`' 
`' Not quite, you need to capture $1 before you can refer to it:
`' 
`' s/([\x00-\xFF])/sprintf "%02X" => ord $1/eg;


I actually meant to write:

   s/[\x00-\xFF]/sprintf "%02X" => ord $&/eg;



Abigail
-- 
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: Tue, 20 Feb 2001 21:15:42 GMT
From: "Bertilo Wennergren" <bertilow@chello.se>
Subject: Re: Execution external programs
Message-Id: <28Bk6.1235$MU.24181@nntp1.chello.se>

<blah@blah.blah.invalid>:

> Kuba Banaszak <J.banaszak@shu.ac.uk> wrote:
> > For example I am trying to start notepad.exe by using perl function
> > system()

> > system("notepad.exe myfile.txt");

> > The notepad is starting and opening myfil.txt but the results are not
> > visible on the screen (process is starting)

> > What's wrong?

> What are you talking about?  What results?  You do realize that
> nothing after the "system" statement in your perl script will be
> executed until *after* notepad is closed, right?

I just tried this on my system. The file "myfile.txt" was loaded
into the editor I specified, and then the rest of the script was
executed without waiting for anything.

-- 
#####################################################################
                         Bertilo Wennergren
                 <http://purl.oclc.org/net/bertilo>
                        <bertilow@chello.se>
#####################################################################




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

Date: Tue, 20 Feb 2001 11:10:15 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: FAQ 4.48:   How do I select a random element from an array?
Message-Id: <3A92C117.5AD9004A@stomp.stomp.tokyo>

Gwyn Anno Judd wrote:
 
> Anno Gwyn Siegel wrote:
> > Godzilla! wrote:
 
> > Fascinating.  Firm self-confidence, justified by absolutely nothing.
 
> Don't worry about it old man, she's quite insane. 
> Come away before you get some on you.

 
You really think this is so? I would quickly
agree I am firmly self-confident lending well
to my stability of personality.

Would you rather I address you as "Anno" during
these times you are pretending to be female?
This name, Anno, does hold a feminine quality,
don't you think, Frank?

Godzilla!


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

Date: Tue, 20 Feb 2001 19:57:39 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: FAQ 4.48:   How do I select a random element from an array?
Message-Id: <x7elwtjff0.fsf@home.sysarch.com>

>>>>> "G" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:

  G> Gwyn Anno Judd wrote:
  >> Anno Gwyn Siegel wrote:
  >> > Godzilla! wrote:
 
  >> > Fascinating.  Firm self-confidence, justified by absolutely nothing.
 
  >> Don't worry about it old man, she's quite insane. 
  >> Come away before you get some on you.

 
  G> You really think this is so? I would quickly
  G> agree I am firmly self-confident lending well
  G> to my stability of personality.

  G> Would you rather I address you as "Anno" during
  G> these times you are pretending to be female?
  G> This name, Anno, does hold a feminine quality,
  G> don't you think, Frank?

well, you blew it this time. anno and gwyn are just alter egos of the
alaskan electrician. or imagining they are the same poster is another
indication of the amount of cerebrum damage you have.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Tue, 20 Feb 2001 12:30:51 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: FAQ 4.48:   How do I select a random element from an array?
Message-Id: <3A92D3FB.6F9877E2@stomp.stomp.tokyo>

Uri Guttman wrote:
 
> Godzilla! wrote:
 
> > Gwyn Anno Judd wrote:
> > > Anno Gwyn Siegel wrote:
> > > > Godzilla! wrote:

> > > > Fascinating.  Firm self-confidence, justified by absolutely nothing.

> > > Don't worry about it old man, she's quite insane.
> > > Come away before you get some on you.
 
> > You really think this is so? I would quickly
> > agree I am firmly self-confident lending well
> > to my stability of personality.

> > Would you rather I address you as "Anno" during
> > these times you are pretending to be female?
> > This name, Anno, does hold a feminine quality,
> > don't you think, Frank?

> well, you blew it this time.

Oh my! You must be observing my boyfriend and myself
with a very powerful geostationary satellite telescope!
Clearly not the near-sighted Hubble. Listen Uri, we do
have homemade videos available if you are interested.

Uri, have I ever told you of my adventures as a post-grad
student working in my university's geodesy lab? Rather
fun! We enjoy lots of nudist colonies around here.

> anno and gwyn are just alter egos of the alaskan electrician.

Ah yes, the infamous Alaskan Incident, an incident involving
a bunch of you boys huddling then developing and executing a
game plan of committing crimes against a man and his family. 

Hut! Hut! Hike!  FUMBLE!

> or imagining they are the same poster is another
> indication of the amount of cerebrum damage you have.

I've never denied being brain dead. I do well though,
pretending to be a person capable of thinking. I most
certainly do a better job of pretending than does our
resident man/woman of a thousand ugly mugs.

Sometimes you are humorous Uri. However, I am always
annoyed by having to invest so much effort into 
correcting your newsreader's quoting style.

Godzilla!


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

Date: Tue, 20 Feb 2001 19:27:05 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: FAQ 4.49:   How do I permute N elements of a list?
Message-Id: <dyzk6.291$zN2.189028864@news.frii.net>

In article <96t8pv$k91@netnews.hinet.net>,
John Lin <johnlin@chttl.com.tw> wrote:
>"PerlFAQ Server" wrote
>>   How do I permute N elements of a list?
>
>Ah, I remember this FAQ has come up several weeks ago.
>The PerlFAQ server has finished a cycle?  So soon.
>
>

There are 303 files in the rotation right now.  4 are posted every day.
That makes the rotation 75.75 days or about 2.5 months per 'lap.'

Responses have all been positive and helpful.  And the editorial
feedback has been useful for improving the clarity and appropriateness
of the PerlFAQ.  Your changes have been encorproated and submitted
to the Pumpking and are being folded in for the 5.6.1 release.

Thanks to all of you for making the PerlFAQ such a success.

chris
-- 
    This space intentionally left blank


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

Date: Tue, 20 Feb 2001 12:10:58 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: FAQ 4.49:   How do I permute N elements of a list?
Message-Id: <3A92CF52.2A31874B@stomp.stomp.tokyo>

Chris Fedde wrote:

> John Lin wrote:
> > PerlFAQ Server wrote:

> > >   How do I permute N elements of a list?

> > Ah, I remember this FAQ has come up several weeks ago.
> > The PerlFAQ server has finished a cycle?  So soon.
 
> There are 303 files in the rotation right now.  4 are posted every day.
> That makes the rotation 75.75 days or about 2.5 months per 'lap.'
 
> Responses have all been positive and helpful.  And the editorial
> feedback has been useful for improving the clarity and appropriateness
> of the PerlFAQ.  Your changes have been encorproated and submitted
> to the Pumpking and are being folded in for the 5.6.1 release.
 
> Thanks to all of you for making the PerlFAQ such a success.
 
I wouldn't be so quick to announce PerlFAQ a success. However
it is appropriate to express gratitude to those who took 
time to critique. This is professional behavior.

Nonetheless you folks of this "perlfaq server" are displaying
a lack of knowledge regarding professional editing of documents
to be publically published. You have indicated some critiques
will be used for modification of FAQ documents. Your failure in
professional editing is in not publishing these new FAQ documents
for critique as well. Doing this, a pre-release of new documentation
for further critique, is professionally prudent, just as it is
professionally prudent to run a spell check program and a grammar 
check program on all announcements and documents, to be made public.
Documents of this type should always be professionally perfect
and reflect a high degree of professional pride.

A moderate change of topic, my presumption is your FAQ regarding
CGI.pm and read / parse routines has been completely trash canned
and will reflect reality, with a completely new and accurate FAQ.

Incidently, what does this "Pumpking" expression mean? I am unfamiliar
with this slang term and am a firm believer in clear and concise
communication within a public forum. What does it mean?

Godzilla!


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

Date: Tue, 20 Feb 2001 13:19:56 -0800
From: Frank Hanny <fchanny@lbl.gov>
Subject: inconsistent behavior in CGI->param()?
Message-Id: <3A92DF7C.CD630C3B@lbl.gov>

In the following program, I would expect the contents of parameters 'a'
and 'b' to be the same. Instead, 'a' contains only 3 elements, while 'b'
contains 6. Is this a bug or a feature? 

Thanks,

Frank Hanny 

#!/usr/local/bin/perl
use strict;
use CGI(); 

my $q;

$q = CGI->new(); 

$q->param( 'a', 0, undef, 1, undef, 2 );
$q->param( -name=>'b', -value=>[ 0, undef, 1, undef, 2 ] );

print
    $q->header(),
    $q->start_html(),
    $q->dump(),
    $q->end_html();


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

Date: 20 Feb 2001 20:35:34 GMT
From: "Martijn Mulder" <soso@open.net>
Subject: Interpolate filehandle
Message-Id: <01c09b7d$1ce8a5c0$fcf0f1c3@default>

I expect the following code to print

   It's only Rock & Roll but I like it

but I end up with

   It's only $a but I like it

How can I interpolate the list I read in from filehande DATA?
Thanks, Martijn

$a = "Rock & Roll";
print <DATA>;
__DATA__
   It's only $a but I like it


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

Date: Tue, 20 Feb 2001 21:55:56 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Interpolate filehandle
Message-Id: <slrn995pvb.up.tjla@thislove.dyndns.org>

I was shocked! How could Martijn Mulder <soso@open.net>
say such a terrible thing:
>I expect the following code to print
>
>   It's only Rock & Roll but I like it
>
>but I end up with
>
>   It's only $a but I like it

$a = "Rock & Roll";
print map {$_ = '"'.$_.'"'; eval} <DATA>;
__DATA__
   It's only $a but I like it

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The gods gave man fire and he invented fire engines.  They gave him
love and he invented marriage.


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

Date: Tue, 20 Feb 2001 19:33:42 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Java servlets and CGI
Message-Id: <qEzk6.292$zN2.189825024@news.frii.net>

In article <3A928C16.C30CDF50@cecioni.com>,
John Smith  <jsmith@cecioni.com> wrote:
>
>I couldn't find a Servlet newsgroup. Java newsgroups are too generic
>and this question is probably too different from what CGI people normally
>do.
>
>On the other hand, CGI is mostly done in Perl, so Perl gurus are
>much more likely to have a valid answer to this question, IMO.
>

If want to find people who can answer your questions about CGI I
think a better group would be comp.infosystems.www.authoring.cgi

good luck
chris
-- 
    This space intentionally left blank


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

Date: Tue, 20 Feb 2001 21:06:43 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: MacPerl help for a newbie
Message-Id: <slrn995n32.rk.tjla@thislove.dyndns.org>

I was shocked! How could mbb <michael.beardsley@dartmouth.edu>
say such a terrible thing:

>Using AppleScript I've managed to change the File Type and Creator Type to
>MS Excel and Excel happily opens up the files with no complaints.  However,
>since I don't really know what I'm doing, I can't figure out how to ask it
>to rename all the file's last 3 characters to "xls".  this step is important
>for compatibility with Windows machines.

Well there are a few things you can do. Firstly Mac's don't in general
care about file extensions so you could just ignore them. This avoids
the need to learn Perl altogether :). Secondly MacPerl comes with a
whole heap of documentation. What you want to do is use the 'rename'
function, which renames a file. Then all you need to do is figure out
what the original filename is and what name you want to change it to.
You can most easily do this in Perl using a regex. Assuming they are all
in the same directory. The following code is untested.

while (<*.wk1>)
{
    # $_ holds the name of the file

    # get the new filename in '$new'
    ($new = $_) =~ s/wk1$/xls/;

    rename $_, $new or die "Cannot rename $_\n";
}

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
It is illegal to drive more than two thousand sheep down Hollywood
Boulevard at one time.


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

Date: Tue, 20 Feb 2001 17:44:09 -0500
From: "mbb" <mbeards@altavista.com>
Subject: Re: MacPerl help for a newbie
Message-Id: <96urs0$jgp$1@merrimack.Dartmouth.EDU>

Thank you for the pointers.  I know that the Mac OS could care less about a
file name extension, but Windows does care and these files are going to be
accessed by both platforms.  So, it does matter.

Conversely, I suppose I could try using Perl on a Windows machine...???

I go forward from here.

Thanks again,

mike
"Gwyn Judd" <tjla@guvfybir.qlaqaf.bet> wrote in message
news:slrn995n32.rk.tjla@thislove.dyndns.org...
> I was shocked! How could mbb <michael.beardsley@dartmouth.edu>
> say such a terrible thing:
>
> >Using AppleScript I've managed to change the File Type and Creator Type
to
> >MS Excel and Excel happily opens up the files with no complaints.
However,
> >since I don't really know what I'm doing, I can't figure out how to ask
it
> >to rename all the file's last 3 characters to "xls".  this step is
important
> >for compatibility with Windows machines.
>
> Well there are a few things you can do. Firstly Mac's don't in general
> care about file extensions so you could just ignore them. This avoids
> the need to learn Perl altogether :). Secondly MacPerl comes with a
> whole heap of documentation. What you want to do is use the 'rename'
> function, which renames a file. Then all you need to do is figure out
> what the original filename is and what name you want to change it to.
> You can most easily do this in Perl using a regex. Assuming they are all
> in the same directory. The following code is untested.
>
> while (<*.wk1>)
> {
>     # $_ holds the name of the file
>
>     # get the new filename in '$new'
>     ($new = $_) =~ s/wk1$/xls/;
>
>     rename $_, $new or die "Cannot rename $_\n";
> }
>
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> It is illegal to drive more than two thousand sheep down Hollywood
> Boulevard at one time.




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

Date: 20 Feb 2001 22:00:54 GMT
From: dha@panix2.panix.com (David H. Adler)
Subject: Re: Newbie Question:  How to upload a file from a form WITHOUT using cgi.pm?
Message-Id: <slrn995q8m.m5g.dha@panix2.panix.com>

On Sun, 18 Feb 2001 14:42:30 +1000, Gregory Toomey <gtoomey@usa.net> wrote:

>"Klondike Wolf" <KlondikeWolf@mailops.com> wrote in message
>news:fu8u8ts18nsbovrt52fssfcc6ct6mrct1l@4ax.com...
>> I'm a newbie (duh) ... I need to be able to upload a file through a web
>> form using a Perl script ... but cgi.pm is not installed on the server,
>> and the server owner refuses to install any modules.

>One way around this is to copy the modules you require (from cpan.org)
>into your local directories.

Although, if you do not have CGI.pm installed, chances are that the
version of Perl installed is *really* old (or *really* badly installed).
CGI.pm has been part of the Standard Distribution for a *long* time.

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
I didn't jump.  I took a tiny step and the conclusions were right
there.	- Buffy


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

Date: 20 Feb 2001 14:48:31 -0800
From: David Wake <dwake@stanford.edu>
Subject: Newbie:  can Perl make HTTP connections?
Message-Id: <874rxp0y4g.fsf@herbie.Stanford.EDU>

Hi there,

I'm a Perl newbie, and I want to write a Perl script which will do
comparison shopping (go to different websites, search for the price,
etc.).  How do I tell a Perl script to make a HTTP connection to a
website and download an HTML page?

Thx,

David


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

Date: Tue, 20 Feb 2001 22:55:11 GMT
From: sjs@linux.ca (Steven Smolinski)
Subject: Re: Newbie:  can Perl make HTTP connections?
Message-Id: <slrn9961tu.5pn.sjs@ragnar.stevens.gulch>

David Wake <dwake@stanford.edu> wrote:
> I'm a Perl newbie, and I want to write a Perl script which will do
> comparison shopping (go to different websites, search for the price,
> etc.).  How do I tell a Perl script to make a HTTP connection to a
> website and download an HTML page?

perl -MLWP::Simple -e 'getprint("http://www.slashdot.org/")'

Make sure the LWP Bundle from CPAN is installed, and begin the
adventure with:

perldoc LWP

Steve
-- 
Steven Smolinski => http://www.steven.cx/


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

Date: 20 Feb 2001 20:44:22 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: PROPOSAL: Graphics::ColorNames
Message-Id: <96ukv6$vd$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Abigail
<abigail@foad.org>],
who wrote in article <slrn994h7c.ii5.abigail@tsathoggua.rlyeh.net>:
> Why would they need to be pretty ugly? use AnyDBM_File should take care
> of most of the problems, right?

use AnyDBM_File can only create problems, not take care of them.  You
install another DBM - and all your data disappears in the thin air -
without any warning or explanation...

Ilya


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

Date: 20 Feb 2001 20:08:46 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Specifying the length of regular expression
Message-Id: <slrn995jme.rpv.abigail@tsathoggua.rlyeh.net>

Greg Bacon (gbacon@HiWAAY.net) wrote on MMDCCXXX September MCMXCIII in
<URL:news:t959u6jc7c9od0@corp.supernews.com>:
## In article <slrn995941.ii5.abigail@tsathoggua.rlyeh.net>,
##     Abigail <abigail@foad.org> wrote:
## 
## : Greg Bacon (gbacon@HiWAAY.net) wrote on MMDCCXXX September MCMXCIII in
## : <URL:news:t952ias50rh9ae@corp.supernews.com>:
## :
## : && I would argue the a module like the one you've described is
## : && unnecessarily limited.  Giving the user the option of providing a
## : && coderef to check individual strings or filter lists of strings would
## : && yield considerably more flexibility.
## : 
## : Yes, it would. But I doubt calling a code ref to each line of the monthly
## : weblogs of a busy server makes many happy users.
## 
## The users are happy when r3\/\/+ is happy, right? :-)  I wrote "or
## filter lists of strings" to answer the concern about calling a code
## ref for each element in the list.


You'd think r00+ is happy if you pass the monthly weblog as a list 
of strings to the supplied coderef?

*This* root wouldn't. ;-)


Abigail
-- 
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
          for (s;s;s;s;s;s;s;s;s;s;s;s)
              {s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'


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

Date: 20 Feb 2001 21:32:06 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Specifying the length of regular expression
Message-Id: <eli$0102201628@qz.little-neck.ny.us>

In comp.lang.perl.misc, Greg Bacon <gbacon@hiwaay.net> wrote:
>      <ianb@ot.com.au> wrote:
> : For example, you are using a third-party module which
> : requires you to specify a regex (or a file containing hundreds of regexes)
> I would argue the a module like the one you've described is
> unnecessarily limited.  Giving the user the option of providing a
> coderef to check individual strings or filter lists of strings would
> yield considerably more flexibility.

What if the regex is being used by split()? Will you provide a patch
to perl so that split() will use coderefs? How will that work
efficently?

Elijah
------
marvels at how hard people are fighting the 'I need a regex' here


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

Date: 20 Feb 2001 20:48:52 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: term::readline gnu/stub current_history
Message-Id: <96ul7k$121$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Mark Hamlin \(News ax\)
<mark.hamlin@artdigital.co.uk>],
who wrote in article <96thmu$o52$1@pheidippides.axion.bt.co.uk>:
> I've adapted Perl Cookbook Recepie 15.4: vbsh to query the history on
> command. The script runs, but when I enter 'shi' to query the history I get
> the error:
> 
> Can't locate object method "GetHistory" via package "Term::ReadLine::Stub"
> at termpl line 17, <FIN> chunk 2.

  perldoc Term::ReadLine

Put your chunk inside 'eval' to take into account differences between
different flavors of Term::ReadLine.

Ilya


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

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 V10 Issue 322
**************************************


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