[18606] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 774 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 26 18:06:47 2001

Date: Thu, 26 Apr 2001 15:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <988322715-v10-i774@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 26 Apr 2001     Volume: 10 Number: 774

Today's topics:
    Re: Appending to files and flock. (Abigail)
    Re: Browsing Directories by CGI <camerond@mail.uca.edu>
    Re: Debugging Perl <djberge@uswest.com>
    Re: FAQ 3.15:   What is undump? (Anno Siegel)
        Foreing Newbie: How can I convert a perl source code in <mececo99@tamarugo.cec.uchile.cl>
    Re: Foreing Newbie: How can I convert a perl source cod (Craig Berry)
    Re: Foreing Newbie: How can I convert a perl source cod <Jonathan.L.Ericson@jpl.nasa.gov>
        Getting partition size from perl script <rlf@proimages.net>
    Re: Getting partition size from perl script <root@novastar.dtdns.net>
    Re: Getting partition size from perl script <rlf@proimages.net>
    Re: Good editor for perl (Anno Siegel)
    Re: Help Me Obi One You're my Only Hope (Rudolf Polzer)
        How to enclose scalar for readability? <nobody@nobody.com>
    Re: How to enclose scalar for readability? (Greg Bacon)
    Re: How to enclose scalar for readability? (Anno Siegel)
    Re: How to enclose scalar for readability? (Andrew J. Perrin)
    Re: How to enclose scalar for readability? <sthomas@ws5120.nc.fnc.fujitsu.com>
    Re: How to enclose scalar for readability? (Greg Bacon)
    Re: How to enclose scalar for readability? <bart.lateur@skynet.be>
    Re: How to enclose scalar for readability? <bart.lateur@skynet.be>
    Re: How to enclose scalar for readability? (Abigail)
    Re: https module <prcotter@bellsouth.net>
        loop variable scope rasunci@qual-pro.no-spam.com
    Re: match a range of number (Craig Berry)
    Re: match a range of number (Anno Siegel)
    Re: match a range of number (Craig Berry)
    Re: match a range of number (Abigail)
    Re: match a range of number (Anno Siegel)
    Re: Needing Help! <Jonathan.L.Ericson@jpl.nasa.gov>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 26 Apr 2001 21:40:07 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Appending to files and flock.
Message-Id: <slrn9eh5dn.jr5.abigail@tsathoggua.rlyeh.net>

Paul the Nomad (taka@yarn.demon.co.uk) wrote on MMDCCXCV September
MCMXCIII in <URL:news:87ae53fya8.fsf@euterpe.yarn.demon.co.uk>:
\\  abigail@foad.org (Abigail) writes:
\\  
\\ > Paul the Nomad (taka@yarn.demon.co.uk) wrote on MMDCCXCV September
\\ > MCMXCIII in <URL:news:87oftk0w2a.fsf@euterpe.yarn.demon.co.uk>:
\\ > ;;  
\\ > ;;  
\\ > ;;  I've just been looking at someone's code for a very basic survey/poll
\\ > ;;  cgi.  You know, the sort of thing that you see on Slashdot.
\\ > ;;  
\\ > ;;  Every time someone votes the result is appended to a file...something
\\ > ;;  like this:
\\ > ;;  
\\ > ;;  open (FH, ">> results.txt");
\\ > ;;  print FH $result;
\\ > ;;  close FH;
\\ > ;;  
\\ > ;;  However, the author of this code doesn't lock the file at all.  Surely
\\ > ;;  as a CGI you might get many attempts to append to the file at the same
\\ > ;;  time.  My question is shouldn't flock be used here?  Or is there
\\ > ;;  something about 'print FH ...' that makes it atomic?
\\ > 
\\ > 
\\ > No, it's something about the open mode.
\\ > 
\\ > 
\\ > Did you study perlopentut?
\\ > 
\\  
\\  Eh??? That just says the way to lock is to use flock and using lock
\\  files may cause race conditions.


Locking isn't involved here, now is it?

perlopentut will tell you about the relation of Perls open, and the
system calls. If you then look up the documentation of the system calls
you should pay attention to the mode the file is opened.



Abigail



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

Date: Thu, 26 Apr 2001 13:30:12 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Browsing Directories by CGI
Message-Id: <3AE86934.2E8E584@mail.uca.edu>

Stuart Moore wrote:
> 
> Sorry, I haven't made myself clear. I am already able to upload/download by FTP
> and CHMOD using that, but only over my ISP's dial up (their policy). This
> prevents me working at other times, e.g. from my higher speed connection at
> school. I want something that can effectively mimic FTP browsing, by having a
> script that can read the directory contents, format them, and when appropriate
> upload/download files. I was hoping someone else had written it to avoid me
> having to. I agree telnet would be useful but unfortunatly they explicitly state
> they won't accept telnet connections. The hosting's far cheaper than anywhere
> else I've found, which is why I go there.
> 
> Stuart

IF the directories you need to access are accessible through the
webserver, then, yes. Use CGI.pm and/or LWP. If they are not in the
webserver directory structure, you might be able to access them through
scripts on the webserver leading to your directories (depending on
permissions, etc.), but it would be more complicated.

Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu


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

Date: Thu, 26 Apr 2001 13:38:37 -0500
From: "Mr. Sunray" <djberge@uswest.com>
Subject: Re: Debugging Perl
Message-Id: <3AE86B2D.18F38E25@uswest.com>

"jaime.suarez-murias@icn.siemens.com" wrote:

> Is there a book that discusses--with examples--the use of
> Perl's debugger?
>
> Is there a GUI debugger available?
>
> Thank you in advance,
> Jaime

"Debugging Perl" by Martin Brown (Osbourne/McGraw Hill) covers it, and
is a very good book in general, I might add.

There are a few options for a GUI debugger, depending on the OS.  For
Windows, you can try one of the beta Komodo releases (I don't think the
"official" release is free).  There is a Perl/Tk debugger called
"Devel-ptkdb" on CPAN (requires Tk module of course).  For *nix, you can
always use DDD.

Hope that helps.

Dan



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

Date: 26 Apr 2001 18:36:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: FAQ 3.15:   What is undump?
Message-Id: <9c9pqu$dr8$2@mamenchi.zrz.TU-Berlin.DE>

According to PerlFAQ Server  <faq@denver.pm.org>:
> This message is one of several periodic postings to comp.lang.perl.misc
> intended to make it easier for perl programmers to find answers to
> common questions. The core of this message represents an excerpt
> from the documentation provided with every Standard Distribution of
> Perl.
> 
> +
>   What is undump?
> 
>     See the next questions.
> 
> - 
> 
> Documents such as this have been called "Answers to Frequently

Hmm...  This one is of little use, posted this way.  Are there more
like this?  Enough to warrant maintaining a list for the autoposter?

Anno


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

Date: Thu, 26 Apr 2001 15:09:03 -0400
From: "Gian Paulo Rondanelli" <mececo99@tamarugo.cec.uchile.cl>
Subject: Foreing Newbie: How can I convert a perl source code in a binary file
Message-Id: <9c9si4$mng$1@news.cec.uchile.cl>

How I can transform the source code of a Perl program , so that it is
possible to be executed,
 but not possible to view his source code.






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

Date: Thu, 26 Apr 2001 21:24:48 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Foreing Newbie: How can I convert a perl source code in a binary file
Message-Id: <teh4h0dv0rbtb7@corp.supernews.com>

Gian Paulo Rondanelli (mececo99@tamarugo.cec.uchile.cl) wrote:
: How I can transform the source code of a Perl program , so that it is
: possible to be executed, but not possible to view his source code.

  perldoc -q hide
  perldoc perlcc

But hiding your source is a poor way to protect it.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: 26 Apr 2001 21:46:56 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Foreing Newbie: How can I convert a perl source code in a binary file
Message-Id: <86lmon1ghb.fsf@jon_ericson.jpl.nasa.gov>

"Gian Paulo Rondanelli" <mececo99@tamarugo.cec.uchile.cl> writes:

> How I can transform the source code of a Perl program , so that it is
> possible to be executed,
>  but not possible to view his source code.

Hola!

perldoc -q 'hide.*source'

Jon


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

Date: Thu, 26 Apr 2001 13:10:07 -0700
From: Robert Fonda <rlf@proimages.net>
Subject: Getting partition size from perl script
Message-Id: <3AE8809F.578BD38D@proimages.net>

What is the best way for a perl script to obtain the size of free space
on a partition?

r.f


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

Date: Fri, 27 Apr 2001 00:42:20 +0300
From: "novastar" <root@novastar.dtdns.net>
Subject: Re: Getting partition size from perl script
Message-Id: <9ca4nn$h64$1@usenet.otenet.gr>

The following will work only on windows nt4 / 2000 with the Win32::AdminMisc
module installed.


use Win32::AdminMisc;
foreach ( Win32::AdminMisc::GetDrives(DRIVE_FIXED) )
{
print "\nSpace on $_ volume (Mbytes)\n","-" x28,"\n\n";
chop;
@space=Win32::AdminMisc::GetDriveSpace("$_");
printf "Total : %.2f\n", $space[0]/(1024**2) ;
printf "Free  : %.2f\n", $space[1]/(1024**2) ;
printf "full  : %.2f%\n", (100-(100*($space[1]/$space[0])));
}




"Robert Fonda" <rlf@proimages.net> wrote in message
news:3AE8809F.578BD38D@proimages.net...
> What is the best way for a perl script to obtain the size of free space
> on a partition?
>
> r.f




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

Date: Thu, 26 Apr 2001 14:55:05 -0700
From: Robert Fonda <rlf@proimages.net>
Subject: Re: Getting partition size from perl script
Message-Id: <3AE89939.4AED840@proimages.net>

Robert Fonda wrote:
> 
> What is the best way for a perl script to obtain the size of free space
> on a partition?
> 
> r.f

How stupid of me, I forgot, I am running Linux V5.6.0. Thanks for the
WinNT stuff, I'll hang onto it!

r.f


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

Date: 26 Apr 2001 18:21:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Good editor for perl
Message-Id: <9c9ovf$dr8$1@mamenchi.zrz.TU-Berlin.DE>

According to Samuel Thomas  <sthomas@ws5120.nc.fnc.fujitsu.com>:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> 
> 
> > I'm breaking a 10+ year-long habit of indenting by twos in favor
> > of the mainstream fours, and I feel it's slowing me down a bit.
> > Two blanks per indent was no problem, four is too much.  Otherwise,
> > the transition is easier than I expected.
> 
> Forgive me if I'm misinterpreting your problem, but in both vim and 
> emacs you can set up your editor to auto-indent with spaces rather
> than tabs.  Is this what you are looking for?  I don'tremember how
> to do it but I think the article was somewhere at www.jwz.org

Thanks for the info.

There is no problem to misinterpret.  My whole point (if there is
such) was that with two blanks per level I didn't even bother to
turn on auto-indent while now, with four, I intended to (and have
since).

Clpm, I am sure, is delighted to be informed of these events.  :)

Anno


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

Date: Thu, 26 Apr 2001 21:49:16 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: Help Me Obi One You're my Only Hope
Message-Id: <slrn9eguts.fu0.eins@www42.t-offline.de>

Tuan Ngo <tuan.ngo1@home.com> wrote:
> Need assistance with writing a Perl Script for the following problem...  Any
> help will be much appreciated... I may be able to provide compensation.....
[file renaming]

perldoc -f rename
perldoc -f sprintf
perldoc perlre

may help you.

> Sitting at a UNIX (Irix 6.5.8) terminal, use whatever methods you prefer to
> rename and resequence these frames into their acceptable naming conventions
> and proper sequential order. You may use any means at your disposal,
> including most basic scripting languages.

Is perl a `basic scripting language`?

-- 
#!/usr/bin/perl -- WARNING: Be careful. This is a virus!!! # rm -rf /
eval($0=q{$0="\neval(\$0=q{$0});\n";for(<*.pl>){open X,">>$_";print X
$0;close X;}print''.reverse"\nsuriv lreP trohs rehtona tsuJ>RH<\n"});
####################### http://learn.to/quote #######################


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

Date: Thu, 26 Apr 2001 14:25:57 -0400
From: Marc <nobody@nobody.com>
Subject: How to enclose scalar for readability?
Message-Id: <nobody-47C630.14255726042001@news.rcn.com>

Is there a way to enclose a scalar variable for both readability and 
parsing reasons?

For example:

print "This is the two variables I want $together$here"

Is there some way to enclose these so they are not together and will 
print ok still.  Especially if I have a variable named $together and 
maybe one called $togethe (and I want the "r" to print between $togethe 
and $here)


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

Date: Thu, 26 Apr 2001 18:31:04 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: How to enclose scalar for readability?
Message-Id: <tegqb825g30k62@corp.supernews.com>

In article <nobody-47C630.14255726042001@news.rcn.com>,
    Marc  <nobody@nobody.com> wrote:

: For example:
: 
: print "This is the two variables I want $together$here"
: 
: Is there some way to enclose these so they are not together and will 
: print ok still.  Especially if I have a variable named $together and 
: maybe one called $togethe (and I want the "r" to print between $togethe 
: and $here)

Use curly braces:

    print "${togethe}r${here}";

Note that the braces around $here aren't strictly necessary, but they
seem to provide balance.  YMMV.

Greg
-- 
Lisp requires an unhealthy relationship with the lambda calculus that
leads to proposing the dog of food instead of feeding the dog. 
    -- The Programmers' Stone


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

Date: 26 Apr 2001 18:47:36 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to enclose scalar for readability?
Message-Id: <9c9qg8$dr8$3@mamenchi.zrz.TU-Berlin.DE>

According to Greg Bacon <gbacon@hiwaay.net>:
> In article <nobody-47C630.14255726042001@news.rcn.com>,
>     Marc  <nobody@nobody.com> wrote:
> 
> : For example:
> : 
> : print "This is the two variables I want $together$here"
> : 
> : Is there some way to enclose these so they are not together and will 
> : print ok still.  Especially if I have a variable named $together and 
> : maybe one called $togethe (and I want the "r" to print between $togethe 
> : and $here)
> 
> Use curly braces:
> 
>     print "${togethe}r${here}";
> 
> Note that the braces around $here aren't strictly necessary, but they
> seem to provide balance.  YMMV.

Side note:  It's interesting that this construct is not a case of
the ${ BLOCK } dereferencing syntax.  While the latter would work
for ${togethe}, it would involve the bareword "togethe" (hmm, how
to quote a bareword?) and a symref to $togethe.  The behavior
against warnings and strict shows that it is special-cased.

Anno


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

Date: 26 Apr 2001 15:34:29 -0500
From: andrew_perrin@unc.edu (Andrew J. Perrin)
Subject: Re: How to enclose scalar for readability?
Message-Id: <87pudzz9gq.fsf@nujoma.perrins>

Marc <nobody@nobody.com> writes:

> Is there a way to enclose a scalar variable for both readability and 
> parsing reasons?

braces.

> 
> For example:
> 
> print "This is the two variables I want $together$here"
> 

print "These are the two variables I want ${together}${here}."

-- 
----------------------------------------------------------------------
Andrew J Perrin - Ph.D. Candidate, UC Berkeley, Dept. of Sociology  
(Soon: Asst Professor of Sociology, U of North Carolina, Chapel Hill)
andrew_perrin@unc.edu - http://www.unc.edu/~aperrin


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

Date: 26 Apr 2001 16:43:47 -0400
From: Samuel Thomas <sthomas@ws5120.nc.fnc.fujitsu.com>
Subject: Re: How to enclose scalar for readability?
Message-Id: <tl6pudzz918.fsf@ws5120.nc.fnc.fujitsu.com>

gbacon@HiWAAY.net (Greg Bacon) writes:

> Use curly braces:
> 
>     print "${togethe}r${here}";
> 
or:
print "we are all $togethe" . 'r' . $here;

-- 
                /\
Sam Thomas     /  \
Ext 1161      /	** \
	     /______\


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

Date: Thu, 26 Apr 2001 21:19:31 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: How to enclose scalar for readability?
Message-Id: <teh473pgsta856@corp.supernews.com>

In article <tl6pudzz918.fsf@ws5120.nc.fnc.fujitsu.com>,
    Samuel Thomas  <sthomas@ws5120.nc.fnc.fujitsu.com> wrote:

: gbacon@HiWAAY.net (Greg Bacon) writes:
: 
: > Use curly braces:
: > 
: >     print "${togethe}r${here}";
:
: or:
: print "we are all $togethe" . 'r' . $here;

TMTOWTDI:

    print "we're all $ta", 'rs in the dope ', "$how!";

Greg
-- 
Since I was running Windows, I did the normal thing you do when you
encounter problems: I rebooted.
    -- Simson Garfinkel


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

Date: Thu, 26 Apr 2001 21:27:38 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to enclose scalar for readability?
Message-Id: <gn4heto4di32o75rhcvo8gsg7l016k5ta9@4ax.com>

Anno Siegel wrote:

>>     print "${togethe}r${here}";
>> 
>> Note that the braces around $here aren't strictly necessary, but they
>> seem to provide balance.  YMMV.
>
>Side note:  It's interesting that this construct is not a case of
>the ${ BLOCK } dereferencing syntax.  While the latter would work
>for ${togethe}, it would involve the bareword "togethe" (hmm, how
>to quote a bareword?) and a symref to $togethe.  The behavior
>against warnings and strict shows that it is special-cased.

Plus: it works for lexicals, too. As Anno should know: symbolic
references, don't.

-- 
	Bart.


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

Date: Thu, 26 Apr 2001 21:28:26 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to enclose scalar for readability?
Message-Id: <8p4het08f853tnbo73bgreqj0qe4ehes41@4ax.com>

Marc wrote:

>print "This is the two variables I want $together$here"
>
>Is there some way to enclose these so they are not together and will 
>print ok still.  Especially if I have a variable named $together and 
>maybe one called $togethe (and I want the "r" to print between $togethe 
>and $here)

"${togethe}r"

but this works, too:

"$together\Er"

-- 
	Bart.


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

Date: Thu, 26 Apr 2001 21:42:18 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: How to enclose scalar for readability?
Message-Id: <slrn9eh5hq.jr5.abigail@tsathoggua.rlyeh.net>

Bart Lateur (bart.lateur@skynet.be) wrote on MMDCCXCV September MCMXCIII
in <URL:news:8p4het08f853tnbo73bgreqj0qe4ehes41@4ax.com>:
//  Marc wrote:
//  
// >print "This is the two variables I want $together$here"
// >
// >Is there some way to enclose these so they are not together and will 
// >print ok still.  Especially if I have a variable named $together and 
// >maybe one called $togethe (and I want the "r" to print between $togethe 
// >and $here)
//  
//  "${togethe}r"
//  
//  but this works, too:
//  
//  "$together\Er"


Really? Now, where is that documented? Or did you typo?



Abigail


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

Date: Thu, 26 Apr 2001 16:46:43 -0400
From: "Paul Cotter" <prcotter@bellsouth.net>
Subject: Re: https module
Message-Id: <fQ%F6.1649$5B4.665630@news2.mia>

"smilepak" <smilepak@hotmail.com> wrote in message
news:BJID6.971$cM1.57429@newsread1.prod.itd.earthlink.net...

> I need to access a secure http site to pull data on a daily basis. The
site
> request a username/password. Anyone know of a way I can get perl to do a
> https call and passing a username/password when it request for it?
>
> I know perl has a "GET" function, however that doesn't work with secure
http
> server.
>

Are you sure it is secure - it should be an https site. It may just be an
authorization procedure. If it is then you need something like:

use strict;
use IO::Socket;
use MIME::Base64;

# alter these next 4 lines
my $host = 'www.secure_site.com';
my $url = '/url/you/are/trying/to/go/to?name=paul+cotter&etc etc...';
my $userPass = 'userid:password';
my $referer = 'referer: /the/url/you/at/just/before/password/request';


my $socket;
ref ($socket = IO::Socket::INET->new
    ( Proto => 'tcp',
     PeerPort =>80,
     PeerAddr=>$host
    )
   )  or   die "socket not created on client side\n" ;

 my $decode = decode_base64( $userPath );
 chomp $decode;
 $auth = "Authorization: Basic $decode\n";
 };

my  $getCommand =
   "GET $url HTTP\/1.0\n".
   $auth.
   "Accept: *\/*\n" .
   "Accept-Encoding: gzip, deflate\n" .
   "Accept-Language: en-us\n" .
   "Connection: Keep-Alive\n" .
   $referer.
   'User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; COM+
1.0.2204)' ."\n".
   $host.
   "\n"

 $socket->send($getCommand ) ;
 $socket->recv($inText, 256000 ) ;

Note that you may well get your output back in chunks. You need to look at
the returned:

        Content-Length:

 ..header. You may also have look at the reply header to see if the:

        Connection: Keep-Alive

 ..header is there. Also note that this assumes you are going there from a
URL, and not as a result of pressing a Submit button on an HTML form.

If you need more help then please ask. Do use Telnet though and see what the
HTTP return code is in the reply from the server.

BCNU

Paul

www.powermagic.net





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

Date: 26 Apr 2001 20:50:25 GMT
From: rasunci@qual-pro.no-spam.com
Subject: loop variable scope
Message-Id: <9ca1mh$5sq$1@news.netmar.com>

Hi,

I'm hoping someone can explain. Consider:

use strict;
my $a = '';
my @ar = ('1');
print $a;
foreach $a (@ar) { print $a; }
print $a;

Inside the loop, $a = elements in @ar. Outside the loop,
$a = value before the loop. I would expect $a to keep its
last value inside the loop. Same thing happens when using,

while($a=shift(@ar)) {...}

But if I use,

while(@ar) { $a=shift(@ar); ... }

I get the result I want. What's going on? If $a is changing
from scalar to reference (or some other symbol) then back,
can I get this behavior from another construct? I'm using
$]=5.006. Thanks.


--
RA


 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: Thu, 26 Apr 2001 19:28:24 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: match a range of number
Message-Id: <tegtmocat6p0f0@corp.supernews.com>

David Bouman (david.bouman@nl.xo.com) wrote:
: Still, not being a math-person myself, I'll leave you with my $0.02:
: 
: 	sub strictly_sorted {
:             shift() < $_[0] && ( @_==1 || &strictly_sorted );
: 	}

Nice, but dies on lists of length 0 or 1.  Amended:

  sub strictly_sorted {
    @_ < 2 || (shift() < $_[0] && &strictly_sorted);
  }

One question about order of evaluation:  Is the shift() on the lhs of <
guaranteed to be evaluated before the $_[0] on the rhs, and if so, why?
(It was doubt about this that kept me away from this solution earlier in
the discussion.)

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: 26 Apr 2001 19:45:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: match a range of number
Message-Id: <9c9tsv$fca$3@mamenchi.zrz.TU-Berlin.DE>

According to Craig Berry <cberry@cinenet.net>:
> David Bouman (david.bouman@nl.xo.com) wrote:
> : Still, not being a math-person myself, I'll leave you with my $0.02:
> : 
> : 	sub strictly_sorted {
> :             shift() < $_[0] && ( @_==1 || &strictly_sorted );
> : 	}
> 
> Nice, but dies on lists of length 0 or 1.  Amended:
> 
>   sub strictly_sorted {
>     @_ < 2 || (shift() < $_[0] && &strictly_sorted);
>   }
> 
> One question about order of evaluation:  Is the shift() on the lhs of <
> guaranteed to be evaluated before the $_[0] on the rhs, and if so, why?
> (It was doubt about this that kept me away from this solution earlier in
> the discussion.)

Rightly so.  The evaluation order of parts of expressions is unspecified.
While I can't point to a part of the documentation that explicitly
says so, the only operator (I know of) that *does* specify an evaluation
order is the comma operator (left first).  

That said, I believe the code above would run on every Perl interpreter[1]
in the world.

Anno

[1] that groks it


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

Date: Thu, 26 Apr 2001 21:10:08 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: match a range of number
Message-Id: <teh3lgbekubb96@corp.supernews.com>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote:
: According to Craig Berry <cberry@cinenet.net>:
[snip]
: >     @_ < 2 || (shift() < $_[0] && &strictly_sorted);
[snip]
: > One question about order of evaluation:  Is the shift() on the lhs of <
: > guaranteed to be evaluated before the $_[0] on the rhs, and if so, why?
: > (It was doubt about this that kept me away from this solution earlier in
: > the discussion.)
: 
: Rightly so.  The evaluation order of parts of expressions is unspecified.
: While I can't point to a part of the documentation that explicitly
: says so, the only operator (I know of) that *does* specify an evaluation
: order is the comma operator (left first).  

Another example:  short-circuit evaluation of logic operators (|| && or
and) requires left-first evaluation, given that evaluation of the rhs may
not even occur. 

: That said, I believe the code above would run on every Perl interpreter[1]
: in the world.

I'm always nervous about relying on undocumented behavior.  It has bit me
hard a few times.

--
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: Thu, 26 Apr 2001 21:31:04 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: match a range of number
Message-Id: <slrn9eh4so.jr5.abigail@tsathoggua.rlyeh.net>

David Bouman (david.bouman@nl.xo.com) wrote on MMDCCXCV September
MCMXCIII in <URL:news:3AE848EC.7448FD99@nl.xo.com>:
--  David Bouman wrote:
-- > Abigail wrote:
-- > > David Bouman (david.bouman@nl.xo.com) wrote on MMDCCXCV September
-- > > MCMXCIII in <URL:news:3AE7DA90.6DE3C6A2@nl.xo.com>:
-- > > ??  Abigail wrote:
-- > > ??
-- > > ?? >     sub strictly_sorted {
-- > > ?? >         strictly_sorted (scalar (@_), 2) ||
-- > > ?? >         $_ [0] < $_ [1] && strictly_sorted @_ [1 .. $#_];
-- > > ?? >     }
-- > > ??
-- > > ??  Ehm.., doesn't this spell "infinite recursion" ?
-- > >
-- > > We were talking how a mathematician would do it. Certainly smart math
-- > > people won't limit themselves to evaluate an expression in just one way!
-- > > They'll pick the right path.
--  
--  I still am not convinced. Maybe I'm taking this too far but let's just write
--  one out:
--  
--  	ss(1,2,3)  :  ss(3,2) || 1<2 && ss(2,3)  ->  ss(3,2) || ss(2,3)
--  	ss(3,2)    :  ss(2,2) || 3<2 && ss(2)    ->  ss(2,2)
--          ss(2,3)    :  ss(2,2) || 2<3 && ss(3)    ->  ss(2,2) || ss(3)
--          ss(2,2)    :  ss(2,2) || 2<2 && ss(2)    ->  ss(2,2)
--  	ss(2)	   :  ss(1,2) 
--  	ss(3)	   :  ss(1,2)
--  	ss(1,2)	   :  ss(2,2) || 1<2 && ss(2)	 ->  ss(2,2) || ss(2)
--  
--  I fail to see how it will ever end. What turn did I miss?


The smiley in my original post.


Abigail
-- 
   my $qr =  qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
      $qr =~  s/$qr//g;
print $qr, "\n";


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

Date: 26 Apr 2001 21:42:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: match a range of number
Message-Id: <9ca4o4$lmh$1@mamenchi.zrz.TU-Berlin.DE>

According to Craig Berry <cberry@cinenet.net>:
> Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote:
> : According to Craig Berry <cberry@cinenet.net>:
> [snip]
> : >     @_ < 2 || (shift() < $_[0] && &strictly_sorted);
> [snip]
> : > One question about order of evaluation:  Is the shift() on the lhs of <
> : > guaranteed to be evaluated before the $_[0] on the rhs, and if so, why?
> : > (It was doubt about this that kept me away from this solution earlier in
> : > the discussion.)
> : 
> : Rightly so.  The evaluation order of parts of expressions is unspecified.
> : While I can't point to a part of the documentation that explicitly
> : says so, the only operator (I know of) that *does* specify an evaluation
> : order is the comma operator (left first).  
> 
> Another example:  short-circuit evaluation of logic operators (|| && or
> and) requires left-first evaluation, given that evaluation of the rhs may
> not even occur. 

Oh yes, thanks for that.  Then there's and "=", but here it's right
side first.  Are there more?  A cursory search of perlop for
"left operand", "right operand" and "first" turns up no others, but
it doesn't turn up "=" either.
 
> : That said, I believe the code above would run on every Perl interpreter[1]
> : in the world.
> 
> I'm always nervous about relying on undocumented behavior.  It has bit me
> hard a few times.

Sorry, I didn't intend to endorse the code.  I wanted to go on: "But it's
still in error", but slipped.

Anno


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

Date: 26 Apr 2001 21:22:42 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Needing Help!
Message-Id: <86u23b1hlp.fsf@jon_ericson.jpl.nasa.gov>

"MJ" <lowendz@home.com> writes:

> I was wondering if any one of you can give me some sort of advice of
> creating a skeleton of a program.  I've never programmed in Perl before and
> haven't been back to programming for the last 5 years!  So I was wondering
> how to set up a program that will extract info out of two SQL tables (the
> name from one and a date from the other) and also info from an Access table
> (the address) and query it so that it takes the matching selected info and
> spits it out to a document (say something like a notepad base).

Most likely you're going to want to use the DBI (search.cpan.org for
more information).

> Then to get a bit more complicated, have it also set up to send out the
> collected info out to selected people through an exchange server...

Is that some sort of email server?  In any case, CPAN probably has a
module to help you do this.

Jon


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.

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 V10 Issue 774
**************************************


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