[11352] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4952 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 20 20:07:29 1999

Date: Sat, 20 Feb 99 17:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 20 Feb 1999     Volume: 8 Number: 4952

Today's topics:
        Adding another variable <mailbox@gunnar.cc>
        Drag and Drop ASCII File in Windows  <jjrael@mediaone.net>
        FAQ 4.2: Why isn't my octal data interpreted correctly? <perlfaq-suggestions@perl.com>
        FAQ 4.3: Does Perl have a round() function?  What about <perlfaq-suggestions@perl.com>
        FAQ 4.4: How do I convert bits into ints?   <perlfaq-suggestions@perl.com>
    Re: guestbook perl script <vrwaciuk@sprint.ca>
    Re: guestbook perl script (Cesar Romani)
    Re: Handling files greater than 2.1 GB <skilchen@swissonline.ch>
    Re: HELP me with flock please!! (Ronald J Kimball)
        Help needed urgently! <wmtoh@singnet.com.sg>
    Re: Help needed urgently! (Steve Linberg)
    Re: Help needed urgently! <Allan@Due.net>
        HELP w/ SOCKETS + PORTS!!! <support@mekagames.com>
    Re: HELP w/ SOCKETS + PORTS!!! (Alastair)
    Re: How to Search FAQ? <tchrist@mox.perl.com>
        man pages <info@blue.uk.com>
    Re: man pages <gellyfish@btinternet.com>
    Re: man pages <tchrist@mox.perl.com>
    Re: Non-greedy matching (Ronald J Kimball)
    Re: perl 5.005_02 compile on FreeBSD 3.0 <*#^&$@ennui.org>
    Re: Perl Editors for WinNT? (Brett W. McCoy)
        Problem recapturing errors from Apache::ePerl (Steve Linberg)
        trapping arrow keys <fournierc@psi.ca>
    Re: trapping arrow keys <tchrist@mox.perl.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Sun, 21 Feb 1999 01:12:43 +0100
From: Gunnar Hjalmarsson <mailbox@gunnar.cc>
Subject: Adding another variable
Message-Id: <36CF4F7B.13F36163@gunnar.cc>

Hi,

I wonder if anybody could advise me how to modify a Perl script, so that
it picks up the value of an extra variable from one of the forms that
the script works with. It's a mail script; please feel free to see how
it works at http://www.gunnar.cc/mailman.html .

The script requires the library cgi-lib.pl, and I have studied a few
tutorials on the web to find a lead. However, the script is a lot more
complicated than the examples I've found. This is how it starts:

        use Socket;
        require $strLocalScriptLocation . 'cgi-lib.pl';
        local(%mma, %mmb, %mmc, %mmd);
        ReadParse(\%mma,\%mmb,\%mmc,\%mmd);

        foreach $mme (keys %mma) {
         if($mme =~ /^(.+)\.[xy]$/) {
          if($mme =~ /^([^\#]+)\#(.*)\.[xy]$/)
           { $mma{$1} = mmie($2); }
           else { $mma{$1} = 'MAILMANSPECIALTRUE'; }
          delete($mma{$mme}); } }

        if($mma{'INTERFACE'}) {
         @mmf = split(/\&/,$mma{'INTERFACE'});
         foreach $mmg (@mmf) {
          if($mmg =~ /^([^\=]+)\=(.*)$/) {
           $mma{$1} = mmie($2); } }
         unless($mma{'INTERFACE'} =~ /ALTERNATE_TEMPLATES/) {
          $mma{'ALTERNATE_TEMPLATES'} = ''; } }

        @mmh = split(/\;/,$ENV{'HTTP_COOKIE'});
        foreach $mmi (@mmh) {
         $mmj = TRUE;
         if($mmi =~ /MailManAuth\=(\S+)/) {
          @mmk = split(/\&/,$1);
          foreach $mml (@mmk) {
           $mml =~ /^(.+)\#(.+)$/;
           unless($mma{$1}){ $mma{$1} = $2; } } } }

        $mmm = mmii($mma{'USERNAME'});
        $mmn = mmih($mmm);

        $mmo = mmii($mma{'PASSWORD'});
        $mmp = mmih($mmo);

        unless($strIncomingServer)
         { $strIncomingServer = mmii($mma{'SERVER'}); }
        $mmq = mmih($strIncomingServer);

Well, I stop it here. I suppose that the lines
        local(%mma, %mmb, %mmc, %mmd);
        ReadParse(\%mma,\%mmb,\%mmc,\%mmd);
have something to do with my failures when I tried to add an extra
variable. I simply don't understand what these lines do.

Needless to say, I'm an amateur of this, and I'd very much appreciate if
someone could show me how to do it.

Gunnar Hjalmarsson


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

Date: Sat, 20 Feb 1999 16:55:10 -0800
From: Jacob Rael <jjrael@mediaone.net>
Subject: Drag and Drop ASCII File in Windows 
Message-Id: <36CF596E.5C4699D8@mediaone.net>

Hello,

I would like to make an application that I can drag and drop an ascii
file on-top of and it will modify it (one example is dos <-> unix). I
come from a unix background so my old version is used a shell script to
call a perl script (the shell script was to handle the file names
easily).

I tried to do it using a shortcut and batch file however I am missing
something. I can write it so a specific file gets modified but I don't
know how to extract the file name from the "drag and drop" operation.

jr



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

Date: 20 Feb 1999 15:01:08 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 4.2: Why isn't my octal data interpreted correctly?  
Message-Id: <36cf30a4@csnews>

(This excerpt from perlfaq4 - Data Manipulation 
    ($Revision: 1.43 $, $Date: 1999/01/26 09:57:23 $)
part of the standard set of documentation included with every 
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq4.html
if your negligent system adminstrator has been remiss in his duties.)

  Why isn't my octal data interpreted correctly?

    Perl only understands octal and hex numbers as such when they occur as
    literals in your program. If they are read in from somewhere and
    assigned, no automatic conversion takes place. You must explicitly use
    oct() or hex() if you want the values converted. oct() interprets both
    hex ("0x350") numbers and octal ones ("0350" or even without the leading
    "0", like "377"), while hex() only converts hexadecimal ones, with or
    without a leading "0x", like "0x255", "3A", "ff", or "deadbeef".

    This problem shows up most often when people try using chmod(), mkdir(),
    umask(), or sysopen(), which all want permissions in octal.

        chmod(644,  $file); # WRONG -- perl -w catches this
        chmod(0644, $file); # right

-- 
    X-Windows: It was hard to write; it should be hard to use.
	--Jamie Zawinski


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

Date: 20 Feb 1999 16:01:11 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 4.3: Does Perl have a round() function?  What about ceil() and floor()?  Trig functions?  
Message-Id: <36cf3eb7@csnews>

(This excerpt from perlfaq4 - Data Manipulation 
    ($Revision: 1.43 $, $Date: 1999/01/26 09:57:23 $)
part of the standard set of documentation included with every 
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq4.html
if your negligent system adminstrator has been remiss in his duties.)

  Does Perl have a round() function?  What about ceil() and floor()?  Trig functions?

    Remember that int() merely truncates toward 0. For rounding to a certain
    number of digits, sprintf() or printf() is usually the easiest route.

        printf("%.3f", 3.1415926535);       # prints 3.142

    The POSIX module (part of the standard perl distribution) implements
    ceil(), floor(), and a number of other mathematical and trigonometric
    functions.

        use POSIX;
        $ceil   = ceil(3.5);                        # 4
        $floor  = floor(3.5);                       # 3

    In 5.000 to 5.003 Perls, trigonometry was done in the Math::Complex
    module. With 5.004, the Math::Trig module (part of the standard perl
    distribution) implements the trigonometric functions. Internally it uses
    the Math::Complex module and some functions can break out from the real
    axis into the complex plane, for example the inverse sine of 2.

    Rounding in financial applications can have serious implications, and
    the rounding method used should be specified precisely. In these cases,
    it probably pays not to trust whichever system rounding is being used by
    Perl, but to instead implement the rounding function you need yourself.

    To see why, notice how you'll still have an issue on half-way-point
    alternation:

        for ($i = 0; $i < 1.01; $i += 0.05) { printf "%.1f ",$i}

        0.0 0.1 0.1 0.2 0.2 0.2 0.3 0.3 0.4 0.4 0.5 0.5 0.6 0.7 0.7 
        0.8 0.8 0.9 0.9 1.0 1.0

    Don't blame Perl. It's the same as in C. IEEE says we have to do this.
    Perl numbers whose absolute values are integers under 2**31 (on 32 bit
    machines) will work pretty much like mathematical integers. Other
    numbers are not guaranteed.

-- 
    "Just because you're screwed *up* doesn't mean you're screwed." --Larry Wall


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

Date: 20 Feb 1999 17:01:14 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 4.4: How do I convert bits into ints?  
Message-Id: <36cf4cca@csnews>

(This excerpt from perlfaq4 - Data Manipulation 
    ($Revision: 1.43 $, $Date: 1999/01/26 09:57:23 $)
part of the standard set of documentation included with every 
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq4.html
if your negligent system adminstrator has been remiss in his duties.)

  How do I convert bits into ints?

    To turn a string of 1s and 0s like `10110110' into a scalar containing
    its binary value, use the pack() and unpack() functions (documented in
    the section on "pack" L<perlfunc/"unpack" in the perlfunc manpage):

        $decimal = unpack('c', pack('B8', '10110110'));

    This packs the string `10110110' into an eight bit binary structure.
    This is then unpack as a character, which returns its ordinal value.

    This does the same thing:

        $decimal = ord(pack('B8', '10110110'));

    Here's an example of going the other way:

        $binary_string = unpack('B*', "\x29");

-- 
BTL didn't really have a distribution policy in the early days,
you got a disk with a note: Here's your rk05, Love Dennis.  If UNIX
crapped on your rk05, you'd write to Dennis for another.
 --Andy Tannenbaum, "Politics of UNIX," Washington, DC USENIX Conference, 1984


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

Date: Sat, 20 Feb 1999 17:16:01 -0500
From: "Vince Waciuk" <vrwaciuk@sprint.ca>
Subject: Re: guestbook perl script
Message-Id: <UxGz2.43925$b8.18937800@hme2.newscontent-01.sprint.ca>

Agreed.

Use CGI.pm to parse your input and maybe try appending your data to your
guestbook file like this

open (GUEST,">>$file") || die "can't open GUEST $!";
    print GUEST $parsed_input;
close (GUEST);

Cheers
Anonymous wrote in message <7al3gn$l46$1@winter.news.rcn.net>...
>Has anyone ever written a *working* guestbook script for an NT server?  If
>so, please assist me...if not, please assist me =)





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

Date: 20 Feb 1999 22:37:17 GMT
From: romani_c@bigfoot.com (Cesar Romani)
Subject: Re: guestbook perl script
Message-Id: <slrn7cue8t.1o9o.romani_c@rzaix05.rrz.uni-hamburg.de>

You should use "/" and not "\":

$file = "D:/Customer Sites/DStern/cgi-bin/guestbook.dat";

On Fri, 19 Feb 1999 20:36:30 -0500, Anonymous wrote:
>Has anyone ever written a *working* guestbook script for an NT server?  If
>so, please assist me...if not, please assist me =)
>
>My guestbook.pl script:
>
>
>#GUESTBOOK.PL
>
>$file = "D:\Customer Sites\DStern\cgi-bin\guestbook.dat";
>$date = localtime(time);
>
>$ENV{"REQUEST_METHOD"} eq "POST" ? &Add_Guest($file) :
>&Display_Book($file);
>
>
>
>It returns the error:
>'D:\User Space\Webmaster\cgi-bin\guestbook.pl' script produced no output
>
>Please give me some help on this.  Thank you.
>
>
>


-- 
Cesar Romani
Hamburg, Germany


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

Date: Sat, 20 Feb 1999 23:50:04 +0100
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: Handling files greater than 2.1 GB
Message-Id: <7anedo$3un5@news-sol.swissonline.ch>

Jonathan Feinberg schrieb in Nachricht ...
>>>>>> "AK" == Amod Kale <amod.kale@vlsi.com> writes:
>
>   AK> Now my file size has grown to 2.2 GB and the perl script
>   AK> refuses to recognize it.
>
>There is no inherent limitation in the size of a file that Perl will
>manipulate.

Are you sure? Does Perl not use the stdio functions fseek, ftell, etc?
If it does, then there is an arbitrary limit in the file size Perl can
handle: the maxvalue of a long int on your system.

--
Samuel Kilchenmann
skilchen@swissonline.ch





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

Date: Sat, 20 Feb 1999 17:35:56 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: HELP me with flock please!!
Message-Id: <1dnjb0y.1f4agbk1kpjlc4N@bay2-54.quincy.ziplink.net>

<msztipan@bellsouth.net> wrote:

> #  if (flock(FH, 2) == 0) {
> #    print scalar localtime, " trying second lock ...\n";
> #    if (flock(FH, 2) == 0) {
> #      print "  .... GOT second lock.\n";
> #    }

Does a return value of 0 indicate success or failure?  Make up your
mind.  ;-)

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Mon, 22 Feb 1999 05:56:13 +0800
From: "Luke" <wmtoh@singnet.com.sg>
Subject: Help needed urgently!
Message-Id: <7anc0i$h2i$1@mawar.singnet.com.sg>

Please email me with the answer if you know it.

How do I randomly select X number of items from Y with no repeat where X is
less than Y.

eg randomly choosing 5 out of 20 unique numbers and none of the 5 numbers
chosen are repeated numbers.

I really would like to know how because the code I wrote using hashes
doesn't work.  Here's what I did.  The program will pick a random number and
then delete that entry from the hash.  Then it will repeat with another
pick.  However, sometimes it randomly picks a key that was already picked
before (but it was deleted).  I don't know why it can still pick an already
deleted key.  Anyway, I need to squeeze the hash down before randomly
picking again.....anyone know how??

Luke





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

Date: Sat, 20 Feb 1999 23:01:02 GMT
From: slinberg@crocker.com (Steve Linberg)
Subject: Re: Help needed urgently!
Message-Id: <slinberg-2002991801030001@cc11620-a.lwmrn1.pa.home.com>

In article <7anc0i$h2i$1@mawar.singnet.com.sg>, "Luke"
<wmtoh@singnet.com.sg> wrote:

> How do I randomly select X number of items from Y with no repeat where X is
> less than Y.

Populate an array of Y entries with the information you want.  Randomize
it by iterating through it randomly swapping positions.  Pop X entries off
of the array.  Nothing to it.


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

Date: Sat, 20 Feb 1999 18:13:53 -0500
From: "Allan M. Due" <Allan@Due.net>
Subject: Re: Help needed urgently!
Message-Id: <clHz2.297$986.6726@nntp1.nac.net>

Luke wrote in message <7anc0i$h2i$1@mawar.singnet.com.sg>...
:Please email me with the answer if you know it.


Sorry, but the cultural norm for this newsgroup is post here, read here.  Hope
you understand.

:How do I randomly select X number of items from Y with no repeat where X is
:less than Y.

:eg randomly choosing 5 out of 20 unique numbers and none of the 5 numbers
:chosen are repeated numbers.
:I really would like to know how because the code I wrote using hashes
:doesn't work.  Here's what I did.  The program will pick a random number and
:then delete that entry from the hash.  Then it will repeat with another
:pick.  However, sometimes it randomly picks a key that was already picked
:before (but it was deleted).  I don't know why it can still pick an already
:deleted key.  Anyway, I need to squeeze the hash down before randomly
:picking again.....anyone know how??


Well, it would be helpful to have seen the actual code. I would have done it a
different way.  Perhaps something like this?

#!/usr/local/bin/perl -w
use strict;
my @y = qw( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20);
my($selected,%numbers);
my $need = 0;

while($need < 5) {
    $selected = $y[rand @y];
    next if exists $numbers{$selected};
    $numbers{$selected} = 1;
    $need++
}
print "The selected numbers are", map {" $_"} keys %numbers;

HTH

AmD




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

Date: 20 Feb 1999 22:39:16 GMT
From: "MekaGames Staff" <support@mekagames.com>
Subject: HELP w/ SOCKETS + PORTS!!!
Message-Id: <01be5d21$25490940$a089accf@default>

Hello to all,
I'm having a very simply problem, but I need this problem solved as soon as
possible so please email me at kpahlevan@hotmail.com if you have a solution
to the following problem:

I have the following script:

#!/usr/bin/perl
use IO::Socket;

@hosts = ('ftp.microsoft.com','ftp.netscape.com','ftp.cuteftp.com');
$port = 21;

#####################################################################

print "Content-type: text/html\n\n";
print "Here are the results of your port-checking:<br><hr>\n";

foreach $host (@hosts) {
	if ($remote = IO::Socket::INET -> new (
		Proto => "tcp",
		PeerAddr => $host,
		PeerPort => $port) || die "Could not connect to $!\n")
	{
		print "<hr>$host : $remote<br>\n";
	}
}

The problem is, the script only gives a response for the sites that it can
reach, and does not pring "Count not connect to $!" when it's unable to
connect to a site. If you can help me out here, please do so!! Also, this
is not absolutely necessary, I'd like to make it so if after 10 seconds it
still hasn't been able to check the port, it can assume it's a closed port.
Please help me in any way you can. Thank you.

- Kaveh Pahlevan


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

Date: Sat, 20 Feb 1999 22:45:57 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: HELP w/ SOCKETS + PORTS!!!
Message-Id: <slrn7cuerq.eu.alastair@calliope.demon.co.uk>

MekaGames Staff <support@mekagames.com> wrote:
snip
>
>foreach $host (@hosts) {
>	if ($remote = IO::Socket::INET -> new (
>		Proto => "tcp",
>		PeerAddr => $host,
>		PeerPort => $port) || die "Could not connect to $!\n")
snip
>The problem is, the script only gives a response for the sites that it can
>reach, and does not pring "Count not connect to $!" when it's unable to
>connect to a site. If you can help me out here, please do so!! Also, this

Perhaps try setting a timeout value?

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: 20 Feb 1999 14:56:56 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to Search FAQ?
Message-Id: <36cf2fa8@csnews>

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

In comp.lang.perl.misc, Jonathan Stowe <gellyfish@btinternet.com> writes:
:Or indeed , if you have better than Perl 5.005.02 :
:perldoc -q <whatever>

That's a bad hack, and nothing so flexible as what I devised in a mere
couple hours of coding.  The power of combining small tools
that do one thing well cannot be understated.

With my stuff, you have the choice of grepping in whatever podfile
you feel like, just the headers or otherwise. 

Notice how nicely it combines with other things:

    $ podgrep match `which podgrep`

    $ podgrep typeglob `basepods`

    $ podgrep object `sitepods`

    $ podgrep number `faqpods`

    $ podgrep -h number `faqpods`

etc.

See http://mox.perl.com/misc/pmtools-1.00.tar.gz to see
what I mean.  Make sure you see the README.

    pmpath - show the module's full path
    pmvers - get a module version number
    pmdesc  - get a module description
    pmall  - get all installed modules pmdesc descriptions 
    pmdirs    - print the perl module path, newline separated
    plxload - show what files a given program loads at compile time
    pmload - show what files a given module loads at compile time
    pmexp - show a module's exports
    pminst  - find what's installed
    pmeth - list a class's methods, recursively
    pmls  - long list the module path
    pmcat  - cat the module source through your pager
    pman - show the module's pod docs
    pmfunc - show a function source code from a module
    podgrep - grep in pods of a file
    pfcat - show pods from perlfunc
    podtoc - list table of contents of a podpage
    podpath - show full path of pod file
    pods - list all standard pods and module pods
    sitepods - list only pods in site_perl directories
    basepods - list only normal "man-page" style pods
    faqpods - list only faq pods
    modpods - all module pods, including site_perl ones
    stdpods - list standard pods, not site_perl ones

--tom
-- 
I've got plenty of inputs and outputs.  I don't need the video. --Andrew Hume


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

Date: Sat, 20 Feb 1999 22:13:16 -0000
From: "Matt" <info@blue.uk.com>
Subject: man pages
Message-Id: <7anbvd$lmn$1@starburst.uk.insnet.net>

I have just downloaded active perl from active state, what i cant find are
the man pages, do i have to download these separately

Thanks
Matt




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

Date: 20 Feb 1999 22:55:17 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: man pages
Message-Id: <7anegl$28b$1@gellyfish.btinternet.com>

On Sat, 20 Feb 1999 22:13:16 -0000 Matt wrote:
> I have just downloaded active perl from active state, what i cant find are
> the man pages, do i have to download these separately
> 

They are installed as HTML and if you have installed it properly there
will be an item on your Start menu that will be a shortcut to the index
page ,,.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 20 Feb 1999 16:58:13 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: man pages
Message-Id: <36cf4c15@csnews>

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

In comp.lang.perl.misc, Jonathan Stowe <gellyfish@btinternet.com> writes:
:They are installed as HTML and if you have installed it properly there
:will be an item on your Start menu that will be a shortcut to the index
:page ,,.

Well, that's lame.  Sure makes it hard to use tools (like pmtools).
I guess that consumer-oriented, programmer-hostile systems aren't set
up for that kind of thinking, however.  That's a shame, because it keeps
them shackled in the dark forever.

--tom
-- 
"I'd rather have :rofix than const."
	    --Dennis Ritchie


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

Date: Sat, 20 Feb 1999 17:35:57 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Non-greedy matching
Message-Id: <1dnjbd5.r54wdca1wdtsN@bay2-54.quincy.ziplink.net>

Mark <admin@asarian-host.org> wrote:

> Suppose I have the following domains:
> 
> $sites{'cwdomains'} = 'domain_one|domain_two';
> 
> then:
> 
> s/\@.*?(?:($sites{'cwdomains'}))/\@$1/gi;
> 
> will fail is there are multiple email addresses on the same line: the
> ".*?" is discarded, and a greedy match is done. Okay, I asked for that
> with "?:", but is there any way I can match ".*?" non-greedy before
> "(?:($sites{'cwdomains'}))" ?

You fail to understand non-greedy matching.

The non-greedy match is not "discarded".  Regardless of greediness, it
is always the *leftmost* match that will be returned.  With greediness,
it is the longest leftmost, and with non-greediness, the shortest
leftmost, but either way it's still the leftmost match.

For example:

$_ = 'abc@no.com def@a.yes.com ghi@b.yes.com';

/@.*yes\.com/;    # matches '@no.com def@a.yes.com ghi@b.yes.com'

/@.*?yes\.com/;   # matches '@no.com def@a.yes.com'


If you don't want to match the @ sign, then say so explicitly:

/@[^@]*yes\.com/; # matches '@a.yes.com'


Non-greedy matching tends to be overused.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 20 Feb 1999 14:03:47 -0800
From: onomatopoetic justice <*#^&$@ennui.org>
Subject: Re: perl 5.005_02 compile on FreeBSD 3.0
Message-Id: <rone.7anbg3$6s4$1@ennui.org>

In article <m3n229ec79.fsf@ratatosk.netcetera.dk>,
Ask Bjoern Hansen  <ask@netcetera.dk> wrote:
>My compilation of perl5.005_02 (./Configure -des) ends like this:

Um, FreeBSD 3.0 already comes with perl 5.005_02 as part of the
system.  And, of course, if you wanted to install it on your own
anyway, it will work much better if you go to /usr/ports/lang/perl5
and type "make install".

rone
-- 
In the truest spirit of usenet I actually have zero idea what I'm talking
about and am making all this up, but it does seem reasonable and has the
added benefint of possibly even beng true.
					- Richard Sexton <richard@vrx.net>


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

Date: Sat, 20 Feb 1999 22:27:13 GMT
From: bmccoy@news.lan2wan.com (Brett W. McCoy)
Subject: Re: Perl Editors for WinNT?
Message-Id: <slrn7cucj8.31v.bmccoy@dragosani.lan2wan.com>

On 19 Feb 1999 13:36:57 GMT, H.A. <ns-am528@chebucto.ns.ca> wrote:

>I'm just starting on Perl and I do most of my programming on WinNT.  I hate 
>using Notpad for programming.  I was wondering if there is a nice CGI/Perl 
>editor out there that I could use. Kind of like HTML editor (Not WYSIWYG).

I'd grab a copy of emacs for Win32.  It handles the perl syntax quite
well, as well as many other languages.

-- 
Brett W. McCoy           
                                        http://www.lan2wan.com/~bmccoy/
-----------------------------------------------------------------------
To be or not to be, that is the bottom line.

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GAT dpu s:-- a C++++ UL++++$ P+ L+++ E W++ N+ o K- w--- O@ M@ !V PS+++
PE Y+ PGP- t++ 5- X+ R+@ tv b+++ DI+++ D+ G++ e>++ h+(---) r++ y++++
------END GEEK CODE BLOCK------


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

Date: Sat, 20 Feb 1999 22:53:29 GMT
From: slinberg@crocker.com (Steve Linberg)
Subject: Problem recapturing errors from Apache::ePerl
Message-Id: <slinberg-2002991753300001@cc11620-a.lwmrn1.pa.home.com>

Folks,

I've exhausted all of my research and information channels at this point,
so I thought I'd see if I'm not the only one having this problem.

I'm using Apache::ePerl to embed Perl as a server-side scripting language
for a large site I'm working on.  It's terrific, fast, smooth, easy. 
Great.  It even has a nice built-in error-handler that generates a page
when an error occurs, so you don't have to comb through server logs to
find your typos and snytax errors.

The trouble is, there doesn't appear to be an easy way to turn this
behavior off, and there are circumstances where I need to be able to react
to errors, not just have the whole process ripped away from me when one
occurs.  This application is very DBI-intensive, and there are DBI-related
errors that I need to be able to detect and react to (like missing tables,
syntax errors from SQL statements, and so forth) to carry out certain
actions (like emailing the maintainer, and maybe presenting a nice "we
suck" apology page tweaked the way we want it).  However, I can't get
control back from ePerl.  Even executing code inside an eval block kicks
back out to ePerl if an error happens.

Browsing the Parse::ePerl source (used by Apache::ePerl), I see that the
author (Ralf Engelschall, whom I also wrote to a week or two ago, no
response yet) is capturing STDERR with a tie() system, and locally
undefining $SIG{__DIE__} before eval'ing the embedded code.  I don't want
to hack his code at all if I can avoid it, obviously.  I thought maybe I
could preface code I'd like to be able to get errors in like this:

{
  local $SIG{__WARN__};     # ...also tried local $SIG{__WARN__} = 'DEFAULT';
  local $SIG{__DIE__};      # ...also tried local $SIG{__DIE__} = 'DEFAULT';
  my $txt_error = "";

  $dbh->do{"SELECT * FROM tbl_foo"} or { $txt_error = $DBI::errstr; }

  &do_something if ($txt_error);
}

 ...which sort of works, in that an error does go to the server logs and
the "Server error" text is echoed to the web page (heh, imagine being
psyched to see a 500 error!) -- AFTER the Apache::ePerl error page text,
which is still being generated.

ePerl undefines the __DIE__ signal before eval'ing, and also redirects
STDERR (and STDOUT) with a TIE system to capture error messages to a
variable, and then generates the error page if either $@ is non-null, or
its stderr capture variable is non-null.  My undefining __DIE__ appears to
circumvent the first check, but STDERR output is still channeled into its
accumulating variable, so the error page still gets called.

I'd like to prevent this, and set STDERR back to whatever it's supposed to
be for the duration of the block.  This isn't a rechanneling of STDERR as
in FAQ 8.25, and I don't want to write a new tie system or just dump
STDERR to /dev/null or another black hole, because it may have important
information.  What I'd like to do, in a sense, is temporarily untie STDERR
from whatever the caller has tied it to, so I can intercept the errors
myself, but return in the same state I was called in.  Like setting
$SIG{__DIE__} to 'DEFAULT', but for the STDERR channel.  (I'm a little
fuzzy on the stuff in this last paragraph, and not sure that I'm barking
up the right tree.)

Anybody know a way to do this, or have other suggestions?

I'll post a solution when/if I find or get one. Cheers.

--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: Sat, 20 Feb 1999 18:51:50 -0500
From: "chris fournier" <fournierc@psi.ca>
Subject: trapping arrow keys
Message-Id: <o0Iz2.86$%i7.382892@NewsRead.Toronto.iSTAR.net>

Does anyone know how to trap arrow keys? When I tried doing an 'ord' on a
'getc', the values were all the same...




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

Date: 20 Feb 1999 17:09:18 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: trapping arrow keys
Message-Id: <36cf4eae@csnews>

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

In comp.lang.perl.misc, "chris fournier" <fournierc@psi.ca> writes:
:Does anyone know how to trap arrow keys? When I tried doing an 'ord' on a
:'getc', the values were all the same...

Get the Curses module.  Or train your silly users not to use
sillly keys, which is the better approach.

    use Curses;
    keypad(1);                  # enable keypad mode
    $key = getch();
    if ($key eq 'k'     ||      # sublime vi mode
        $key eq "\cP"   ||      # silly emacs mode
        $key eq KEY_UP)         # stupid arrow mode
    {
        # do as thou wilt
    } 


--tom
-- 
    It's there as a sop to former Ada programmers.  :-)
        --Larry Wall regarding 10_000_000 in <11556@jpl-devvax.JPL.NASA.GOV>


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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