[6934] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 559 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 2 16:27:18 1997

Date: Mon, 2 Jun 97 13: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           Mon, 2 Jun 1997     Volume: 8 Number: 559

Today's topics:
     Re: (Help!)Formating output to sendmail (O'Shaughnessy Evans)
     Re: 2-way communication with unix command <rra@stanford.edu>
     Re: 5.004 problem with Hashes <rra@stanford.edu>
     Re: Bored?  Want to evaluate my first (usefull) perl sc <rra@stanford.edu>
     Re: Converting number to ascii (A. Deckers)
     Re: data structure question <chewie@dtai.com>
     Don't understand POSIX.pm <felix@quickquote.com>
     Going from Perl to C <mystery@itis.com>
     Re: How can I set up this server to run perl faster?... <chewie@dtai.com>
     HTML templates in Perl (article) (Brian Slesinsky)
     Re: Idiom for list summation? <rra@stanford.edu>
     Looking for a tech writer who knows perl <swdoc@ora.com>
     Re: moving form BSD to SunOS 5.5  (formmail.pl) <rootbeer@teleport.com>
     nth root function? liamtu@echonyc.com
     Re: nth root function? <merlyn@stonehenge.com>
     Re: Refresh and Environment Variables. <rra@stanford.edu>
     Re: Regex lookahead help <freter@heorotsi.com>
     Re: Regex lookahead help (Jeff Stampes)
     Re: Setting a variable for both split and join... <mystery@itis.com>
     Re: Sorting by values (O'Shaughnessy Evans)
     Re: Sorting by values <merlyn@stonehenge.com>
     Re: Sorting by values <rootbeer@teleport.com>
     Trying to get a DATE/TIME from MS-Excel. joeyGibson@mindspring.com
     Re: Trying to get a DATE/TIME from MS-Excel. <rootbeer@teleport.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 2 Jun 1997 18:08:48 GMT
From: shaug@callamer.com (O'Shaughnessy Evans)
Subject: Re: (Help!)Formating output to sendmail
Message-Id: <5mv27g$mfa$2@zinger.callamer.com>

In article <33910AAE.17CE@technicom.net>,
	Angelo Kello <kello@technicom.net> writes:
> 
> I used :     printf (MAIL,"%-40s %10s\n"$dummy1,$dummy2) ;
 
You're argument format is a bit messed up:
 1) There *should not* be a comma after the name of the filehandle.
 2) There *should* be a comma after the format specifier string.

Try this, instead:

	printf STDOUT ("%-40s %10s\n", $dummy1, $dummy2);

Keeping those commas straight is the important note here; you might want
to try throwing spaces inbetween your arguments just to make this kind of
error more obvious.

-- 
- O'Shaughnessy Evans
- UNIX/Internet Systems Administrator, GST Call America; SLO, Ca
- "I'm about to write you a reality check..." -- The Tick


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

Date: 02 Jun 1997 11:42:17 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: 2-way communication with unix command
Message-Id: <m3lo4ssv7a.fsf@windlord.Stanford.EDU>

Michael J Assels <mjassels@cs.concordia.ca> writes:
> Randal Schwartz  <merlyn@stonehenge.com> wrote:

>> But it'd be really funny if this same "management" *requires* you to
>> respond to any CERT security notice by installing the required patches:
>> there have been at least a few CERT-ifiable notices against 4.036,
>> 5.001, 5.002 and 5.003.  The safest version of Perl is *now* 5.004.

> Does this mean 5.004 is *now* a production release?  The Perl home page
> tells me that "Version 5.004 of perl has now entered beta."

5.004 is a production release.  The Perl home page is currently a bit
behind.

> Perhaps I should stop reading comp.lang.perl.announce and subscribe to
> perl5-porters for current info?

The production release of 5.004 was announced on comp.lang.perl.announce,
actually.  Although reading perl5-porters isn't a bad idea if you have
time; I've learned a *lot* about both Perl and programming in general from
it.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 02 Jun 1997 11:46:10 -0700
From: Russ Allbery <rra@stanford.edu>
To: Prince Mystery <mystery@itis.com>
Subject: Re: 5.004 problem with Hashes
Message-Id: <m3iuzwsv0t.fsf@windlord.Stanford.EDU>

[ Posted and mailed. ]

Prince Mystery <mystery@itis.com> writes:

> I'm getting an error that I didn't used to get when the system was on
> the previous version of perl (5.003):

> Odd number of elements in hash list at...

> Over the line:

> %final = {};

A bunch of people gave you the solution, but no one told you why it was
doing what it was doing.  {} creates an *anonymous* hash with zero
key/value pairs, just like [] creates an empty anonymous array.  In Perl,
anonymous hashes and anonymous arrays are implemented as references.  So
that line is basically equivalent to:

        $hash = {};
        %final = $hash;

You're trying to assign what's basically a scalar to a hash, Perl's trying
to turn it into a list of key/value pairs for you, and Perl is complaining
because there's an odd number of things (only one) and it therefore can't
pair things up properly.

To clear out a hash, you want to assign the empty *list* to it:

        %final = ();

General rule of thumb:  Mixing a real hash variable (something beginning
with %) and {}s is generally *not* doing what you think it's doing.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 02 Jun 1997 11:39:11 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Bored?  Want to evaluate my first (usefull) perl script?
Message-Id: <m3oh9osvcg.fsf@windlord.Stanford.EDU>

Chipmunk <Ronald.J.Kimball@dartmouth.edu> writes:
> Russ Allbery <rra@stanford.edu> writes:

>> BTW, how much of a speed penalty do -w and use strict cause?

> Aren't they only factors when the script is being compiled?

Sure, but in most cases the script has to be compiled every time it's run.
And actually, -w includes a bunch of run-time checks as well.  I know
there's been a lot of discussion on perl5-porters in the past about the
proper way of writing warning code in Perl core (always check -w first
before doing anything expensive), so I know that some expensive checks are
disabled by not using -w.  I'm just not sure how relatively expensive
expensive is.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 2 Jun 1997 18:08:43 GMT
From: I-hate-cyber-promo@man.ac.uk (A. Deckers)
Subject: Re: Converting number to ascii
Message-Id: <slrn5p631b.kdb.I-hate-cyber-promo@news.rediris.es>

In comp.lang.perl.misc,
	grimm@shell.pgonline.com wrote:
>
>Well, the title pretty much sums it up. I need to know how to change a
>numeric value into ascii.

$num = 65;
$str = chr($num);

print "$str\n";

Which part of the copious free documentation did you not understand?

HTH,

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
    Perl archive: <URL:http://www.perl.com/CPAN/>
        Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>


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

Date: Mon, 02 Jun 1997 12:04:07 -0700
From: Rich Yumul <chewie@dtai.com>
To: Jon Nathan <jn0729a@cage.cas.american.edu>
Subject: Re: data structure question
Message-Id: <33931927.DFDA778C@dtai.com>

This is a multi-part message in MIME format.
--------------C40536734F61F4024F6850FF
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Here's one way to do what you're asking (at least, this is the way that
I would do it):

First, I'd format the data file like this:
-------------
Some Song|Take me out to the ball game...
Joe Smith|Whatever
Rich Yumul|Where ever you go, there you are.
-------------

And the perl code would be:
----------------------------------------------
#!/usr/local/bin/perl

open (QUOTE, "//usr//people//nathanj//quotes");

$i=1;
while (<QUOTE>) {
	$quote_array{$i++} = $_;
}

close (QUOTE);

# this code will read in the data file and store
# the data into an associative array with the line number
# being the key

srand(time);
$i--;
$index = int(rand $i) + 1;

# choose a random index (line) number

($author, $quote) = split (/\|/, $quote_array{$index});

# assign the author & the quote text to the variables
# $author & $quote
#
# Now you have two variables $author & $quote that you
# can print out in any way you want.

print "$quote\n\t\t\t$author\n";

-----------------------------------
Of course, there's the drawback that you can't use the character "|" in
your data - (ie, the character "|" can't be in the author text string or
the quote text string), but it's not a very common character, so it
should be okay.  

There's probably more elegant ways to do this, but I think this way is a
little bit more elegant than what you were working on. I hope this
helps.

Rich Yumul

|-------------------------------------------------------------------|
| Richard M.  Yumul                  |     /////  /////   //   /////|
| DTAI, Incorporated    Java    HTML |    /    /   /    /  /    /   |
| P.O. Box 16989          Netscape   |   /    /   /   /    /   /    |
| San Diego, CA  92176    C++  CGI   |  /    /   /   //////   /     |
| (619) 281-2292         Windows 95  | /////    /   /    / /////    |
| (FAX) 281-0377        Unix    DBMS |  I N C O R P O R A T E D     |
| mailto:chewie@dtai.com             |    http://www.dtai.com       |
|-------------------------------------------------------------------|
--------------C40536734F61F4024F6850FF
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Richard Yumul
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Richard Yumul
n:              Yumul;Richard
org:            DTAI, Incorporated
email;internet: chewie@dtai.com
title:          Web Master
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
end:            vcard


--------------C40536734F61F4024F6850FF--



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

Date: Mon, 02 Jun 1997 11:23:40 -0700
From: Felix Finch <felix@quickquote.com>
Subject: Don't understand POSIX.pm
Message-Id: <33930FAC.77C13EFA@quickquote.com>

I've beem trying to use the POSIX::open function to create a file.

	POSIX::open($name, &POSIX::O_CREAT | &POSIX::O_EXCL | &POSIX::O_WRONLY,
0666);

It seems to work, but if I throw in the -w option, I get the complaint

	argument "/var/ns-home/cgi-bin/file xyzzy..." isn't numeric
	in entersub at /usr/local/lib/perl5/posix.pm line 197.

This is a line in sub AUTOLOAD which says

	my $val = constant($constname, $_[0]);

I can't find constant() in POSIX.pm or the camel book.  But just above
sub AUTOLOAD are two lines

	my $EINVAL = constant("EINVAL", 0);
	my $EAGAIN = constant("EAGAIN", 0);

which seem to imply that the second arg should be a number.
But the camel book (p 481) says I have the args in the right order.

Does someone know what I am doing wrong?

-- 
     ... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
     Felix Finch,  scarecrow repairer / felix@quickquote.com
     PGP = D0 DA 24 E4 8A 6A 9E C5   DB 21 A6 F6 A2 95 CC 57
I've found a solution to Fermat's Last Theorem but I see I've run out of
room o


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

Date: Mon, 02 Jun 1997 14:29:07 -0400
From: Prince Mystery <mystery@itis.com>
Subject: Going from Perl to C
Message-Id: <339310F3.59E2@itis.com>

I've got a minor perl routine that does a lot of regexp'ing, and a lot
of file input/output.  I would like to recreate this in C, and then
compile it, hopefully speeding up the process.  However, due to the fact
that I'm much better at perl than I am at C, I'm more inclined to try
out some sort of converter before recoding it from the ground up.  Is
there such a beast?

Thanks,

Myst


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

Date: Mon, 02 Jun 1997 12:24:10 -0700
From: Rich Yumul <chewie@dtai.com>
To: perlprogrammer@hotmaill.com
Subject: Re: How can I set up this server to run perl faster?...
Message-Id: <33931DDA.7E379AB4@dtai.com>

This is a multi-part message in MIME format.
--------------95B0A18E6B4D7AA606BBAC61
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

You might want to try a different chat program.  One java based solution
that I found, and is actually quite good, is EWGIE (Easy Web Group
Interaction Enabler). I'm not sure how well it will do under the server
load that you're describing, but it's worked out pretty well for me. 
The url for it is:

http://www.eit.com/ewgie/

Of course, the java process takes up a lot of memory if you start the
server without any java flags - but you can start up the server with the
-mx flag, ie:

java -mx2048 EwgieServer

and the java virtual machine will only take up 2 megs of memory instead
of the default 20.

Hope this helps.

Rich Yumul

|-------------------------------------------------------------------|
| Richard M.  Yumul                  |     /////  /////   //   /////|
| DTAI, Incorporated    Java    HTML |    /    /   /    /  /    /   |
| P.O. Box 16989          Netscape   |   /    /   /   /    /   /    |
| San Diego, CA  92176    C++  CGI   |  /    /   /   //////   /     |
| (619) 281-2292         Windows 95  | /////    /   /    / /////    |
| (FAX) 281-0377        Unix    DBMS |  I N C O R P O R A T E D     |
| mailto:chewie@dtai.com             |    http://www.dtai.com       |
|-------------------------------------------------------------------|
--------------95B0A18E6B4D7AA606BBAC61
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Richard Yumul
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Richard Yumul
n:              Yumul;Richard
org:            DTAI, Incorporated
email;internet: chewie@dtai.com
title:          Web Master
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
end:            vcard


--------------95B0A18E6B4D7AA606BBAC61--



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

Date: Mon, 02 Jun 1997 18:59:48 GMT
From: bslesins-usenet@wired.com (Brian Slesinsky)
Subject: HTML templates in Perl (article)
Message-Id: <33931586.1817473848@news.hotwired.com>


Hi, if you're writing CGI's you might be interested in my latest
Webmonkey article about using templates to make design changes easier:

  http://www.hotwired.com/webmonkey/code

Also, at the end of the article there's a module (HTMLT::Interpreter)
for parsing templates containing loops and conditional HTML.  I'd be
interested in knowing if people find this useful and whether a cleaned
up version should end up on CPAN.

Thanks,
Brian Slesinsky (bslesins-usenet@wired.com)


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

Date: 02 Jun 1997 11:49:12 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Idiom for list summation?
Message-Id: <m3enaksuvr.fsf@windlord.Stanford.EDU>

Dean Pentcheff <dean@tbone.biol.sc.edu> writes:

> timethese(100000, {
> 	      'short-for' , '$s=0; for (@short) {$s+=$_;}',
> 	      'short-map' , '$s=0; map{$s+=$_} @short;   ',
> 	      'short-eval', '$s=eval join " + ", @short; ',
> 	     });

> Benchmark: timing 100000 iterations of short-eval, short-for, short-map...
> short-eval: 29 secs (29.29 usr  0.02 sys = 29.31 cpu)
>  short-for:  2 secs ( 1.79 usr  0.00 sys =  1.79 cpu)
>  short-map:  3 secs ( 2.31 usr  0.00 sys =  2.31 cpu)

> Conclusion: Despite their nifty appearance, alternatives to
> "for/foreach" lose in efficiency (whether working on long or short
> arrays).

If I remember correctly, map still isn't optimized for the case of a void
context.  I seem to recall some discussion that this should be coming down
the road and just hasn't been done yet.  If that's the case, that would
certainly explain the speed difference between it and "for", and that's
arguably an optimizer bug, or at least a lack of a feature, in Perl rather
than anything inherently wrong with map.

Not much of a speed difference either.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Mon, 02 Jun 1997 12:15:59 -0700
From: "Susan B. Peck" <swdoc@ora.com>
Subject: Looking for a tech writer who knows perl
Message-Id: <33931BEE.59EF@ora.com>

Greetings,

We are looking for a technical writer to prepare some perl documentation
for us (we are O'Reilly & Associates, home of Larry Wall ;-) If you are
interested, or know someone who is, please have them send me a note at
swdoc@ora.com.  Some specifics follow:

This individual should be an experienced technical writer who can 
devote full time to the project for about 4 months (mid-June to
mid-October).  Knowledge of perl and familiarity with programming 
tools is a must.  Writing can be done in troff, Frame, (or even 
Word) using our template and/or macro packages.

We anticipate this documentation to be about 100-150 pp long.  The
writer will receive technical, editorial, and production support.  
The writer will also participate in regular project meetings (via 
phone if not local to the Sebastopol, California office).  We prefer 
to work with off-site writers who have their own equipment and 
software.  We will, of course, provide the software to be documented.  

Looking forward to hearing from you!  Thanks for reading this far.

susan

----------------------------------------------------
Susan B. Peck        Manager, Software Documentation
            O'Reilly & Associates, Inc
email: swdoc@ora.com        http://software.ora.com


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

Date: Mon, 2 Jun 1997 11:13:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Henry Hazan <henry@uninet.com.br>
Subject: Re: moving form BSD to SunOS 5.5  (formmail.pl)
Message-Id: <Pine.GSO.3.96.970602111259.28406B-100000@kelly.teleport.com>

On Mon, 2 Jun 1997, Henry Hazan wrote:

> Is there anyone to answer me why I am having problems to run this script
> on sunOs 5.5. I get the message: [Mon Jun  2 10:54:21 1997] httpd:
> malformed header from script

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to
solving such problems. It's available on the perl.com web pages. Hope
this helps!

   http://www.perl.com/perl/
   http://www.perl.com/perl/faq/
   http://www.perl.com/perl/faq/idiots-guide.html

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Mon, 02 Jun 1997 13:21:41 -0600
From: liamtu@echonyc.com
Subject: nth root function?
Message-Id: <865274700.1919@dejanews.com>

is there a secret nth root function in perl? has anyone written one?

Any advice?... C?

-Liam

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 02 Jun 1997 11:57:09 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: liamtu@echonyc.com
Subject: Re: nth root function?
Message-Id: <8ck9kcvnne.fsf@gadget.cscaper.com>

>>>>> "liamtu" == liamtu  <liamtu@echonyc.com> writes:

liamtu> is there a secret nth root function in perl? has anyone written one?
liamtu> Any advice?... C?

Yeah.  Pretty secret:

	$nth_root_of_x = $x ** (1/$n);

:-)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 455 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: 02 Jun 1997 11:51:26 -0700
From: Russ Allbery <rra@stanford.edu>
To: duggan@kira.ecs.umass.edu (John F Duggan)
Subject: Re: Refresh and Environment Variables.
Message-Id: <m3bu5osus1.fsf@windlord.Stanford.EDU>

[ Posted and mailed. ]

John F Duggan <duggan@kira.ecs.umass.edu> writes:

> I have been using a refresh within a perl script to allow me to clear
> the query string information from being displayed as part of the url. I
> do this by setting the refresh time for 0. When I do this, I lose all of
> the Environment Variables information. Is there any way around that?
> Would embedding the refresh within a form solve the problem?

This is not a Perl question.  This is a question about the interaction
between the CGI interface and a web browser, in particular dealing with
precisely what data is sent to the web server by the browser after a
refresh and how that data is passed along to the script.

You'll have much better luck asking this question on a CGI newsgroup, such
as comp.infosystems.www.authoring.cgi.  The answer will be the same
regardless of the programming language used to implement the CGI script.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Mon, 02 Jun 1997 14:03:39 -0400
From: Craig Freter <freter@heorotsi.com>
To: Jeff Stampes <stampes@xilinx.com>
Subject: Re: Regex lookahead help
Message-Id: <33930AFB.3A42@heorotsi.com>

Jeff Stampes wrote:

> so here's the problem.  I have some strings that are in the form
> 'data/foo/bar/not.this'  I want to NOT match these strings.
> However, the regex needs to be plugged into a positive assertion
> match.  There could be anywhere from 3-6 levels before the
> 'not.this'.
> 
> I was hoping to use a negative lookahead, but can't seem to find
> something that works.  For example:
> 
> m{(.+/)+(?!not.this)}
Try this:
        m{
          ^
          ([^/]+/)+         # match path
          (?!not\.this)     # fail if not.this
          [^/]+             # match file
          $
        }x;

-- 
Craig Freter    <freter@freter.com>   <http://www.freter.com>
PGP fingerprint 61 A5 E2 51 F5 AC 9D 79 DD 15 56 90 F2 0A 97 25
Heorot Systems  <http://www.heorotsi.com>


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

Date: 2 Jun 1997 15:41:41 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Regex lookahead help
Message-Id: <5mupjl$1eq$1@neocad.com>

Jeff Stampes (stampes@xilinx.com) wrote:
: I was hoping to use a negative lookahead, but can't seem to find
: something that works.  For example:

: m{(.+/)+(?!not.this)}

Following up my own post...thanks to those who e-mailed me help.
What I needed was this:

m{^((.+/)+(?!not.this)\w+(\.\w+)?)$}

to be sure I match files that are NOT 'not.this'.

Thanks to all.

Jeff


--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: Mon, 02 Jun 1997 14:14:34 -0400
From: Prince Mystery <mystery@itis.com>
Subject: Re: Setting a variable for both split and join...
Message-Id: <33930D8A.15FB@itis.com>

CHAN TANG Eric-Aubert wrote:
> $SEPARATOR = '|';
> 
> $string = join($SEPARTOR, @text);
> 
> @text = split(/$SEPARATOR/, $text);
> 
> This won't work because, 'split' should be call this way:
> @text = split(/\|/, $text);

I think you have to run $SEPARATOR through the quotemeta() func before
running it through split, ie:

@text = split(/quotemeta($SEPARATOR)/,$text);

Myst


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

Date: 2 Jun 1997 18:00:20 GMT
From: shaug@callamer.com (O'Shaughnessy Evans)
Subject: Re: Sorting by values
Message-Id: <5mv1nk$mfa$1@zinger.callamer.com>

In article <EB05uw.Lt7@midway.uchicago.edu>,
	soh3@midway.uchicago.edu (min-woong sohn) writes:
> Hello.
> 
> I'd like to know if there is a way of printing
> the contents of an associative array sorted by
> values (in descending order) rather than sorted
> by keys as documented in the Programming Perl book.
> Any help will be greatly appreciated.
> 
> Min
 
This probably isn't the most memory- or time-efficient, but it'll do what 
you want (assuming that the hash you want to print out is named "%hash"):

	my %revhash = reverse %hash;
	foreach (reverse sort keys %revhash) {
	   print "$_ => $revhash{$_}\n";
	}

-- 
- O'Shaughnessy Evans
- UNIX/Internet Systems Administrator, GST Call America; SLO, Ca
- "I'm about to write you a reality check..." -- The Tick


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

Date: 02 Jun 1997 11:55:28 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: shaug@callamer.com (O'Shaughnessy Evans)
Subject: Re: Sorting by values
Message-Id: <8cn2p8vnq6.fsf@gadget.cscaper.com>

>>>>> "Evans" == O'Shaughnessy Evans <shaug@callamer.com> writes:

Evans> This probably isn't the most memory- or time-efficient, but it'll do what 
Evans> you want (assuming that the hash you want to print out is named "%hash"):

Evans> 	my %revhash = reverse %hash;
Evans> 	foreach (reverse sort keys %revhash) {
Evans> 	   print "$_ => $revhash{$_}\n";
Evans> 	}

It's also broken if there are two values that are the same.

Others have already given the proper answer in this thread, or at least
in the FAQ.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 455 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: Mon, 2 Jun 1997 12:41:38 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: O'Shaughnessy Evans <shaug@callamer.com>
Subject: Re: Sorting by values
Message-Id: <Pine.GSO.3.96.970602123403.28406D-100000@kelly.teleport.com>

On 2 Jun 1997, O'Shaughnessy Evans wrote:

> In article <EB05uw.Lt7@midway.uchicago.edu>,
> 	soh3@midway.uchicago.edu (min-woong sohn) writes:

> > I'd like to know if there is a way of printing
> > the contents of an associative array sorted by
> > values (in descending order) rather than sorted
> > by keys as documented in the Programming Perl book.

> This probably isn't the most memory- or time-efficient, but it'll do what 
> you want (assuming that the hash you want to print out is named "%hash"):
> 
> 	my %revhash = reverse %hash;
> 	foreach (reverse sort keys %revhash) {
> 	   print "$_ => $revhash{$_}\n";
> 	}

That won't work if you have two hash elements with the same value; in that
case you'll only print one of them. Also, you're sorting by ASCII, rather
than by number, which (I think) the poster wanted. 

And you're right to note that it's not especially efficient to reverse a
hash. 

In any case, the answer in the FAQ should be sufficient. Hope this helps! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Mon, 02 Jun 1997 13:25:21 -0600
From: joeyGibson@mindspring.com
Subject: Trying to get a DATE/TIME from MS-Excel.
Message-Id: <865275190.2503@dejanews.com>

   I am using the latest version of Perl for Win32 with MS-Excel
for Windows95. I am using the OLE interface to access a spreadsheet.
I can get all of the cells with no problem, but how do I convert the
date/time fields? I get a XXXXX.YYYYYY type number, but I don't
know how to decode it. According to the Excel docs, the digits on the
left of the dot are the date and those to the right are the time. But
I couldn't figure out what the encoding scheme was. If anyone can
help, PLEASE do!

Thanks for any help,
Joey Gibson

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Mon, 2 Jun 1997 12:51:19 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: joeyGibson@mindspring.com
Subject: Re: Trying to get a DATE/TIME from MS-Excel.
Message-Id: <Pine.GSO.3.96.970602124721.28406F-100000@kelly.teleport.com>

On Mon, 2 Jun 1997 joeyGibson@mindspring.com wrote:

> Subject: Trying to get a DATE/TIME from MS-Excel.
> 
>    I am using the latest version of Perl for Win32 with MS-Excel
> for Windows95. I am using the OLE interface to access a spreadsheet.
> I can get all of the cells with no problem, but how do I convert the
> date/time fields? I get a XXXXX.YYYYYY type number, but I don't
> know how to decode it. According to the Excel docs, the digits on the
> left of the dot are the date and those to the right are the time. But
> I couldn't figure out what the encoding scheme was. If anyone can
> help, PLEASE do!

If this isn't covered in Excel's documentation, you should ask for your
money back. But it's actually not a Perl question, since it's an Excel
question. But here's an idea, if you can't find anything in the manual and
you can't wait for customer support to tell you what's up: Put a few
different dates into the field and see what numbers you get. Maybe you can
figure out how to decode it that way. Good luck! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

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

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