[10428] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4021 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 20 15:03:47 1998

Date: Tue, 20 Oct 98 12:00:28 -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           Tue, 20 Oct 1998     Volume: 8 Number: 4021

Today's topics:
    Re: All perl works with CGI????? <jdporter@min.net>
    Re: Backgrounding long processes? (Daniel Beckham)
    Re: Backgrounding long processes? <barnett@houston.Geco-Prakla.slb.com>
        Camel book: References. <misc.word.corp@pobox.com>
    Re: Camel book: References. <uri@camel.fastserv.com>
    Re: CGI problem...probably a simple answer. <100mile@bcinternet.net>
        comma formatting numbers <smith.will@epa.gov>
    Re: comma formatting numbers (Larry Rosler)
    Re: comp.lang.perl.win32?? <keithmur@mindspring.com>
    Re: End of File..... <Tony.Curtis+usenet@vcpc.univie.ac.at>
        Environement variables and PATH (Nestor Florez)
        Example Threads <wells@cedarnet.org>
    Re: Glob Prob <minich@globalnet.co.uk>
    Re: help shorten one-liner <uri@camel.fastserv.com>
    Re: help shorten one-liner <john_scrimsher@ex.cv.hp.com>
    Re: help shorten one-liner (Larry Rosler)
    Re: help shorten one-liner (Larry Rosler)
    Re: help shorten one-liner (Sean McAfee)
    Re: Help:  Looking for AI modules <john_scrimsher@ex.cv.hp.com>
    Re: how do you search subdirectories for a file? <perlguy@technologist.com>
    Re: how do you search subdirectories for a file? (Daniel Beckham)
    Re: IE problem when download from a cgi script <rootbeer@teleport.com>
    Re: New Module: File::Finder -- OO version of File::Fin <jdporter@min.net>
    Re: Newbie needs help transposing two words in a file <aqumsieh@matrox.com>
        Passing multiple arrays and hashes as parameter <pfung@mipos2.intel.com>
    Re: Passing multiple arrays and hashes as parameter (Larry Rosler)
    Re: Passing multiple arrays and hashes as parameter <jdf@pobox.com>
        perl win32 and sockets sundar_raman@mw.3com.com
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 20 Oct 1998 14:02:37 -0400
From: John Porter <jdporter@min.net>
Subject: Re: All perl works with CGI?????
Message-Id: <362CD03D.436F0DD9@min.net>

Steve Adams wrote:
> 
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);

Do yourself a favor and learn how to use CGI.pm.

-- 
John "Gashlycrumb" Porter

"A fugitive and lurid gleam
  Obliquely gilds the gliding stream." -- EG


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

Date: Tue, 20 Oct 1998 13:42:30 -0400
From: danbeck@eudoramail.com (Daniel Beckham)
Subject: Re: Backgrounding long processes?
Message-Id: <MPG.10969591b5799b14989692@news.supernews.com>

What about a system call of some sort?

In article <362CA8BB.A298172C@freerealtime.com>, 
dvongrad@freerealtime.com says...
> I'd like to background a long process and still have my script run,
> something like:
> 
> print "Script started.\n";
> `grep -c mystring my-big-file.txt &`; # background this
> print "Script ended.\n";
> 
> The print statements should execute one right after the other and the
> grep finishes whenever. However, I don't get the second print until grep
> is done. It's important that I be able to background the grep (or
> whatever command), but I'm not sure how to do this.
> 
> How would I go about implementing something like this on a Unix machine?
> 
> TIA,
> 
> Dave
> 
> 


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

Date: Tue, 20 Oct 1998 13:32:33 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Backgrounding long processes?
Message-Id: <362CD741.159ECB8@houston.Geco-Prakla.slb.com>

Daniel Beckham wrote:
> 
> What about a system call of some sort?
How about one.....
#!/usr/local/bin/perl -w
#
print "1: Going to sleep!\n";
print `(sleep 5; echo "1: done sleeping!") & `;
print "1: Awake again!\n";
 
 
print "2: Going to sleep!\n";
system '(sleep 5; echo "2: done sleeping!") & ';
print "2: Awake again!\n";
__END__

Yields:

dapd7:barnett [169] !$
junk11.perl
1: Going to sleep!
1: done sleeping!
1: Awake again!
2: Going to sleep!
2: Awake again!
dapd7:barnett [170] 2: done sleeping!

There is a 5 second pause (as dictated by 'sleep 5') between 2: Awake
again! and 2: done sleeping!

Is that what you were after?

You're next question, of course, should be why was perl waiitng, even
though I told it to background the process.  Well, examine the
difference between the two examples I gave you.

You should notice that one uses the backtick (`) operator, while the
other uses system.  So? you ask.  With the ` operator, perl returns the
results of the operation.  As such, perl will await its completion.

<aside> Without the print statement before the ` info., you will never
see 'done sleeping!'.</aside>

System, on the other hand, will fire off the process, and not wait for
it to finish since you backgrounded it using &.  Leave off the &, and
perl will wait, just like it does with the ` operator.

Make sense?

HTH.

Dave

> 
> In article <362CA8BB.A298172C@freerealtime.com>,
> dvongrad@freerealtime.com says...
> > I'd like to background a long process and still have my script run,
> > something like:
> >
> > print "Script started.\n";
> > `grep -c mystring my-big-file.txt &`; # background this
> > print "Script ended.\n";
> >
> > The print statements should execute one right after the other and the
> > grep finishes whenever. However, I don't get the second print until grep
> > is done. It's important that I be able to background the grep (or
> > whatever command), but I'm not sure how to do this.
> >
> > How would I go about implementing something like this on a Unix machine?
> >
> > TIA,
> >
> > Dave
> >
> >

-- 
Dave Barnett	Software Support Engineer	(281) 596-1434


Indecision is the key to flexibility.


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

Date: Tue, 20 Oct 1998 13:32:36 -0400
From: "misc.word.corp" <misc.word.corp@pobox.com>
Subject: Camel book: References.
Message-Id: <362CC934.55CC466F@pobox.com>

Two questions on references:

1) On p. 258 of the Camel Book, the authors use the following code to
illustrate "load[ing] an array from a function:

for $i (1 .. 10) {
	@tmp = somefunc ($i);
	$LoL[$i] = [ @tmp ];

What does "somefunc" refer to? A standard (builtin) perl function? A
user function (i.e. sub)? 

What sort of function do the authors have in mind? (It's not enumerated
or provided via an example).

2) I'm trying to create a simple DBM database out of a multidimensional
associative array (aka Hash-of-Hash). I'll probably use no more than
four key/value pairs.
-Would a Hash-of-Hash of this size be better (and easier) to implement
via a multidimensional array (aka List-of-List in Camel)?

-A more general question: Would it be easier to write this in C?
References in Perl seem a bit ornery, at least as presented in Camel.
I'm sure that they offer many advantages over their complements in C.
What exactly are those advantages, anyway?


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

Date: 20 Oct 1998 13:42:16 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: "misc.word.corp" <misc.word.corp@pobox.com>
Subject: Re: Camel book: References.
Message-Id: <sarems3nn9j.fsf@camel.fastserv.com>

>>>>> "mwc" == misc word corp <misc.word.corp@pobox.com> writes:

  mwc> Two questions on references: 1) On p. 258 of the Camel Book, the
  mwc> authors use the following code to illustrate "load[ing] an array
  mwc> from a function:

  mwc> for $i (1 .. 10) { @tmp = somefunc ($i); $LoL[$i] = [ @tmp ];

  mwc> What does "somefunc" refer to? A standard (builtin) perl
  mwc> function? A user function (i.e. sub)?

having a builting with the name of somefunc would be kind of silly,
wouldn't it? it obviously is a placeholder name (many others would have
used foo, but if you didn't get the code above i won't use foo on
you). 

  mwc> What sort of function do the authors have in mind? (It's not
  mwc> enumerated or provided via an example).

it means a function that returns a list of values. the example is
showing how to build up the LoL with a function that returns a single
list.

  mwc> 2) I'm trying to create a simple DBM database out of a
  mwc> multidimensional associative array (aka Hash-of-Hash). I'll
  mwc> probably use no more than four key/value pairs.  -Would a
  mwc> Hash-of-Hash of this size be better (and easier) to implement via
  mwc> a multidimensional array (aka List-of-List in Camel)?

it depends on the types of the keys. if they are numeric, a LoL or LoH
might be fine. you need to give more concrete examples of your data and
structures. 

  mwc> -A more general question: Would it be easier to write this in C?
  mwc> References in Perl seem a bit ornery, at least as presented in
  mwc> Camel.  I'm sure that they offer many advantages over their
  mwc> complements in C.  What exactly are those advantages, anyway?

apples and oranges. i would never program hash and complex tree stuff in
C if i could help it. perl does most of the work for you while in C you
have to manage every tiny little bit (sic) yourself. and refs in perl
are no more complicated than pointers in C in most cases. i have seen
simple and complex versions of both.

hth,

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Tue, 20 Oct 1998 11:53:21 -0700
From: "100 Mile NetShop" <100mile@bcinternet.net>
Subject: Re: CGI problem...probably a simple answer.
Message-Id: <362cdc52.0@news.vphos.net>

open (fwfile, ">>fw2.log")

I think you need the >> in there. that way the script continues to write to
the file. Without the >> or with > it will make a new file everytime.


Kevin Falcone wrote in message ...
>Well, this isn't a perl problem, its really an HTML program, instead
>of a newline, you need to be printing a <br> which your browser knows
>to interpret as a newline
>-kevin
>
>On Tue, 20 Oct 1998, piercew@netscape.net <piercew@netscape.net> wrote:
>>I created the following as a way to parse a firewall log file. For some
>>reason I can't get it to place each item on a new line:
>>
>>#begin file
>>#!/usr/bin/perl
>>
>>print "Content-type: text/html\n\n";
>>print "<HTML>";
>>print "<BODY>";
>>
>>open (fwfile, "fw2.log") || die "Couldn't open file: $!";
>>
>>@data = split(/ /, <fwfile>);
>>foreach $line (@data) {
>>   print "$item\n";
>>   }
>>
>>close (fwfile);
>>print "</BODY>";
>>print "</HTML>";
>>
>>
>> I've tried placing the carrage return on a separate line and it doesn't
work
>>either.  I know the data is being broken up, because I can print something
>>between each item.
>>
>> Thanks for any assistance that can be provided,
>>
>--
>Kevin Falcone
>kevinfal@seas.upenn.edu
>
>If a cow laughed, would milk come out her nose?




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

Date: Tue, 20 Oct 1998 14:04:25 -0400
From: "William Smith" <smith.will@epa.gov>
Subject: comma formatting numbers
Message-Id: <70ijco$prn1@valley.rtpnc.epa.gov>

I wonder if anyone out there has a one line perl routine to format a number
with comma's.  EX: 1234567  --> 1,234,567
For lack of anything better, I wrote this quick and dirty comma function.

$num = 1234567;
print comma($num);  # prints 1,234,567

Thanks for any perls of wisdom.


sub comma
{
  local($x) = pop @_;
  local($a,$n,$i);
  $n = length($x);
  for ($i=0; $i < $n; $i++) {
    $a = ',' . $a if ($i && ($i % 3 == 0));
    $a = substr($x,$n-$i-1,1) . $a;
    }
  return $a;
}





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

Date: Tue, 20 Oct 1998 11:41:50 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: comma formatting numbers
Message-Id: <MPG.109679468619b611989829@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <70ijco$prn1@valley.rtpnc.epa.gov> on Tue, 20 Oct 1998 
14:04:25 -0400, William Smith <smith.will@epa.gov> says...
> I wonder if anyone out there has a one line perl routine to format a number
> with comma's...
> Thanks for any perls of wisdom.

perlfaq5:  "How can I output my numbers with commas added?"

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


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

Date: Tue, 20 Oct 1998 12:14:33 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: comp.lang.perl.win32??
Message-Id: <362CC4F9.C48DE8C5@mindspring.com>

Craig Berry wrote:
> 
> Jim Brewer (jimbo@soundimages.co.uk) wrote:
> : cberry@cinenet.net (Craig Berry) writes:
> : > : There are several perl issues that would be of interest only to those doing
> : > : win32 perl programming and not to the rest of the perl community.
> : >
> : > Examples?  And why win32 as opposed to any other particular architecture
> : > or OS?
> :
> : Regarding the second point: The installed base. Unix people are not
> : particularly pleased with Bill and his products, and many of the
> : people beginning to use Perl are from his prison. As a result, there
> : is a high level of basic misunderstanding about what Perl is and does
> : relative to the experience and unserstanding of this particular
> : group. There is also a high degree of ignorance about Unix and the
> : tools philosophy and how that relates to Win32 users. Putting the
> : Win32 community into a targeted group would reduce the pointless
> : postings that often make their way into c.l.p.misc.
> 
> Interesting points.  My counter is that if we segregate the win32 users
> into a 'ghetto' of sorts, how are they expected to learn about the
> underlying Unix/tools philosophy?  I'm somehow reminded of the politically
> explosive native language primary education debate in California -- is it
> doing a student a favor to delay his/her exposure to the language in which
> he/she must become skilled in order to succeed?
This is what was bothering me, but Craig said it better than I could.

Speaking as one who runs Perl 90% of the time on my Win95 machine
(gasp!) I agree 100%.  I want to be exposed to the Perl/Unix "old
hands".  If I get a disparaging remark occasionally about my choice
(well, not really) of OS, well, I'm a big boy.  The language is the
same, except for modules, and we have a group for that.  For anything
really implementation-specific, I should still be able to get answers
here, or in ActiveState's groups.

And I'm not at all sure it's a bad idea for the Unix/Perl folks to get a
glimpse of what's going on in the Death Star, I'm sorry, Windows world
vis-a-vis Perl.


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

Date: 20 Oct 1998 20:30:03 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: End of File.....
Message-Id: <83ems3m6hg.fsf@vcpc.univie.ac.at>

Re: End of File....., Darren <dward@pla.net.au> said:

Darren> What methods do people use for end of file detection
Darren> on ascii flat file?  The way I tried seems to miss
Darren> occasionally for a weird reason and I'd like a
Darren> better answer.

while (<HANDLE>) {
    ...;
}

works for me.  Are you perhaps doing double reads somehow?

How do you expect us to guess?  Why not post the code that
demonstrates this behavious and then...

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: 20 Oct 1998 18:32:46 GMT
From: nestor@sd.cadence.com (Nestor Florez)
Subject: Environement variables and PATH
Message-Id: <70il0e$1qh$1@news.cadence.com>



I am runnig a html that calls a perl/cgi program.  The whole process
is to archive some files using an archiver program in our environment.
The html ask the user to enter the path to the files to archive
and the path of where to put the newly archived files.  

My problem is that when I call the archiver program it can not find it.
If I call the archive program with a fullpath it finds it, but the archiver
program, calls other utilities that are not found because certain path and
environment variables are unknow when running a cgi/perl script because at
that moment the user is "nobody".  I know that if I run the utility as a 
perl script and not a cgi/perl script it works because it assumes my path 
and environment variables.

How can I, via cgi/perl tell the system to "source" the .cshrc of the user 
"nobody" so that it can find all the environment variables and the path
nescessary to run the tools I need to run.  Is this possible?  If this is 
too confusing I will try to rewrite the problem.

Thanks,

Nestor


-- 
______________________________________________________________________
Nestor Alberto Florez Torres  | "Authority Gone to one's head is the |
                              |  greatest enemy of thruth." Einstein |
                              |---------------------------------------


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

Date: Tue, 20 Oct 1998 11:46:01 -0500
From: Steve Wells <wells@cedarnet.org>
Subject: Example Threads
Message-Id: <362CBE49.EF62C1C1@cedarnet.org>

If anyone would be so kind as to point me to an
example program using threads in PERL I'd really
appreciate it.  I have never programmed using 
threads and would very much like to try my hand
at them...

TIA,
STEVE


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

Date: Tue, 20 Oct 1998 18:29:21 +0100
From: "Martin" <minich@globalnet.co.uk>
Subject: Re: Glob Prob
Message-Id: <70ij1b$2sn$1@newnews.global.net.uk>

>If you want to include files with no extensions, don't ask for files
>with extensions only.


Sorry! I realise what I've done done - me and my DOS ways <g>

<*> works fine, thanks

Martin




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

Date: 20 Oct 1998 13:29:10 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: help shorten one-liner
Message-Id: <sarhfwznnvd.fsf@camel.fastserv.com>

>>>>> "SM" == Sean McAfee <mcafee@pacman.rs.itd.umich.edu> writes:

  SM> In article <70i2pp$g3r$1@nnrp1.dejanews.com>,
  SM> <jkane@my-dejanews.com> wrote: [snip, wants to do something in
  SM> shortest number of lines]
  >> # The minus one is because the pattern matches itself in the
  >> script.  # I am keeping a copy of this line in it as an example for
  >> future referance.  a=`perl -ne 'print if /(;|{|}).*# .*/'
  >> perl_script | wc -l`;expr $a - 1 perl -ne 'if(/(;|{|}).*#
  >> .*/){$a++;print $a-1,"\n";}' perl_script |tail -1 perl -e
  >> 'while(<>){if(/(;|{|}).*# .*/){$a++;}}print $a-1,"\n";' perl_script

  >> Anybody have a better way of doing this??  The shortest one has to
  >> use 'wc -l' and `expr`.  I want to make this ONLY perl.

  SM> perl -lne '$a++ if /(;|{|}).*# .*/; END { print $a-1 }'
  SM> perl_script

  >> FYI: The pattern is looking for a semicolon, right curly brace, or
  >> left curly brace followed by anything, a #, a space, and finally
  >> anything more.  I figure that there will never be comments in the
  >> middle of a line that does not have one of these chars delimiting
  >> the end of it.  Am I wrong?

why are you both using alternation of single chars when you could use a
char class? it is easier to read and probably faster. and since you
don't use the grouping to grab the text, you could have used (?:) or
with a char class, remove the ().

so this is shorter and probably faster.

perl -lne '$a++ if /[;{}].*# .*/; END { print $a-1 }'


hth,

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Tue, 20 Oct 1998 10:29:38 -0700
From: "John P. Scrimsher" <john_scrimsher@ex.cv.hp.com>
Subject: Re: help shorten one-liner
Message-Id: <70iha5$ke@hpcvsnz.cv.hp.com>

<EMBARASSED>

Of course it won't work as written... I should have tested before posting...
needs the ";" at the end of the open, $a += should be $a++ and needs a ";"
at the end, and the print statement needs a ";" at the end.  my faux pas.

My apologies.  I will attempt to open my brain before my keyboard next time
:)

John Scrimsher
john_scrimsher@hp.com

Larry Rosler wrote in message ...
>[Posted to comp.lang.perl.misc and a copy mailed.]
>
>except compile.  I won't even discuss any other problems, as you
>couldn't have tested it as written before you posted it.
>
>I'll make believe that this didn't come from "one of us". :-)


Even HP employees aren't "always" perfect :-)

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




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

Date: Tue, 20 Oct 1998 10:35:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: help shorten one-liner
Message-Id: <MPG.109669a8bb08b72e989826@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <70i2pp$g3r$1@nnrp1.dejanews.com> on Tue, 20 Oct 1998 
13:22:01 GMT, jkane@my-dejanews.com <jkane@my-dejanews.com> says...
 ...
> I am trying to count the number of lines that have code and comments in them.
> i.e.
> 
>    $_ =~ tr/A-Z/a-z/;                  # Translate it to all lower case.
> 
> While NOT counting the lines that are ONLY comments, blank, or have a # as
> part of the text in the code.  (I am helping myself by putting spaces after
> all #'s that are comments.)  i.e.
> 
>  # Number of args left, plus the current one, give the remainder divided by 2.
>     # If there are not an even number of arguments, it MUST be wrong.
> 
>  if (($#ARGV+1)%2) {
> 
> Those four lines should NOT match at all!
> 
> So, my "personal" goal is to make a single command I can run from a prompt
> that will do this and keep it under 80 columns! :{ ) ...
> ... I want to make this ONLY perl.
> 
 ... 
> FYI:  The pattern is looking for a semicolon, right curly brace, or left curly
> brace followed by anything, a #, a space, and finally anything more.  I figure
> that there will never be comments in the middle of a line that does not have
> one of these chars delimiting the end of it.  Am I wrong?

You are quite wrong.  Comments can appear in the middle of expressions:

$x = $a + # This is a comment
   $b;

I will use your criterion that all your comments have a space after the 
'#', though that is not foolproof either:

$x = 'abc# this is not a comment'; #but this is.

In fact, no regex can determine what is a comment, as it is state-
dependent, as you see.  It takes a parser (or the Perl compiler :-).

That said, here is a Perl-only one-liner (and it is short):

perl -ne "++$n unless /^\s*(#|$)|#\S/; END { print qq{$n\n} }" files...

It is shorter to write 'if !/...' instead of 'unless', but uglier IMO.  
And there are lots of spaces you can elide if you are a masochist.  Here 
is the shortest I can do (Unix only, because of the single-quotes):

perl -ne '$n++if!/^\s*(#|$)|#\S/;END{print"$n\n"}' files...

where you may have to escape the '!' if your shell gives it special 
meaning.

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


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

Date: Tue, 20 Oct 1998 09:53:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: help shorten one-liner
Message-Id: <MPG.10965ff91bcacf14989825@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <70ibq0$qqk@hpcvsnz.cv.hp.com> on Tue, 20 Oct 1998 08:55:42 -
0700, John P. Scrimsher <john_scrimsher@ex.cv.hp.com> says...
> #!/usr/local/bin/perl
> 
> $filename = shift(@ARGV);
> open (FILE, "<$filename")
> while(<FILE>)
> {
>  $_ =~ s/\s//g;
>  $a += if(!(/\#/) && $_)
> }
> print "Lines in $filename: $a\n"
> 
> This should do everything that you are asking...

except compile.  I won't even discuss any other problems, as you 
couldn't have tested it as written before you posted it.

> ...
> John Scrimsher
> john_scrimsher@hp.com

I'll make believe that this didn't come from "one of us". :-)

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


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

Date: Tue, 20 Oct 1998 18:18:34 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: help shorten one-liner
Message-Id: <_t4X1.2763$fS.8482319@news.itd.umich.edu>

In article <sarhfwznnvd.fsf@camel.fastserv.com>,
Uri Guttman  <uri@camel.fastserv.com> wrote:
>>>>>> "SM" == Sean McAfee <mcafee@pacman.rs.itd.umich.edu> writes:
>  SM> In article <70i2pp$g3r$1@nnrp1.dejanews.com>,
>  SM> <jkane@my-dejanews.com> wrote: [snip, wants to do something in
>  SM> shortest number of lines]
>  >> a=`perl -ne 'print if /(;|{|}).*# .*/'
>  >> perl_script | wc -l`;expr $a - 1 perl -ne 'if(/(;|{|}).*#
>  >> .*/){$a++;print $a-1,"\n";}' perl_script |tail -1 perl -e
>  >> 'while(<>){if(/(;|{|}).*# .*/){$a++;}}print $a-1,"\n";' perl_script

>  SM> perl -lne '$a++ if /(;|{|}).*# .*/; END { print $a-1 }'
>  SM> perl_script

>why are you both using alternation of single chars when you could use a
>char class?

The regex was nasty-looking enough that I didn't look at it too closely; I
just pasted it into my own solution.

>so this is shorter and probably faster.

>perl -lne '$a++ if /[;{}].*# .*/; END { print $a-1 }'

To make it shorter yet, note that .* is superfluous at the end of a regex
(something I noticed after sending out my previous article).

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Tue, 20 Oct 1998 10:54:07 -0700
From: "John P. Scrimsher" <john_scrimsher@ex.cv.hp.com>
Subject: Re: Help:  Looking for AI modules
Message-Id: <70iio1$270@hpcvsnz.cv.hp.com>

Yes,  I have searched CPAN, but found nothing that seemed to meet my
requirements.  Did you have particular module or author in mind that I could
search on?


John Porter wrote in message <362CBCB0.AE6066C0@min.net>...
>Have you looked at CPAN?
>
>--
>John "Gashlycrumb" Porter
>
>"A fugitive and lurid gleam
>  Obliquely gilds the gliding stream." -- EG




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

Date: Tue, 20 Oct 1998 11:03:18 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: how do you search subdirectories for a file?
Message-Id: <362C6DF6.517F7810@technologist.com>

Try using File::Find.

Also, just because you opendir a directory, it doesn't "magically" read
it for you.  Look up the "readdir" function if you want to read the
contents.

HTH,
Brent
-- 
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: Tue, 20 Oct 1998 13:44:11 -0400
From: danbeck@eudoramail.com (Daniel Beckham)
Subject: Re: how do you search subdirectories for a file?
Message-Id: <MPG.109695f9cb770e06989693@news.supernews.com>

Possibly, you could give us a good way to do this?  That isn't very 
helpful... even if he did post in html.

In article <362CB3C8.D94A2D2E@min.net>, jdporter@min.net says...
> Rob Bridal wrote:
> > 
> > Make your own recursive thing.
> 
> A VERY bad idea.
> 
> Although not as bad as posting in HTML.
> 
> 


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

Date: Tue, 20 Oct 1998 18:24:08 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: IE problem when download from a cgi script
Message-Id: <Pine.GSO.4.02A.9810201123550.5534-100000@user2.teleport.com>

On Fri, 16 Oct 1998 iulian4992@my-dejanews.com wrote:

> This works fine with Netscape, but not with IE 4.x. 

If you're following the proper protocol but some browser or server doesn't
cooperate, then it's the other program's fault. If you're not following
the protocol, then it's your fault. If you aren't sure about the protocol,
you should read the protocol specification. If you've read it and you're
still not sure, you should ask in a newsgroup about the protocol.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 20 Oct 1998 14:12:52 -0400
From: John Porter <jdporter@min.net>
Subject: Re: New Module: File::Finder -- OO version of File::Find
Message-Id: <362CD2A4.99B57926@min.net>

Jonathan Feinberg wrote:
> 
> Whereas I've been idly wondering whether it might be nice to see
> 
>    sub wanted {
>       my ($fullname, $dir, $shortname) = @_;
>       # etc.
>    }
>    find( \&wanted, '/foo' );

Yes, even that would be an improvement -- although probably
not in terms of speed.

-- 
John "Gashlycrumb" Porter

"A fugitive and lurid gleam
  Obliquely gilds the gliding stream." -- EG


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

Date: Tue, 20 Oct 1998 14:05:53 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Newbie needs help transposing two words in a file
Message-Id: <Pine.SUN.3.96.981020135134.1096A-100000@tigre.matrox.com>

On Tue, 20 Oct 1998, Andrew M. Langmead wrote:

    > >I did not mean to imply that Larry doesn't test before he posts.
    > >The truth is that I thought that the email address supplied by my
    > >newsreader (aqumsieh@tigre.matrox.com) was actually fine. 
    > 
    > Which just proves Larry's original point, doesn't it.

Isn't this precisely what I stated above? Actually, the very next line
(which you deleted for some reason) says:

"That is why I questioned the truth of Larry's claim (which is indeed
true)."

So I already acknowledge that Larry's claim was true. Now what exactly is
the purpose of your posting?

If you are talking about whether I test my answers or not before I post,
then I believe I answered that before. Regarding my newsreader, I did not
bother to alter my email address in any way and just assumed that it would
do its job. It is not my problem that it didn't, and I certainly did not
know that the email address supplied by my (old) newsreader (see above)
would not work. Actually, it DOES work when I try to send an email to
myself or to other people within the same domain. Only from another domain
would it fail. Anyway, I switched newsreaders now and I made sure that the
address supplied is indeed correct.

    > -- 
    > Andrew Langmead
    > 

Honestly, I am still confused as the purpose of your posting!

--
Ala Qumsieh               email: aqumsieh@matrox.com
ASIC Design Engineer      phone: (514) 822-6000 x7581
Matrox Graphics Inc.      (old) webpage :
Montreal, Quebec          http://www.cim.mcgill.ca/~qumsieh





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

Date: Tue, 20 Oct 1998 10:20:06 -0700
From: "Poon Fung" <pfung@mipos2.intel.com>
Subject: Passing multiple arrays and hashes as parameter
Message-Id: <70hp6a$79d$1@scnews.sc.intel.com>

I am try to pass more than one array and hash table to a subroutine.
However, the version of perl my project is using does not support reference.
By the way, the version I have is 5.004 on HPUX.  Do you know of any way to
pass hash tables into subroutine without knowning it sizes ahead of time?




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

Date: Tue, 20 Oct 1998 11:17:28 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Passing multiple arrays and hashes as parameter
Message-Id: <MPG.1096738ee88581e1989828@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <70hp6a$79d$1@scnews.sc.intel.com> on Tue, 20 Oct 1998 
10:20:06 -0700, Poon Fung <pfung@mipos2.intel.com> says...
> I am try to pass more than one array and hash table to a subroutine.
> However, the version of perl my project is using does not support reference.
> By the way, the version I have is 5.004 on HPUX.  Do you know of any way to
> pass hash tables into subroutine without knowning it sizes ahead of time?

Surely you are wrong about that version.  Have you tried typing at the 
command line '/usr.../bin/perl -v' (specifically whatever is the actual 
path in the first line of your Perl program)?

I have used all versions of perl from 5.001 on HP-UX and have never had 
a problem with references.  You must be using Perl 4 and are being 
misled somehow about the version.

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


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

Date: 20 Oct 1998 20:51:56 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: "Poon Fung" <pfung@mipos2.intel.com>
Subject: Re: Passing multiple arrays and hashes as parameter
Message-Id: <m3zparhxrn.fsf@joshua.panix.com>

"Poon Fung" <pfung@mipos2.intel.com> writes:

> I am try to pass more than one array and hash table to a subroutine.
> However, the version of perl my project is using does not support reference.
> By the way, the version I have is 5.004 on HPUX.

Version 5.004 certainly does support references.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Tue, 20 Oct 1998 16:44:09 GMT
From: sundar_raman@mw.3com.com
Subject: perl win32 and sockets
Message-Id: <70iekq$r0f$1@nnrp1.dejanews.com>

i'm trying to either use the net::ping()/net::pingecho() functions that
come with perl (activestate ver 5.00502).  i receive an error message
indicating that the alarm() function is not implemented (i'm assuming
this is a problem with NT).

does anyone have any sourcecode that circumvents this issue, or is aware
of a ping module that can be used inside perl?

also, i've attempted to implement my own 'ping' in the meantime.  i'm doing
this by sending a stock message (the localtime) to the echo port on a remote
server (my code is below).  i'm using icmp as the protocol, with SOCK_RAW.  i
don't have a problem sending the packet, but get no response.  i keep getting
an error message at my recv() statement, and i don't get any details, just
"unknown error".

any help would be GREAT!  thanks a bunch.

******
($server, $port, $protocol) = @ARGV;
$server="www.microsoft.com" unless $server;
$port=7 unless $port; # echo port
$protocol = 1 unless $protocol; ## icmp=1, tcp=6, udp=17
$socktype = SOCK_RAW;

# Create the icmp socket
	socket (SOCKET, $AF_INET, $socktype, $protocol) ||
		die "socket could not be created: $! \n";

if ($server =~ /[a-zA-z]/) {
	connect(SOCKET, pack('Sna4x8', $AF_INET, $port,
(gethostbyname($server))[4]))
		or die "cant connect to server\n";
} else {
	@words  = split(/\./, $server);

	connect(SOCKET, pack('SnC4x8', $AF_INET, $port,
		$words[0], $words[1], $words[2], $words[3]))
		or die "cant connect to server\n";
}

# send a message to get an echo for
print "sending ... " . localtime() . "\n";
send(SOCKET, localtime(), 0) || die "could not send: $!";

# read the echo
recv(SOCKET, $buffer, 100, 0) || die "could not receive: $!";

## !!! This is where the error seems to occur.  The above stament
## !!!  bombs, and $! is just "unknown error"

print "received: $buffer at " . localtime() . " \n";

close SOCKET;

thanks a lot.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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