[9027] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2645 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 20 00:09:04 1998

Date: Tue, 19 May 98 21:00:25 -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, 19 May 1998     Volume: 8 Number: 2645

Today's topics:
        "Here" docs & cgi programming <lniederberger@monmouth.com>
    Re: "Out of Memory!" on DecAlpha/WinNT/IIS3 (Martien Verbruggen)
    Re: $|, fork and pipe (Charles DeRykus)
    Re: Authentication?? (Mark-Jason Dominus)
    Re: Automation For Posting <rborland@erols.com>
    Re: Creating HTML tables? <shiloh@pairnet.com>
    Re: Cryptography in Perl? <dformosa@st.nepean.uws.edu.au>
        Dose %_ have a spacal meaning? <dformosa@st.nepean.uws.edu.au>
    Re: Email type gateway (Martien Verbruggen)
    Re: file locking question (Mark-Jason Dominus)
        Help please... <dimce@hotmail.com>
    Re: One you glob it, once you don't? (Mike Heins)
    Re: One you glob it, once you don't? (Jeffrey Drumm)
    Re: Playing with PostgreSQL (Leslie Mikesell)
        Printing to LPT2 or LPT3 on NT <jgreene@ham.wb4uds.org>
        readkey (Chico)
    Re: readkey <tchrist@mox.perl.com>
    Re: regexp for strings of chars <lr@hpl.hp.com>
    Re: sort array of hashes (Matt Knecht)
    Re: sort array of hashes (Mark-Jason Dominus)
    Re: stat function, strange behaviour, please help (Martien Verbruggen)
    Re: stat function, strange behaviour, please help (Mark-Jason Dominus)
    Re: translate A-Z to 1-26 <jstern@world.northgrum.com>
    Re: while, each & assoc array <dformosa@st.nepean.uws.edu.au>
        why doesn't it work?? (Chico)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 19 May 1998 23:38:47 -0400
From: Liz & Joe Niederberger <lniederberger@monmouth.com>
Subject: "Here" docs & cgi programming
Message-Id: <35625047.46CD@monmouth.com>

I was thinking how nice it would be if I could write
cgi scripts with "variable interpolation" operating on
subroutine references as well as scalars and arrays.

Combined with here documents it would allow a very clean 
expression of "recursive descent" style text generation.
You could call it syntactic sugar but it sure would make
the typical code I write much easier to read. 

Anyone know why Perl only interpolates scalars & arrays?

Thanks,

Joe Niederberger


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

Date: 20 May 1998 02:05:38 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: "Out of Memory!" on DecAlpha/WinNT/IIS3
Message-Id: <6jtdpi$3f$2@comdyn.comdyn.com.au>

In article <3561B396.7EFC9156@terraincognita.com>,
	Raymond Simmons <raymond@terraincognita.com> writes:

> Here's the stats on the system the script is running on...
> Platform: Dec Alpha
> Operating System: WindowsNT
> Web Server: Internet Information Server 3

Isn't this slightly irrelevant?

> This script works fine in a Unix/Apache environment.  In fact it can
> process a 10 meg file with no problem.  Anybody got a clue as to why it
> could be running out of memory in the DecAlpha/WindowsNT/IIS3
> environment?  

Euhmmm.. maybe you don't have enough memory?

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd.       | negative.
NSW, Australia                      | 


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

Date: Wed, 20 May 1998 00:10:37 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: $|, fork and pipe
Message-Id: <Et8B5p.3Fs@news.boeing.com>

One of the CGI FAQ's probably has something about this.
Basically, the server will pipe buffer CGI output, i.e,
store output until the pipe buffer fills or the pipe
is closed. Since the forked process's output will also be 
piped, the order of output will depend on which process 
flushes output first. That's indeterminate so you may 
experience unexpected output order. Unbuffering the pipe 
with $|=1, will cause an immediate flush of any pipe input 
to prevent this problem.


HTH,
--
Charles DeRykus


In article <3561FE9A.DEF5AABF@shell.com>, Yong Huang  <yong@shell.com> wrote:
>There's an interesting question at the CGI group. But I think it's
>better asked here. The question asks why he got "Content-type: text/html
>Hello" in the browser by executing the script below (called q.pl here)
>while he only got "Hello" if $|=1 is uncommented? Seems it has to do
>with piping. I don't know how to explain. This is my screen dump (the
>prompt is proteus%):
>
>proteus% cat q.pl
>#!/usr/shell/bin/perl -w
>#$|=1;
>print "Content-type: text/html\n\n";
>if (fork)
> { print "Hello\n";
> }
>proteus% q.pl
>Content-type: text/html
>
>Hello
>proteus% q.pl | more
>Content-type: text/html
>
>Content-type: text/html
>
>Hello
>proteus% q.pl | cat
>Content-type: text/html
>
>Content-type: text/html
>
>Hello
>




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

Date: 19 May 1998 20:51:33 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Authentication??
Message-Id: <6jt9el$kvu$1@monet.op.net>
Keywords: Cornish flown Nabisco Vega


In article <35608B06.6C6C474D@Compuserve.com>,
Mark Sage  <Mark_Sage@Compuserve.com> wrote:
>I am trying to get a PERL program to display a user/password dialog, and
>then process the input.  I can make the dialog display by sending a
>"HTTP/1.0 404 Not Authorized", but no matter what I do I cannot get
>anything returned.

Typically, the web server will not give you the credentials, because
doing so would create a possible security problem.  

The solution (if there is one) depends on your web server.  It will
involve recompiling or reconfiguring the server, or putting a hook
into the API, or something.  Whatever it is, it's not appropriate for
this newsgroup; please ask in the group about your server, whatever
that is.

>Is this possible, can I do it with PERL, does anyone have an example?

On most servers, it is not possible in Perl or in any other language.



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

Date: Tue, 19 May 1998 21:51:42 -0400
From: Randy Borland <rborland@erols.com>
Subject: Re: Automation For Posting
Message-Id: <3562372D.EB328A9A@erols.com>

Brian, Bill has a good question - how do we contact this intern with the magical
fingers.  More directly, if it was easy, can you share the script?

 ... Randy

Bill 'Sneex' Jones wrote:

> brian d foy wrote:
> > >You're looking for clairvoyance =)  You would need several
> > >Wizards, and a magician or two.  And I would still wonder how...
> >
> > perhap Sneex could talk to my intern who has programmed such a thing.
> > didn't seem that difficult - that's why i had him do it.
> >
> > all in Perl, wouldn't you know.
>
> What his/her phone number =)  I am always interested in solutions.
>
> Money is no object!
> -Sneex-
> ____________________________________________________________________________
> Bill Jones | FCCJ Webmaster | Voice 1-904-632-3089 | Fax 1-904-632-3007
> Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
> mailto:webmaster@fccjmail.fccj.org | http://webmaster.fccj.org/Webmaster





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

Date: 19 May 1998 20:51:56 GMT
From: "Shiloh Jennings" <shiloh@pairnet.com>
Subject: Re: Creating HTML tables?
Message-Id: <01bd8398$b0c96c20$e3958ecf@webclient>



djones@everest.walcoff.com wrote in article
<6jsiih$ajb$1@nnrp1.dejanews.com>...
> what I'm trying to do is write a perl script that takes an ascii file
that
> contains a table template like the on below and convert it into an HTML
table.
> 
> ----------------------------------------------------
>          |         |           |
>          |         |           ---------------------
>          |         |           |      |      |
> ----------------------------------------------------
> 
> The ultimate goal is to come up with an algorithem that would work an any
> template.  Any ideas?

Write a recursive algorythm that can nest tables.  Tables are pretty
simple, so it should not be too overly hard to create such a script.  Good
luck.  :)

Shiloh
http://www.pairnet.com/


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

Date: 20 May 1998 02:22:10 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: Cryptography in Perl?
Message-Id: <895630930.600374@cabal>

In <35620160.2EA8E1C6@webspan.net> Arthur Dardia <ahdiii@webspan.net> writes:

>I'm learning Perl and am a complete NEWBIE to crytography.  I want to
>learn about using encryption in Perl.  I searched around and found the
>webpage for that "export-a-crypto-system sig" thing that a lot of ppl
>post to Usenet with.  How does it help?

The export a crypto-system sig thing is just an act of cival disobedence
and not realy a serious crypto system.

>  Any information?
>alt.sources.crypto is dead.  Any other newsgroups that deal with crypto?

sci.cryt dose.  If you are intersted in cyrpto I suggest most storngly
that you buy "Applied Cryprogphy" by Brusce Schneier.

--
I'm a perl programer; if you need perl programing, hire me. 
Please excuse my spelling as I suffer from agraphia; see the url. Support NoCeM
http://www.cit.nepean.uws.edu.au/~dformosa/Spelling.html  http://www.cm.org/ 
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: 20 May 1998 02:44:09 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Dose %_ have a spacal meaning?
Message-Id: <895632249.454950@cabal>

Every so often I see a refrence to %_ in ether this newsgroup or burried
within code.  However nether the FAQ's nor the man pagers nor perldoc will
tell me anything about it.

Is is spechal, or is it just a normal hash that gets shoved about in *_
along with $_ and @_ ?


--
I'm a perl programer; if you need perl programing, hire me. 
Please excuse my spelling as I suffer from agraphia; see the url. Support NoCeM
http://www.cit.nepean.uws.edu.au/~dformosa/Spelling.html  http://www.cm.org/ 
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: 20 May 1998 02:04:08 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Email type gateway
Message-Id: <6jtdmo$3f$1@comdyn.comdyn.com.au>

In article <6jsdh3$cch$1@news.bond.net>,
	"Toastboy" <toastboy@mindless.com> writes:
> I need to know if there is a script of some sort for an email reader/writer
> out there.  Preferably free.  But will pay if needed.

I am not entirely sure what you mean by 'email reader/writer', but I
suspect the modules in the Mail:: hierarchy will help you,

You can get these from http://www.perl.com/CPAN/modules/

(GBARR/MailTools-x.xx.gz might be a good start)

Martien
-- 
Martien Verbruggen                  | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au    | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd.       | I can ask him what he meant - Steven
NSW, Australia                      | Wright


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

Date: 19 May 1998 20:30:03 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: file locking question
Message-Id: <6jt86b$kph$1@monet.op.net>
Keywords: downslope ego faith microbial


In article <6jslin$7lv$1@news12.ispnews.com>,
Ryan McGuigan <ryan@mail.ramresearch.com> wrote:
>How can I read the last line of a file, and then append to it while having
>it locked the whole time?  

I didn't try this, but if the file is long, it will probably be a lot
more efficient than solutions that read the whole file.

$LINELEN = 80;  # Line length estimate---need not be exactly correct.
open (F, "+>> $filename")
  or die "Couldn't open file `$filename' for read/append: $!; aborting";
flock(F, LOCK_EX);  # block until lock acquired
until ($lastline) {
  seek F, -$LINELEN, 2;
  read(F, $lastline, $LINELEN);
  chomp($lastline);
  last if $lastline =~ s#.*$/##o; # omit `o' if you plan to change $/
  $LINELEN *= 2;
}
# Last line of file now in $lastline

seek F, 0, 2;   # Unnecessary on many systems

print F "BLAH blah blah blah blah.\n";  # Append
print F "YAKKITY YAKK YAKK YAK YAKKITY YAK.\n";

close F;   # Unlocks file.  Do /not/ use LOCK_UN.




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

Date: Wed, 20 May 1998 13:20:02 +1000
From: Dimce H <dimce@hotmail.com>
Subject: Help please...
Message-Id: <35624BE1.24198134@hotmail.com>

Hello people  how are you?
 I wanted to ask anyone if they could help me with a major assignment of
mine. I am struggling big time.  I have to write a Perl script that gets
data from a browser and inserts it into a database. I dont know where
to start. For example do I need a separate HTML form, and if so, how
will the input of the form be passed onto the script? Does it matter
which Windows server I run on my NT machine? Which win32 extensions do I
need to install? Any other special applications?  How would I start this
script? Any ideas? Have you got any scripts similar to this one?  It is
supposed to take the Name, Surname, Student number (for validation),
Subject name and a mark for that subject, and then store them into a
database (possibly MS Access). It sounds fairly simple but to a newbie
this is an extremely difficult task. Can I get my hands on a script like
this one anywhere on the net?

Please, please help me if you can if have a spare minute to look into it
and help me out heaps.

Thanking you kindly,
DimCe



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

Date: 19 May 1998 20:05:43 -0500
From: mikeh@minivend.com (Mike Heins)
Subject: Re: One you glob it, once you don't?
Message-Id: <35621e57.0@news.one.net>

Marek Jedlinski <cicho@polbox.com> wrote:

> Under Sarathy's port, however, no such "pre-globbing" takes place. Now the
> very same script does receive only the actual filemask. This is the
> behavior I prefer, but of course a question about portability arises. It's
> not a *burning* question for me at the moment, but I am curious. How would
> the same script work on a unix system? And, more to the point, is there a
> way of ensuring that file globbing will work the same way across win32
> *and* unix platforms? Best of all, can I ensure that the OS doesn't meddle
> with globbing at all and leave the dirty work to the script or perhaps a
> CPAN module? Or is OS globbing the way to go, actually?

OS globbing is going to be different on different platforms.

> Code sample follows; thanks in advance for a hint (yes, a pointer will do
> just fine :)

> .marek

# This assumes you have already done any getopt processing
BLOCK {
	# A real Ctrl-O
	last BLOCK unless $ =~ /win32/i;
	eval {
		require 5.004;
	};
	# ActiveState, breaks on a real * in a file name
	if($@) {
		@ARGV = ()
			if index($ARGV[0], '*') > -1;
	}
	# Standard
	else {
		@ARGV = map { glob $_ } @ARGV;
	}
}


-- 
Mike Heins                          http://www.minivend.com/  ___ 
                                    Internet Robotics        |_ _|____
Just because something is           131 Willow Lane, Floor 2  | ||  _ \
obviously happening doesn't         Oxford, OH  45056         | || |_) |
mean something obvious is           <mikeh@minivend.com>     |___|  _ <
happening. --Larry Wall             513.523.7621 FAX 7501        |_| \_\


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

Date: Wed, 20 May 1998 00:51:57 GMT
From: drummj@mail.mmc.org (Jeffrey Drumm)
Subject: Re: One you glob it, once you don't?
Message-Id: <356428e8.5247968@news.mmc.org>

[posted and mailed]

On Tue, 19 May 1998 20:59:34 GMT, cicho@polbox.com (Marek Jedlinski) wrote:

>Confession: my perl runs on a win32 system. End-of-confession.

Well, you can at least comfort yourself with the fact that you've got the
company of plenty of fellow sinners . . . ;-)

(snip)

>	perl runme.pl *.txt
>the script didn't actually _see_ '*.txt'; what it received was a list of
>matching files. (Which, incidentally, broke my original idea for the script
>itself, since I wanted to interpret the commandline input differently based
>on whether a file name or a file *mask* was given. Here I could not
>distinguish between the two, I was always getting file names only.) 

>I understand that the OS was doing the globbing and feeding the filenames
>to Perl - or if perlglob.exe was running I never noticed since I was
>editing in full-screen mode. (BTW, I was not using "File::DosGlob".) Only
>if there were no matching files, the actual filemask got through to the
>script. I didn't like that, since I'd much rather use readdir and/or
>File::Find for my purpose, but I learned to live with it.

PerlGlob.exe in the ActiveState port was doing the globbing for you (hit
Alt-Enter before running the script to "windowize" the console; you'll see
the title bar change to PerlGlob.EXE briefly when you run your script).
This is the _only_ feature that improves on the 'standard' distribution . .
 . and that's only because it seems to work the way a *nix Perl developer
would expect (at least, one that doesn't know ahead of time that neither
DOS nor NT do command-line filename expansion for you). It wasn't an
important enough feature to prevent me from switching to Sarathy's port,
though.

>Under Sarathy's port, however, no such "pre-globbing" takes place. Now the
>very same script does receive only the actual filemask. This is the
>behavior I prefer, but of course a question about portability arises. It's
>not a *burning* question for me at the moment, but I am curious. How would
>the same script work on a unix system? And, more to the point, is there a
>way of ensuring that file globbing will work the same way across win32
>*and* unix platforms? Best of all, can I ensure that the OS doesn't meddle
>with globbing at all and leave the dirty work to the script or perhaps a
>CPAN module? Or is OS globbing the way to go, actually?

Under most *nix shells, wildcard characters are expanded to a list of
matching file names; the application never sees the glob characters.
However, under many *nix shells, you can turn globbing off; doing this
before script execution allows you to parse the command line literally. My
own experience is primarily with the Korn shell, and I know it's possible
in that. I know the C shell supports the disabling of globbing, and I think
Bourne does as well. But I don't think disabling globbing is an optimal
solution.

There's no good answer for this, I'm afraid. The one solution I saw in
DejaNews for the GS port  is apparently only partially effective (something
to do with setting the PERL5OPT environment variable to automatically load
a module, which may or may not have been File::DosGlob; not on-line at the
moment, so I can't easily check).

The only solution I can think of is to check the OS name variable $^O, and
branch accordingly. If it's not "MSWin32",  assume your file names are in
@ARGV; otherwise, expand the wild cards yourself. Unfortunately, this
doesn't solve the portability problem between the two major Win32 Perls.

As an aside . . . am I the only one who thinks the OS name variable looks
like a smiley  screaming in terror?

If you have to check it, be scared . .  . be very, very scared . . .
must've been implemented with the first version of Perl available for
Windows. ;-)

>Code sample follows; thanks in advance for a hint (yes, a pointer will do
>just fine :)

>.marek

(code sample snipped for brevity)

Good luck . . .

-- 
                           Jeffrey R. Drumm, Systems Integration Specialist
                                  Maine Medical Center Information Services
                                     420 Cumberland Ave, Portland, ME 04101
                                                        drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented." -me


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

Date: 19 May 1998 21:22:05 -0500
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: Playing with PostgreSQL
Message-Id: <6jteod$1pr$1@Venus.mcs.net>

In article <Pine.LNX.3.96.980518113521.12717D-100000@tre.thewild.com>,
Scott Webster Wood - TheWild Webster  <swood@TheWild.Com> wrote:
>Does anyone have a copy of this article?
>
>If an when this month does come up, do you recall the subject line?  Last
>months has a lot of stuff with DBI and PERL in the subject lines.

I think this is the next step:

From: "G.Richter" <richter@ecos.de>
To: <modperl-announce@apache.org>, "DBI Users" <dbi-users@fugue.com>,
Subject: ANNOUNCE: DBIx-Recordset-0.14-beta
Date: Tue, 19 May 1998 23:59:24 +0200

The first release of DBIx::Recordset is ready for testing.
At the moment it can be only found at

ftp://ftp.dev.ecos.de/pub/perl/dbi/DBIx-Recordset-0.14-beta.tar.gz

DBIx::Recordset is a perl module, which should make it easier to access a
set of records in a database.


Les Mikesell
   les@mcs.com


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

Date: Tue, 19 May 1998 22:58:50 -0400
From: "Joe Greene" <jgreene@ham.wb4uds.org>
Subject: Printing to LPT2 or LPT3 on NT
Message-Id: <6jtgv1$544@enews4.newsguy.com>

Is there a way to print to LPT2?  I've tried "print LPT2 'some output'".
And I've tried 'open OUTDEV, ">LPT2"'.  So far, the only way I've been able
to do it is by outputing to a file and then copying the file to LPT2.  Seems
to me there should be a way to use LPT2 with the print statement.




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

Date: Wed, 20 May 1998 06:15:57 GMT
From: flaon@iis.com.br (Chico)
Subject: readkey
Message-Id: <6jteqj$dar@news.iis.com.br>

Hello!!

Is there any function wich reads a key from keyboard as soon as we
type it??

Like READKEY in pascal:

character := readkey;

thanks!!



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

Date: 20 May 1998 02:51:16 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: readkey
Message-Id: <6jtgf4$r2b$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    flaon@iis.com.br (Chico) writes:
:Is there any function wich reads a key from keyboard as soon as we
:type it??
:
:Like READKEY in pascal:
:
:character := readkey;

That's in perlfaq8 -- did you look there first?  If you haven't
grepped the manpages and faqpages cover to cover, you haven't 
looked hard enough.

Here's one solution:

    use Term::ReadKey;
    ReadMode('cbreak');
    $key = ReadKey(0);
    ReadMode('normal');

Here's another solution:

    use HotKey;
    $key = readkey();

--tom


    # HotKey.pm
    package HotKey;

    @ISA = qw(Exporter);
    @EXPORT = qw(cbreak cooked readkey);

    use strict;
    use POSIX qw(:termios_h);
    my ($term, $oterm, $echo, $noecho, $fd_stdin);

    $fd_stdin = fileno(STDIN);
    $term     = POSIX::Termios->new();
    $term->getattr($fd_stdin);
    $oterm     = $term->getlflag();

    $echo     = ECHO | ECHOK | ICANON;
    $noecho   = $oterm & ~$echo;

    sub cbreak {
        $term->setlflag($noecho);  # ok, so i don't want echo either
        $term->setcc(VTIME, 1);
        $term->setattr($fd_stdin, TCSANOW);
    }

    sub cooked {
        $term->setlflag($oterm);
        $term->setcc(VTIME, 0);
        $term->setattr($fd_stdin, TCSANOW);
    }

    sub readkey {
        my $key = '';
        cbreak();
        sysread(STDIN, $key, 1);
        cooked();
        return $key;
    }

    END { cooked() }

    1;
-- 
    echo "Congratulations.  You aren't running Eunice."
        --Larry Wall in Configure from the perl distribution


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

Date: Tue, 19 May 1998 17:18:02 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: regexp for strings of chars
Message-Id: <6jt7g8$5h2@hplntx.hpl.hp.com>

[posted and emailed]

Ilya Zakharevich wrote in message
<6jt016$11u$1@mathserv.mps.ohio-state.edu>...
>[A complimentary Cc of this posting was sent to Larry Rosler
><lr@hpl.hp.com>],
>who wrote in article <6jsn1j$9r@hplntx.hpl.hp.com>:
>> [posted and emailed]
>>
>> sloop@mailcity.com wrote in message
>> <3561d94d.49203470@news.xmission.com>...
>> >>|     @trips = m/.(?<=(?=($triple)).)/go;
>>
 ...
>If you read my original message, you would know the answer about ?. .
>And qr// did not make it into 5.005 due to a strike of perl developers
>over licensing issues.
>
>Ilya

I found this in your original message (from May 14).  To me, at least,
it is somewhat cryptic.  More than part of one sentence would be
necessary before I were sure I understood it.

----
After almost-successful //h debate (heirarchical match) on p5p I
decided to postpone implementing (?.REX) construct (which would hide
parens/backrefs from the enclosing RE, and would start counting groups
from 1).  With such a construct, this might have been optimized to

    @trips = m/(?=((?.(.)\1{2})))/g
----

My original point about not blowing away the guy who asked about this,
by pointing him at Friedl's book, still stands.

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





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

Date: Wed, 20 May 1998 00:34:37 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: sort array of hashes
Message-Id: <xyp81.550$YC.2724216@news3.voicenet.com>

On 19 May 1998 23:32:29 GMT, Irene Barg <barg@nickel.as.arizona.edu> wrote:
>	    $href->{'rel_focus'} = $rel_focus;	       # add a new key to $href
>            @myLoH = sort byrel_focus @LoH;
>sub byrel_focus {
>    $rel_focus{$a} <=> $rel_focus{$b};
>}  

You're passing an array of hashrefs to sort().  $a and $b will turn
out to be hashrefs in your sorter sub.  So, just use them like
hashrefs, not hash keys.

Something like this should work:

sub byrel_focus {
	$a->{'rel_focus'} <=> $b->{'rel_focus'};
}

>I know I need to create a list of 'rel_focus' values, then sort

The list is already there... no need to create it :)

-- 
Matt Knecht + <hex@voicenet.com>


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

Date: 19 May 1998 20:39:07 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: sort array of hashes
Message-Id: <6jt8nb$krj$1@monet.op.net>
Keywords: Cezanne hasten mixup uppercut


In article <6jt4qd$ehq$1@news.ccit.arizona.edu>,
Irene Barg <barg@nickel.as.arizona.edu> wrote:
>I want to sort an array of hashes based on the value of a specific key
>in each hash.  I've read the Perl FAQ and Tom Christiansen's "Far More
>Than Everything You've Ever Wanted to Know About Sorting", and I'm
>still not getting it right.

Close, though.  You may groan in annoyance when you see what you did.

@LoH is a list of hashes, but actually, the elements are hashes.
You want to sort these hashes depending on the values in their
`rel_focus' members.

Now, `sort' calls your comparator function:
>sub byrel_focus {
>    $rel_focus{$a} <=> $rel_focus{$b};
>}  

with $a and $b set to the two elements of the list that it wants to
compare.  $a and $b are list elements.  What kind of things are the
list elements?  Hash references.  So $a and $b are hash references.
You want to compare the `rel_focus' members of these hashes.  If $a is
a hash reference, how do you get its `rel_focus' member?  Like this:

	sub by_rel_focus {
	  $a->{'rel_focus'} <=> $b->{'rel_focus'}
	}

That should do it, I think.

> I need to get this done yesterday, 

(Looks at watch.)

Sorry!


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

Date: 19 May 1998 23:44:47 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: stat function, strange behaviour, please help
Message-Id: <6jt5hf$sln$1@comdyn.comdyn.com.au>

In article <6jt2n0$56t$1@nntp1.ba.best.com>,
	"Rich Bodo" <richbodo@pacbell.net> writes:
> Note: I also posted this to alt.perl without cross posting, although I

A quick search on dejanews for articles in that group shows 40
articles. I guess you might say that groups is dead. I guess most
servers don't even have it. I don't see any use for perl in the alt.
hierarchy :). Stick with this one.

>     I am new to perl and am writing a subroutine to print all of the
> filenames, dates, and times in a given subdirectory.  I ran across some
> unexpected behaviour from the stat function.  Only directories return an
> atime or an mtime, not files.  I am not sure what I am doing wrong, but I
> have enclosed my program, it's output, and the actual look of the directory
> in NT. (I have tried the exact same program under digital unix on an
> identical directory with the same results)

atime, mtime and ctime are not meaningful on all platforms. Not all
file systems keep track of these things, and therefore, stat won't
always return anything useful in them. Which parts of the list stat
returns depends on your OS and file system. It might be documented in
the documentation that comes with your version of perl, or it might be
documented in the perl for Win32 FAQ (which is specific for the
Activestate port, I believe)

I am not sure if there is a difference in the way the ActiveState port
and the GS port have implemented stat, but normally I believe it
should just be a wrapper around the system call stat(2).

Martien
-- 
Martien Verbruggen                  | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au    | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd.       | I can ask him what he meant - Steven
NSW, Australia                      | Wright


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

Date: 19 May 1998 21:03:13 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: stat function, strange behaviour, please help
Message-Id: <6jta4h$l1l$1@monet.op.net>
Keywords: Martinez potato reluctant silt


In article <6jt2n0$56t$1@nntp1.ba.best.com>,
Rich Bodo <richbodo@pacbell.net> wrote:
> Only directories return an
>atime or an mtime, not files. 

The usenet oracle says:

	You should learn to use the debuggger.

>        @allfiles = readdir USERDIR;

If you look in this variable, you will see that it contains a list of
strings like `email2.em'.


>                ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
>                        $atime,$mtime,$ctime,$blksize,$blocks)
>                        = stat $filename;

Now you are asking for the information about `email2.em'.

In which directory?

In the CURRENT directory.  

But `email2.em' is not IN the current directory.

You meant to do

	stat "$_[0]/$filename"

didn't you?  Because the file is in directory $_[0], not in the
current directory.

It `worked' for `.' because there happens to be a `.' in both
directories.  But it didn't really work, because it returned the times
for the wrong file.

The Usenet Oracle says:

	This is discussed in the manual under `readdir'.



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

Date: Tue, 19 May 1998 23:52:05 GMT
From: "James M. Stern" <jstern@world.northgrum.com>
Subject: Re: translate A-Z to 1-26
Message-Id: <35621B25.EC67998E@world.northgrum.com>

Larry Rosler wrote:
> On a somewhat brighter note, I know of no character sets in which the
> ten decimal digits aren't contiguous and monotonically increasing.  So
> [0-9] is safe.  Whew...

This is very likely to be true for any computer that offers a C
translator.  The C standard requires that characters '0'..'9' have
contiguous codes.  IOW, this assumption is about as portable as
assumptions get.

-- 
James M. Stern -- Views here are my own, not my employer's.  
(Hawthorne, CA)


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

Date: 20 May 1998 02:57:45 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: while, each & assoc array
Message-Id: <895633065.788742@cabal>

In <MPG.fcb5d46636d76149896cf@news.min.net> jdporter@min.net (John Porter) writes:

>On Mon, 18 May 1998 16:18:40 GMT,
>in article <1d982ps.1cdon0b158dtq3N@roxboro0-027.dyn.interpath.net>,
>phenix@interpath.com (John Moreno) wrote:
>> 
>> Yeah, I don't know who should be given the credit for it, but perls
>> alternative for the single statement  (statement condition;) is much
>> better.

>What, you're thinking it might be someone other than Larry?

>From the camel, 

BASIC/PLUS
  Another ancient languge, from which Perl derived exactly one idear. OK
maybe two.*

* BASIC/PLUS is a registed [...ect...] And the answers are stament
modifers and maybe formats.


--
I'm a perl programer; if you need perl programing, hire me. 
Please excuse my spelling as I suffer from agraphia; see the url. Support NoCeM
http://www.cit.nepean.uws.edu.au/~dformosa/Spelling.html  http://www.cm.org/ 
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: Wed, 20 May 1998 06:15:53 GMT
From: flaon@iis.com.br (Chico)
Subject: why doesn't it work??
Message-Id: <6jteqg$dar@news.iis.com.br>

Look at what i am trying please!!!

@ARGV = ('1.txt', '2.txt', '3.txt');

foreach $linha (<>) {
  print "$linha at $ARGV[0]";
}

It does not print the name of the file ( $ARGV[0] )!

ps.: I was under Win95... i didn't try YET under Unix!

thanks for any help supplied!!

bye



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

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

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