[7336] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 961 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 2 13:07:31 1997

Date: Tue, 2 Sep 97 10:00:33 -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, 2 Sep 1997     Volume: 8 Number: 961

Today's topics:
     Re: Cataloging the contents of an Array <seay@absyss.fr>
     CGI.pm - redirect problem? (Martin Brown)
     CGI_Lint??? <areeves@us.ibm.com>
     errorlevel  of a perl system call ? <kweiner@bloomberg.com>
     Re: Getting values from HTML forms... <mturk@globalserve.net>
     Re: Help with perl script <petri.backstrom@icl.fi>
     How to get keys of array? <tvonick@sprynet.com>
     Re: How to get keys of array? <seay@absyss.fr>
     Re: Integers, God, and e (was Re: Bug in perl? Bug in m (Clinton Pierce)
     More specific GREP-related question (Stuart Robinson)
     Re: More specific GREP-related question (Mike Stok)
     Re: More specific GREP-related question (Dave Feustel)
     Re: pattern matching HELP! (Lack Mr G M)
     Re: Perl & Shadow Passwords authentitacion. <fil@amnh.org>
     Re: Perl (kind of) math question. <seay@absyss.fr>
     Re: Perl (kind of) math question. (Mike Stok)
     Re: perl extension in tcl (Bryan Miller)
     Re: perl/win95/Long File Names (Andrew M. Langmead)
     Re: perl5.003 -> perl5.004: problems with pattern match (Martin Stromberg)
     Q: library for dbase file processing. <ster@stargazer.net>
     Re: Q: Sorting a hash of emails, based on domain <merlyn@stonehenge.com>
     Re: Reserved words (Stephen McCamant)
     Re: Script Time <seay@absyss.fr>
     Re: shell command "more" (Aaron Sherman)
     Re: Taint problem with setuid script (Mike Stok)
     Re: Time question.. <seay@absyss.fr>
     Web Development Position <cgaston@lds.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 02 Sep 1997 17:33:24 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Cataloging the contents of an Array
Message-Id: <340C31C4.324D780D@absyss.fr>

Sean P. Robertson wrote:
> 
> I want to find out that 0 occurs the most, 3 occurs the second most, and
> that the other two occur the least number of times.  These are keys for a
> database thing that I am working on in which I want to return the documents
> in order of probability that they are what the user is looking for.  It
> would be useful, after determining their order based on the frequency of
> their occurance, to strip out the duplicates and then put them in order
> from most frequent to least.

Loop through your input (sorted or not) and record the number of
occurances.  Then sort this numerically in descending order.  Here is a
whack at it.

my %table = ();
foreach my $value ( @input )
	{
	if ( exists $table{$value} )
		{ $table{$value} += 1; }
	else
		{ $table{$value} = 1; }
	}

print sort { $table{$b} <=> $table{$a} } keys %table;

- doug


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

Date: 2 Sep 1997 07:35:00 -0700
From: mjbjr@primenet.com (Martin Brown)
Subject: CGI.pm - redirect problem?
Message-Id: <5uh86k$d2l@nntp02.primenet.com>


For the life of me, I can't figure out what is going on.

the following works:

    $loc="http://127.0.0.1/success.html";
    print $query->redirect($loc);

but if I have a list of url's in a file, each with double '"'s around it
with no lf, and open the file and get a url and assign it to $loc, the
above doesn't work!

If I look at the #loc assignment, it shows:        

    "http://127.0.0.1/success.html"

I can't figure out what is going on!

Any ideas?

Thanx.
   

--
                            - Martin J. Brown, Jr. -  

                               mjbjr@primenet.com
                      PGP public key available via finger


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

Date: Tue, 02 Sep 1997 10:33:25 -0700
From: Adam Reeves <areeves@us.ibm.com>
Subject: CGI_Lint???
Message-Id: <340C4DE5.33F5@us.ibm.com>

I was wondering if someone could tell me where I could find 
CGI_Lint (for unix). I checked CPAN and couldn't find it, although
I might not have know where to look.

Any help would be greatly appreciated!

Cheers,
Adam Reeves
areeves@us.ibm.com


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

Date: Tue, 02 Sep 1997 11:14:25 -0400
From: weiner <kweiner@bloomberg.com>
Subject: errorlevel  of a perl system call ?
Message-Id: <340C2D51.3C17@bloomberg.com>

is there a way to import back into perl dos errorlevel 
after execution of some system command (other than creating a process
and using GetExitCode method)

thanks


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

Date: Tue, 02 Sep 1997 10:29:14 -0400
From: Mike Turk <mturk@globalserve.net>
Subject: Re: Getting values from HTML forms...
Message-Id: <340C22B9.5A93@globalserve.net>


Ramon Mariano Jr wrote:
> 
> I have an HTML form where one of the input fields is named "price". It's
> just a normal text input field where the user types in a numerical value.
> Now, in my perl script, I take the value of "price" and manipulate it
> using very simple math.  Here's the line in my script that seems to be the
> source of my problems:
> 
>  my $totalPrice = $FORM{'price'};
> 
> In other words, I'm attempting to store the value typed into the form
> field into a variable called "$totalPrice".  However, this method doesn't
> seem to work since all of the subsequent calculations using the
> "$totalPrice" variable doesn't compute correctly.  For testing purposes, I
> substituted the "$FORM{'price'}" to an arbitrary constant like this:
> 
>  my $totalPrice = 30;
> 
> After doing that, everything seems to run fine.  I'm guessing that the
> "price" value the perl script gets from the HTML form is a string rather
> than an integer and therefore is the reason I cannot mathmatically
> manipulate it.  Am I right about this?  At any rate, can someone enlighten
> me and tell me how to solve this problem?
> 
> Ramon
> 
> rmariano@u.washington.edu
> 
> 

Try printing out the value of "$FORM{'price'}" instead of doing
calculations with it.... then you'll know what your're dealing with.

Mike Turk


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

Date: Tue, 02 Sep 1997 13:14:18 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Help with perl script
Message-Id: <340BE6FA.30A0@icl.fi>


I. John Misiris wrote:
> 
> I have the an very simple perl script that is executed from
> an HTML FORM. If I test my script offline by running it on
> the shell it works fine (writing the form data to an file).
> When I call the script from my Homepage I get the famous
> 500 error. I tried a view things out and noticed that if I
> extract everything that has to do with the cgi.pm module
> the script works, as soon as add the cgi.pm stuff like:
> 
> use CGI;
> $query = new CGI;
> $Name = $query->param('my_name');
> 
> it dosn't. The same happend with any module offline It
> works fine but not online.
> 
> Does anybody know what could be the cause.

Are file/directory permissions set so that the account
your web server runs under can access every file it
needs to?

What's displayed if you run your script with

   use strict;

at the beginning of the file and -w on the command line
(or on the "shebang" line; #/usr/bin/perl -w)?

What does perl -v say on the command line about your 
Perl version?

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: 2 Sep 1997 13:52:22 GMT
From: "Tracy Vonick" <tvonick@sprynet.com>
Subject: How to get keys of array?
Message-Id: <01bcb7a7$748f48a0$b40101be@tvonick.paloma.palsec.com>

I have X numbers of lines of data & each line starts with a unique
definable key. I can get the lines into arrays but can't print out the
actual
keys. Any help would be appreciated. (I am looking to call subroutines
based on
the key, 20,30,40 of each line)

ex   20:This is test line #1
       30: This is test line #2
       40: This is test line #3
	.
	.
	.

Thanks
Tracy
tvonick@paloma.com
tvonick@sprynet.com



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

Date: Tue, 02 Sep 1997 17:51:23 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: How to get keys of array?
Message-Id: <340C35FB.7C3F54A@absyss.fr>


Tracy Vonick wrote:
> 
> I have X numbers of lines of data & each line starts with a unique
> definable key. I can get the lines into arrays but can't print out the
> actual
> keys. Any help would be appreciated. (I am looking to call subroutines
> based on
> the key, 20,30,40 of each line)
> 
> ex   20:This is test line #1
>        30: This is test line #2
>        40: This is test line #3
>         .
>         .
>         .

Here are two examples in the same script.  The first part implicitly
converts your strings to numerics which works, but produces ugly
warnings.  The second is the world (in)famous Schwartzian Transform
which basically makes a list with two values, one your data and the
other your key, sorts this list and then returns just the data parts. 
Don't worry about the "map sort map" approach making your brain hurt,
that is a normal reaction to Randal's code.

- doug

#!/usr/local/bin/perl -w

use strict;

my @list = ( '10: one', '20: two', '30: howdy there', '5: howdy world'
);

foreach ( sort { $a <=> $b } @list )
        { print "$_\n"; }

print "\npart two \n";

my @sorted = map { $_->[1] }
        sort { $a->[0] <=> $b->[0] }
        map { [ (split(':', $_))[0] , $_ ] } @list;

foreach ( @sorted )
        { print "$_\n"; }


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

Date: 2 Sep 1997 14:41:33 GMT
From: cpierce1@cp501.fsic.ford.com (Clinton Pierce)
To: jdf@pobox.com
Subject: Re: Integers, God, and e (was Re: Bug in perl? Bug in my code?)
Message-Id: <5uh8it$avk9@eccws1.dearborn.ford.com>


In article <5u471i$lli$2@gte2.gte.net>,
	jdf@pobox.com (Jonathan Feinberg) writes:
>gbacon@adtran.com said...
>> Tom C. once wrote "God created the integers.  All else is the work of
>> man
>
>Hmmm.  If you can find some integers whose relationship results in
>the value of the electron's QED "rest-mass" constant n, please
>let us know.  Perhaps there's a Physics::QED module on CPAN...
>

How do you know that God's Integers don't look like:

	0
	9.1e-28
	1.4142135
	2.7182818...
	3.1415926...

What base does God count in?

-- 
+------------------------------------------------------------------------+
|  Clinton A. Pierce    |   "If you rush a Miracle Man,   | http://www.  |
|  cpierce1@ford.com    |     you get rotten miracles"    | dcicorp.com/ |
|   cpierce@mica.net    |--Miracle Max, The Princess Bride| ~clintp      |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P++++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*



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

Date: Tue, 02 Sep 1997 23:48:00 +1000
From: Stuart.Robinson@anu.edu.au (Stuart Robinson)
Subject: More specific GREP-related question
Message-Id: <Stuart.Robinson-0209972348010001@asianstmg-221.anu.edu.au>

Does anyone know how regular expressions like [a-z] work when a
non-alphanumeric character is used?  For example, which characters would
the following regular expression match?

[1-!]

What about this one?

[a-1]

And the reverse?

[1-a]

I'm sure all of this could be predicted if one had knowledge of the
ordering of ASCII, but I'm afraid I lack such knowledge.  Any tips? 
Thanks in advance.

Regards,
Stuart Robinson

-- 
Stuart Robinson <Stuart.Robinson@anu.edu.au>
The Australian National University


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

Date: 2 Sep 1997 14:20:21 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: More specific GREP-related question
Message-Id: <5uh7b5$gd7@news-central.tiac.net>


In article <Stuart.Robinson-0209972348010001@asianstmg-221.anu.edu.au>,
Stuart Robinson <Stuart.Robinson@anu.edu.au> wrote:
>Does anyone know how regular expressions like [a-z] work when a
>non-alphanumeric character is used?  For example, which characters would
>the following regular expression match?
>
>[1-!]

If you actually use that in a regex on a system with ASCII encoding (or 
one of the character sets wherer the low 128 characters are ASCII) you
should get an "invalid [] range in regexp" warning as perl likes to work
with ascending ranges.  In ASCII you're asking for a range from character
49 up to character 33

>What about this one?
>
>[a-1]
>
>And the reverse?
>
>[1-a]

1-a will match a character in the range characters 49 to 97 inclusive, so
in the debugger I can use perl's ord and chr functions to see what
characters are in that range:

  DB<1> print ord '1'
49
  DB<2> print ord 'a'
97
  DB<3> print map {chr $_} (49 .. 97)
123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a

>I'm sure all of this could be predicted if one had knowledge of the
>ordering of ASCII, but I'm afraid I lack such knowledge.  Any tips? 

If you're on a unix system then there is usually a manual page for ascii,
so

  man ascii

should get you a useful page.  Failing that a www search or a reference
book might have a table of ascii codes in it (printer manuals usually have
tables of characters somewhere in them...)

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Tue, 2 Sep 1997 15:26:07 GMT
From: feustel@netcom.com (Dave Feustel)
Subject: Re: More specific GREP-related question
Message-Id: <feustelEFw07J.Jyx@netcom.com>


See the O'Reilly book: _Mastering Regular Expressions_ for a complete
exposition of regular expressions for all the standard unix programs.

Stuart Robinson (Stuart.Robinson@anu.edu.au) wrote:
: Does anyone know how regular expressions like [a-z] work when a
: non-alphanumeric character is used?  For example, which characters would
: the following regular expression match?

: [1-!]

: What about this one?

: [a-1]

: And the reverse?

: [1-a]

: I'm sure all of this could be predicted if one had knowledge of the
: ordering of ASCII, but I'm afraid I lack such knowledge.  Any tips? 
: Thanks in advance.

: Regards,
: Stuart Robinson

: -- 
: Stuart Robinson <Stuart.Robinson@anu.edu.au>
: The Australian National University
-- 
Dave Feustel		http://feustel.mixi.net
219-483-1857		mailto:feustel@netcom.com


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

Date: Tue, 02 Sep 1997 15:51:16 BST
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: pattern matching HELP!
Message-Id: <1997Sep2.155116@ukwit01>


In article <3406efd2.88385371@news.sol.co.uk>, mguz@sol.co.uk (Mark Guz) writes:
|> 
|> You guys have been pretty helpfull so far, so I hav another question.
|> 
|> I am trying to check for illegal characters in a string.
|> 
|> the allowable set is [a-z0-9_&.-] and I am trying to write code
|> something like -
|> 
|> 
|> 	if($string is not [a-z0-9_&.-]){
|> 
|> 		die "Not allowed!!!!"
|> 
|> 	}

   Try:

   if ($string =~ /[^a-z0-9_&.-]/) {
      die "Not allowed!!!!"
   }


   This matches string against all characters which are not in your
"legal" set.


-- 
----------- Gordon Lack ----------------- gml4410@ggr.co.uk  ------------
The contents of this message *may* reflect my personal opinion.  They are
*not* intended to reflect those of my employer, or anyone else.


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

Date: 02 Sep 1997 12:15:15 -0400
From: Fil Krohnengold <fil@amnh.org>
Subject: Re: Perl & Shadow Passwords authentitacion.
Message-Id: <ehd8mr7kvg.fsf@amnh.org>

Tom Grydeland <tom@mitra.phys.uit.no> writes:

> 
> 
> > On 30 Aug 1997, Michael W Peterson wrote:
> > > I've yet to have script running on Solaris
> > > 2.5.1 return shadow passwords unless it's running privileged.
> 
> > It may be that this feature confused someone into thinking that their
> > system was giving out crypted passwords. But until we see some code and
> > output, it's just a guess. Cheers!
> 
> I'm not going to post the usernames or entire passwords returned, but...
> 
> On Solaris 2.5 running NIS+:
> 
> palver ~/ > uname -a
> SunOS palver 5.5 Generic_103093-02 sun4u sparc SUNW,Ultra-1
> palver ~/ > perl -le 'while(($n,$p)=getpwent){print "$n:$p"}'
> root:x
> daemon:x
> bin:x
> sys:x
> adm:x
> lp:x
> smtp:x
> uucp:x
> nuucp:x
> listen:x
> nobody:x
> noaccess:x
> XXXXd:eyFF....
> XXXXs:micR....
> XXXXll:0prB....
> XXXX:0gF/....
> 

That might be more of a NIS+ issue - I dumped NIS+ many moons ago -
but I remember that the default permissions on the ecrypted passwd
entries weren't what they should have been without a manual "nischmod"
or "nistbladm" - I forget the actual command.  (In fact - by default, 
users had *write permission* on thier uid entry in the passwd table - 
I'm tired of being 23451 today - maybe I'll be 0 instad...).  

-fil
___________________________________________________________________________
Fil Krohnengold    |  UNIX Systems Admin, Interdepartmental Laboratories
fil@amnh.org       |  The American Museum of Natural History 
212/769-5294	   |  CPW @ 79thSt / NY, New York / 10024








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

Date: Tue, 02 Sep 1997 16:14:04 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Perl (kind of) math question.
Message-Id: <340C1F2C.FA937E7@absyss.fr>

Andrew Johnson wrote:
> 
> Scott Houck wrote:
> >
> > gbacon@adtran.com (Greg Bacon) wrote:
> >
> > >as hex or hexadecimal is another way of saying base sixteen.  Most
> > >humans are used to dealing with either base ten or base six.
> >
> > Who are these humans that are used to dealing with base six?  Are they
> > mutants that ran out of fingers?  :-)
> 
> indeed, I've heard of base twenty (vigesimal) with the Mayans, and
> base sixty (sexagesimal) with the Babylonians (still in use into
> the 15th century, at least in astronomy)---but a base six system
> doesn't ring any bells...

This is way off topic, but when did that ever change anything?

The Babylonians (actually it started in Sumeria and was pretty popular
throughout most of antiquity) didn't really use base 60, but really it
was a base 6 and a base 10 set of numbers.  I forget the details but if
I ever get back to my folks, I'll see if I my history of math textbook
is still in the attic.  As for base 60 still in use, think degrees.  The
origin of 360 degrees is two of those base 6 units and one base 10 unit.

But closer to home, in English we have single words for values through
twelve, not ten.  Only when we get to thirteen (three ten) do we get to
double digit words.  The same is true for German, but it is more obvious
from the spelling.  This has always made me think that "a long time ago"
the germanic tribes used base-12 (base 6 twice) and switched to base 10
later (late Roman Empire?  Middle Ages?).  Maybe that is why there are
12-hours on a clock (pure speculation).  But since French has single
words for numbers up through 16, maybe the ancient French (Gauls?
Gallo-Roman?) used hexadecimal.  I asked my wife (both French and a
software engineer) about this once and she rejected it out-of-hand.  Oh
well, so much for my ability to understand historical mathematics from
modern languages.

- doug


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

Date: 2 Sep 1997 14:31:15 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Perl (kind of) math question.
Message-Id: <5uh7vj$hj8@news-central.tiac.net>

In article <340C1F2C.FA937E7@absyss.fr>, Doug Seay  <seay@absyss.fr> wrote:

>> indeed, I've heard of base twenty (vigesimal) with the Mayans, and
>> base sixty (sexagesimal) with the Babylonians (still in use into
>> the 15th century, at least in astronomy)---but a base six system
>> doesn't ring any bells...
>
>This is way off topic, but when did that ever change anything?
>
>The Babylonians (actually it started in Sumeria and was pretty popular
>throughout most of antiquity) didn't really use base 60, but really it
>was a base 6 and a base 10 set of numbers.  I forget the details but if
>I ever get back to my folks, I'll see if I my history of math textbook
>is still in the attic.  As for base 60 still in use, think degrees.  The
>origin of 360 degrees is two of those base 6 units and one base 10 unit.

12 and 60 happen to be really good numbers to divide up without
remainders, and are much easier for humans unpolluted by metric
brainwashing to handle.  Only people without any idea about the difference
between fingers and thumbs would promote a base 10 system as "natural" ...
had the metric system been octal then the world would be a better place
;-) 

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 2 Sep 1997 16:06:40 GMT
From: millerb@fc.hp.com (Bryan Miller)
Subject: Re: perl extension in tcl
Message-Id: <5uhdig$5do@fcnews.fc.hp.com>

lvirden@cas.org wrote:

: You could just go to CPAN and pick up Malcom Beattie's
: packages to glue either tcl or Tk/Tcl into Perl.

Hmmm.  Yes, but my intent is to be able to run expect commands
directly from Perl.  If I remember correctly I had some namespace
conflicts using those packages - unless there are some newer
ones that I haven't seen.  It's worth taking another look.

Thanks Larry.

---
HP-UX Development Labs
millerb@udltools.fc.hp.com


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

Date: Tue, 2 Sep 1997 15:19:54 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: perl/win95/Long File Names
Message-Id: <EFvzx6.M70@world.std.com>

Mike Turk <mturk@globalserve.net> writes:
>   Sorry Andrew but in DOS... forward slashes are used for switches (optional arguments) not as
>pathname delimiters... and from a perl script if you want to navigate the DOS file system you have
>to delimit the backslash.....hence.... C:\\DOS........ at least..... that's what 's worked for me!

Mike. Next time, try it before you post. I know what I am talking
about.

MS-DOS itself, and the parts of Windows that have taken over some of
the functionality of MS-DOS, has code that services software service
calls that can be given names like open(), read(), write() close(),
etc. Some of these calls (like open()) are passed filenames as
parameters. Any of the MS-DOS system calls that take filenames as
arguments allow either forward slashes or backslashes are pathname
delimiters. Most C compilers come with libraries that have functions
that make these operating service calls. (definately any of them that
can compile perl.) These functions take filenames as arguments and
pass them without change to the appropriate operating system service.

Still following me? This means that any code that you write in C can
use either forward or backslashes interchangeably.

Now perl has built in functions that call the C library
functions. These functions take strings specifying filenames as
parameters and pass them to the C functions without change. 

This means, that you can write a program in perl, using either forward
or backslashes to specify filenames, and a perl interpreter for either
MS-DOS or Windows will handle it correctly.

Now some programs that run on MS-DOS or windows may parse strings in
different ways before passing the data to MS-DOS system calls. One
example is the COMMAND.COM program that is the default program that
MS-DOS starts when the system boots. COMMAND.COM looks for optional
arguments following forward slashes on its input. So you can't use
forward slashes when typing command lines in COMMAND.COM, it messes
them up before it sends them to the operating system. We're not
talking about the program COMMAND.COM here, we're talking about
functions that call the operating system itself.

Now the current versions of (at least) the Activeware port of perl for
Windows NT and Windows 95 have a bug where opendir on the root
directory fails, but this happens with either forward or backward
slashes.

Now to prove my point, here is a program that takes a directory name
as a paramter, and lists allow of the files and directories under
it. I have written it so that is passes pathnames with forward
slashes.

#!/usr/bin/perl -w

use DirHandle;

my $top = shift || die "usage: dir-s directory\n";
$top .= '.' if $top =~ m#^.:[\\/]$#; # work around perl rootdir bug

recurse($top);

sub recurse {
  my $dir = shift;
  my $file;

  my $dirhandle = new DirHandle $dir or die "Can't open $dir: $!\n";
  while(defined($file = $dirhandle->read())) {
    print "$dir/$file\n";
    next if $file =~ /^\.\.?$/;
    recurse("$dir/$file") if -d "$dir/$file";
  }
}

I used the OO wrappers over opendir(), readdir(), and closedir() to
get around awkward scoping issues for directory handles, I could
re-write it using those calls directly, (and using typeglobs to
restrict the scope) if you want.

Can you show an example where forward slashes fail in perl? (Not
counting calls to "system()", "exec()" or backticks. Those aren't perl
failing, its COMMAND.COM again.)
-- 
Andrew Langmead


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

Date: 2 Sep 1997 13:28:56 GMT
From: Martin.Stromberg@lu.erisoft.se (Martin Stromberg)
Subject: Re: perl5.003 -> perl5.004: problems with pattern matching
Message-Id: <5uh4ao$sbo$1@antares.lu.erisoft.se>


Martin Stromberg (Martin.Stromberg@lu.erisoft.se) wrote:
: I have a perl script that refuses to compile with perl5.004, but works fine
: with perl5.003. I can't find any mention of any change to the pattern matching
: rules in the perldelta man page for perl5.004.
:
: Perhaps I've made some obvious misstake I'm missing? Can somebody knowledgeable
: comment? Or try it on their machines?

Ehrm... I had. "/usr/bin/perl" is version 4.036. Unfortunately my environment
is set up so perl -> perl version 5.004. It work fine now that I've put 
"#!/local/fw/perl/5.004/bin/perl" (which is where perl 5.004 lives, for some 
reason, ask my system administrators about that) as the first line.


Sorry about the bandwidth,

							MartinS


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

Date: 2 Sep 1997 16:52:26 GMT
From: "Ster" <ster@stargazer.net>
Subject: Q: library for dbase file processing.
Message-Id: <01bcb7c0$a5a57860$01808080@cornholio>

I understand there are PERL libraries for processing DBase files
(insert,delete,edit,search,etc.)
Can someone direct me to an EASY library that is PERL 4 compatible (not
PERL 5)

Thank you!!!

______________________
Ster@stargazer.net
http://stargazer.net/ster


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

Date: 02 Sep 1997 09:10:22 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Q: Sorting a hash of emails, based on domain
Message-Id: <8chgc31ytt.fsf@gadget.cscaper.com>


>>>>> "Eric" == Eric D Friedman <friedman@uci.edu> writes:

Eric> (Read this from the bottom up)

Eric> sub getDomain
Eric> {
Eric>   my $add = shift;
Eric>   my @fields = split /\./, $add;
Eric>   return $fields[$#fields - 1];  # Return the penultimate substring
Eric> }

Eric> my @sorted_keys =
Eric>    map { $_->[0] }              # return the real keys (sorted) to the list
Eric>    sort { $a->[1] cmp $b->[1] } # sort on the domains, alphabetically
Eric>    map { [$_, getDomain($_) }  # make an anon array out of keys and domains
Eric>    keys %hash;

Eric> I'd be curious to see a version of this which didn't need the
Eric> additional function (getDomain) to get the next to last key....

Well, I could do that:

    my @sorted_keys =
       map { $_->[0] }
       sort { $a->[1] cmp $b->[1] }
       map { [$_, (split /\./)[-2]] }
       keys %hash;

But as I was looking at it, I think I've got a more interesting solution:

    my @sorted_keys =
      map { $_->[0] }
      sort {
	my $id = 1;
	my $cmp;
	{
	  return $a->[0] cmp $b->[0] if $id > $#$a and $id > $#$b;
	  return $cmp if $cmp = $a->[$id] cmp $b->[$id];
	  $id++;
	  redo;
	}
      }
      map { [$_, reverse map lc split /\.\@/] }
      keys %hash;

which sorts the hash on the domain names, one domain level at a time,
starting at the end name, *case insensitive*, falling back to the
original names if the case-insensitive matches fail to distinguish.

The number of gems (and buglets :-) in this post will be left as an
exercise to the reader. :-)

The Schwartzian Transform, from the master. :-)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 363 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

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


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

Date: 2 Sep 1997 15:53:11 GMT
From: stephen@alias-2.pr.mcs.net (Stephen McCamant)
Subject: Re: Reserved words
Message-Id: <slrn60odfe.l9.stephen@alias-2.pr.mcs.net>

On Mon, 01 Sep 1997 16:57:01 +0200, Arnaud Le Hors <lehors@w3.org> wrote:
>I'm looking for the list of perl reserved words. I spent some time
>looking in the man pages, the FAQs, as well as various resources on the
>web, but can't find it anywhere. Any body knows if this is available
>anywhere? It would be a good thing to have this in the distribution
>package.

Perl doesn't really have reserved words, per se. There's a builtin function
pack(), but you can still have a scalar $pack, an array @pack, a hash %pack,
a label pack, an even a sub pack (though you can only call it as a method or
with `&'). There is a set of `keywords', though, which is probably what
you're looking for.  You can find it in the (source) distribution as the
file `keywords.pl' (or `keywords.h' if you're in a C mood). There's also a
distinction between two levels of keywords, which you can see in
cperl-mode.el or the definition of keyword() in toke.c (some of the KEY_
constants are returned negative).

-- 
____________________________________________________________
Stephen McCamant ======== alias@mcs.com (finger for PGP key)


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

Date: Tue, 02 Sep 1997 17:22:56 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Script Time
Message-Id: <340C2F50.182BC77C@absyss.fr>

Matt Weber wrote:
> 
> I would like to put a line of text on my output page that says how long
> it took to run the script...any suggestions?  See altavista's addurl for
> an example.

You mean something more than time() before and time() after and using
the difference as elapsed time in seconds?


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

Date: 2 Sep 1997 09:59:18 -0400
From: ajs@lorien.ajs.com (Aaron Sherman)
Subject: Re: shell command "more"
Message-Id: <5uh63m$lsl@lorien.ajs.com>

<gomar@mindless.com> wrote:
>sabrina chan <schan@rice.edu> wrote:
>
>>I wrote a script that gathers various information into one file, and
>>then I want to output this file to the screen.  However, I can't
>>figure out how to output it in the style of the command "more", ie
>>stopping and asking for a key to be pressed when the screen is full.
>
>Why don't you _employ "more"_, i.e. pipe the output to it?  Of course
>it's more recommendable to use "less" (if available).
>

I can't belive this is not in the FAQ or a man-page or somewhere, but
here's the rant that I've ranted on before (shades of MMB):

PAGER PAGER PAGER

Use $ENV{PAGER}

eg:

	sub more {
		my $in = shift;
		my $pager = $ENV{PAGER} || 'more';
		my $io = IO::File->new("|$pager");
		local $_;
		return undef unless defined $io;
		if (ref($in) && ref(\$in) eq 'GLOB') {
			while(<$in>) {
				print $io $_;
			}
		} else {
			print $io $in;
		}
		$io->close;
		return 1;
	}


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

Date: 2 Sep 1997 14:01:05 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Taint problem with setuid script
Message-Id: <5uh671$eft@news-central.tiac.net>

In article <340C16A7.D1548336@dux.dundee.ac.uk>,
James Sutherland, IT Services <jasuther@dux.dundee.ac.uk> wrote:

>The problem, though, is that perl refuses to let this run as it is a
>setuid script and creates a file named by an environment variable.
>Really, I would just like to run the script with taint checking disabled
>- the file being named this way is *not* a problem, since it is only
>created if the user who set that variable (authenticated by their logon
>password through Solaris) is allowed to do so him/herself.
>
>How can I either (a) disable this check, or (b) clear the tainted status
>of that variable? (Yes, I could go and change the source code and build
>myself a version of perl which ignores the setuid bit on files, but I
>*really* don't like that idea...

If you know what the environment variable should look like then you can
untaint the data using a regex (as discussed in the perlsec man page) e.g.

If a "safe" value of the environment variable is a filename which has a 1
 .. 8 "letter" stem and a 1 .. 3 "letter" extension (where I consider
letter to be a \w character...) then something like

  if ($ENV{FN} =~ /^(\w{1,8}\.\w{1,3})$/) {
    $file = $1; 
  }
  else {
    die "bad data\n";
  }

would leave $file as an untainted copy of the FN environment variable if
it met the requirements.

Please read perlsec as tainting can save you from all kinds of accidents,
malicious or otherwise, if you use it responsibly.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Tue, 02 Sep 1997 16:26:12 +0200
From: Doug Seay <seay@absyss.fr>
To: guitarplayer@hotmail.com
Subject: Re: Time question..
Message-Id: <340C2204.11968D00@absyss.fr>

[posted and mailed]

CrAzY wrote:
> 
> Is this the best or most effecient way of getting the local time (as for
> just hour, minute, am/pm)???

	SNIPAGE

> 
>    ($min, $hour) = (localtime(time))[1,2,3];

why get 3 values when you only use 2?  delete ",3" from your array
slice.


>    if (length ($min) < 2)
>       {
>       $min = "0" . $min;
>       }

don't worry about this.


>    $ampm = "AM";
>    $ampm = "PM" if ($hour > 11);

don't worry about this either


>    $hour = $hour - 12 if ($hour > 12);
>    $hour = 12 if ($hour == 0);

duh?  $hour==0 between midnight and 1am.  This line will cause problems
unless you want midnight to look like noon.  Keep the line with the -12
hours bit.


>    $current_time = "$hour:$min $ampm";

$current_time = sprintf '%02d:%02d %s', $hour, $min,
		($hour>11 ?'PM':'AM');

> 
> Is this a good way?  I'm using perl 5.004_01..


Sure, it works, but it is a bit manual for my tastes.  Use "strftime"
from POSIX.pm to do the same sort of thing in only one line.  I don't
know if it would be faster.  Use the Benchmark module to find that out.
Of course, if your system is non-POSIX, you kinda have to be a bit
manual.

- doug


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

Date: Tue, 02 Sep 1997 10:47:39 -0400
From: Chris Gaston <cgaston@lds.com>
Subject: Web Development Position
Message-Id: <340C270B.22D1046D@lds.com>

Logical Design Solutions, a leader in the design and development of
Interactive Business Communications has an immediate full-time opening
in their Morristown, NJ office for a Web Architect.

Job Description:
In this visible role, the ideal candidate will possess experience in
configuration of Internet technologies as part of a multi-tiered
information technology architecture.  Keeping up-to-date with
current technology trends is essential, as is the ability to evaluate
appropriate technology components for development and delivery
environments.  This individual must also have the ability to integrate
application support technologies with preexisting client IT
infrastructure.  Experience with C/C++, Perl, HTML, Java, CGI and
knowledge of Internet protocols and standards is required.
Knowledge of Active X a plus.

Send resume with cover letter and salary requirements or contact:

Technical Recruiter
Logical Design Solutions
Phone: (201) 971-0100
Fax:   (201) 971-0103
email: recruiter@lds.com




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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". 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 961
*************************************

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