[9217] in Perl-Users-Digest
Perl-Users Digest, Issue: 2812 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 8 14:07:54 1998
Date: Mon, 8 Jun 98 11:00:41 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 8 Jun 1998 Volume: 8 Number: 2812
Today's topics:
(1 and '') vs. (1 && '') (Todd Lehman)
Re: (1 and '') vs. (1 && '') (Huu Da Tran)
accessing a:\ <kthor@idt.net>
Re: accessing a:\ <bowlin@sirius.com>
Re: AOL AIM & perl fgump@my-dejanews.com
Re: Compiling perl5.004_04 for BSDI 3.1 ellis@valueweb.net
Re: Date fomatting. <jdporter@min.net>
Re: Day of Week Display for User-defined date (Abigail)
Re: Delete all files in a directory <perlguy@inlink.com>
Re: Disabling garbage collection (Andrew Arensburger)
Field order from a Web Server <r.d.smith@man0501.wins.icl.co.uk>
Re: Foreach Efficiency <jdporter@min.net>
Re: I'm having problems: (Tom Grydeland)
if/then in perl/cgi scripts (Jamie)
Re: if/then in perl/cgi scripts (Huu Da Tran)
Re: Invoking perl debugger <rootbeer@teleport.com>
McCabe complexity analysis <tchrist@mox.perl.com>
Re: offline mode? <jdporter@min.net>
Re: Oracle connectivity <perlguy@inlink.com>
Re: Perl module for doing a unix 'which'? (Stuart McDow)
Preventing file conflicts <jgoldberg@dial-but-dont-spam.pipex.com>
problem setting textarea and text elements (Vjekoslav Balas)
Re: problem setting textarea and text elements <tchrist@mox.perl.com>
Re: regexp: Validating UPC Code ionFreeman@my-dejanews.com
Re: regexp: Validating UPC Codes ionFreeman@my-dejanews.com
Skipping iterations in while <olm@mail1.csun.edu>
Re: Why is there no "in" operator in Perl? (Snowhare)
Re: Why is there no "in" operator in Perl? (Abigail)
y2k Database prelaunch...please help. bubbha@my-dejanews.com
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 08 Jun 1998 17:30:27 GMT
From: lehman@visi.com (Todd Lehman)
Subject: (1 and '') vs. (1 && '')
Message-Id: <TcVe1.282$bj2.1592639@ptah.visi.com>
Am I high, or should (1 and '') evaluate to ''?
I've been using '&&' and 'and' interchangably for a long time, except for
cosmetic/readability differentiations, until today when I hit something
very unexpected. Here's a short program to demonstreate what I don't get:
----begin freakmeout.pl----
use strict;
$^W = 1;
my $x = 1 and '';
my $y = 1 && '';
print "x = ", $x? 'true':'false', "\n";
print "y = ", $y? 'true':'false', "\n";
----end freakmeout.pl----
Blue Camel page 94 says: "As more readable alternatives to &&, ||, and
!, Perl provides the and, or and not operators. The behavior of these
operators is identical--in particular, they short-circuit the same way."
I ran the above program under 5.003_00, 5.004_00, 5.004_01, and 5.004_02.
Same result. Why is $x equal to 1? What am I not getting?
--Todd
------------------------------
Date: Mon, 08 Jun 1998 17:47:14 GMT
From: tranhu@jsp.umontreal.ca (Huu Da Tran)
Subject: Re: (1 and '') vs. (1 && '')
Message-Id: <slrn6no8t4.2mb.tranhu@derby.jsp.umontreal.ca>
Un jour, Todd Lehman (lehman@visi.com)
affirmait publiquement que:
| I ran the above program under 5.003_00, 5.004_00, 5.004_01, and
| 5.004_02. Same result. Why is $x equal to 1? What am I not getting?
"man perlop"
my $x = 1 and '';
equals to
my($x = 1) and '';
the '=' operator has more precedence than the 'and' operator.
HTH...
--
__________________________________________________________________________
TRAN, Huu Da B.Sc.Info UdeM: tranhu@jsp.umontreal.ca
RISQ inc RISQ: HuuDa.Tran@risq.qc.ca
Iquipe riseau http://pages.risq.qc.ca/htran
------------------------------
Date: Mon, 08 Jun 1998 11:57:45 -0400
From: Kevin Thorley <kthor@idt.net>
Subject: accessing a:\
Message-Id: <357C09F9.185D@idt.net>
I'm writing a script to access the a: drive and return a list of its
contents. But I keep getting "Bad command or file name." Here's the
code
chdir( "a:" );
while( <"*.*"> ){
print "$_\n" ;
}
It works fine if I use any directory on the c: drive. It seems to be
going to the a: drive that is causing problems.
Kevin Thorley
kthorley@mpgnews.com
------------------------------
Date: Mon, 08 Jun 1998 09:20:03 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: kthor@idt.net
Subject: Re: accessing a:\
Message-Id: <357C0F33.B62A705E@sirius.com>
Kevin Thorley wrote:
>
> I'm writing a script to access the a: drive and return a list of its
> contents. But I keep getting "Bad command or file name." Here's the
> code
>
> chdir( "a:" );
> while( <"*.*"> ){
> print "$_\n" ;
> }
>
> It works fine if I use any directory on the c: drive. It seems to be
> going to the a: drive that is causing problems.
>
> Kevin Thorley
> kthorley@mpgnews.com
Your code worked fine on my system. I am running Perl 5.004_02 on an NT.
You may want to specify a directory on the A: drive. I suggest something
like
chdir("a:/");
otherwise the system will default to the last subdirectory that was the
CWD on the A drive which might not exist now.
-- Jim Bowlin
------------------------------
Date: Mon, 08 Jun 1998 16:29:16 GMT
From: fgump@my-dejanews.com
Subject: Re: AOL AIM & perl
Message-Id: <6lh3gs$8on$1@nnrp1.dejanews.com>
I've been trying to find out for ages how to snoop someone's IP address
through AIM. I know that has nothing to do with what you're asking, but I
found out something...that when you send and receive AIM messages, you are
sending it to a server (login.oscar.aol.com port 5190), which then relays the
message, so only the server knows the IP's of the two participants. If I am
wrong, please correct me because I'd be happy to know there's a way around
it.
But in terms of a client emulator like your Perl Script, you need to work
with Screen Names instead of IP addresses. Since when each user signs in,
his/her IP address is bound to the screen name on the server, the screen name
acts as the alias to the IP address. Any IP address will definitely be
interpreted as a screen name by the AIM server.
So to put it simply, you CAN write a Perl client emulator for Instant
Messenging, but you can't reach anyone without their screen name.
Bret
email : fgump @
mindless.com
In article <356F84D4.625B@noemail.com>,
noemail@noemail.com wrote:
>
> I am looking to send a message to an AOL Instant Messager user from a
> perl script. ie., the perl script initiates the message to the AOL
> Instant Messanger user. I already know what IP address the AIM user is
> at - I just need help in finding out how AIM communicates over the
> socket connection. If anyone can help me, I'd be most grateful.
> Jean-Yves Sireau
> Email : jys @
> hk.super.net
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 8 Jun 1998 16:33:56 GMT
From: ellis@valueweb.net
Subject: Re: Compiling perl5.004_04 for BSDI 3.1
Message-Id: <6lh3pk$1mds$1@news.gate.net>
Cliff Friedel <cfriedel@godzilla.penn.com> wrote:
> While compiling Perl 5.004_04 for BSDI, I ran across the following error
> when it tries to compile doio.c:
> doio.c: In Function Perl_do_ipcctl:
> doio.c:1381: argument #4: incompatible types in argument passing
> doio.c:1432: argument #4: incompatible types in argument passing
> Has anyone seen this error? I have tried changing multiple settings in
> the configure script and Makefile, but to no avail. If somebody could
> please help me with this, it would be greatly appreciated. Thanks.
> Cliff Friedel
> System Administrator
> Penncom Internet Company
> sysadmin@penn.com
diff -c perl5.004_04.orig/perlsdio.h perl5.004_04/perlsdio.h
*** perl5.004_04.orig/perlsdio.h Mon Apr 28 14:05:23 1997
--- perl5.004_04/perlsdio.h Sun Dec 28 18:10:24 1997
***************
*** 80,129 ****
/* Now our interface to Configure's FILE_xxx macros */
#ifdef USE_STDIO_PTR
! #define PerlIO_has_cntptr(f) 1
! #define PerlIO_get_ptr(f) FILE_ptr(f)
! #define PerlIO_get_cnt(f) FILE_cnt(f)
#ifdef STDIO_CNT_LVALUE
! #define PerlIO_canset_cnt(f) 1
#ifdef STDIO_PTR_LVALUE
! #define PerlIO_fast_gets(f) 1
#endif
! #define PerlIO_set_cnt(f,c) (FILE_cnt(f) = (c))
#else
! #define PerlIO_canset_cnt(f) 0
! #define PerlIO_set_cnt(f,c) abort()
#endif
#ifdef STDIO_PTR_LVALUE
! #define PerlIO_set_ptrcnt(f,p,c) (FILE_ptr(f) = (p), PerlIO_set_cnt(f,c))
#else
! #define PerlIO_set_ptrcnt(f,p,c) abort()
#endif
#else /* USE_STDIO_PTR */
#define PerlIO_has_cntptr(f) 0
#define PerlIO_canset_cnt(f) 0
! #define PerlIO_get_cnt(f) (abort(),0)
! #define PerlIO_get_ptr(f) (abort(),(void *)0)
! #define PerlIO_set_cnt(f,c) abort()
! #define PerlIO_set_ptrcnt(f,p,c) abort()
#endif /* USE_STDIO_PTR */
#ifndef PerlIO_fast_gets
! #define PerlIO_fast_gets(f) 0
#endif
#ifdef FILE_base
! #define PerlIO_has_base(f) 1
! #define PerlIO_get_base(f) FILE_base(f)
! #define PerlIO_get_bufsiz(f) FILE_bufsiz(f)
#else
#define PerlIO_has_base(f) 0
! #define PerlIO_get_base(f) (abort(),(void *)0)
! #define PerlIO_get_bufsiz(f) (abort(),0)
#endif
#else /* PERLIO_IS_STDIO */
#ifdef PERL_CORE
--- 80,132 ----
/* Now our interface to Configure's FILE_xxx macros */
#ifdef USE_STDIO_PTR
! #define PerlIO_has_cntptr(f) 1
! #define PerlIO_get_ptr(f) FILE_ptr(f)
! #define PerlIO_get_cnt(f) FILE_cnt(f)
#ifdef STDIO_CNT_LVALUE
! #define PerlIO_canset_cnt(f) 1
#ifdef STDIO_PTR_LVALUE
! #define PerlIO_fast_gets(f) 1
#endif
! #define PerlIO_set_cnt(f,c) (FILE_cnt(f) = (c))
#else
! #define PerlIO_canset_cnt(f) 0
! #define PerlIO_set_cnt(f,c) (abort(), 0)
#endif
#ifdef STDIO_PTR_LVALUE
! #define PerlIO_set_ptrcnt(f,p,c) (FILE_ptr(f) = (p), PerlIO_set_cnt(f,c))
#else
! #define PerlIO_set_ptrcnt(f,p,c) (abort(), 0)
#endif
#else /* USE_STDIO_PTR */
#define PerlIO_has_cntptr(f) 0
#define PerlIO_canset_cnt(f) 0
! #define PerlIO_get_cnt(f) (abort(), 0)
! #define PerlIO_get_ptr(f) (abort(), 0)
! #define PerlIO_set_cnt(f,c) (abort(), 0)
! #define PerlIO_set_ptrcnt(f,p,c) (abort(), 0)
#endif /* USE_STDIO_PTR */
#ifndef PerlIO_fast_gets
! #define PerlIO_fast_gets(f) 0
#endif
#ifdef FILE_base
! #define PerlIO_has_base(f) 1
! #define PerlIO_get_base(f) FILE_base(f)
! #define PerlIO_get_bufsiz(f) FILE_bufsiz(f)
#else
#define PerlIO_has_base(f) 0
! #define PerlIO_get_base(f) (abort(), 0)
! #define PerlIO_get_bufsiz(f) (abort(), 0)
#endif
#else /* PERLIO_IS_STDIO */
#ifdef PERL_CORE
*** perl5.004_04.orig/pp_hot.c Wed Oct 8 10:51:20 1997
--- perl5.004_04/pp_hot.c Sun Dec 28 16:17:57 1997
***************
*** 648,655 ****
}
# endif /* HAS_SETEUID */
if (delaymagic & DM_UID) {
! if (uid != euid)
! DIE("No setreuid available");
(void)setuid(uid);
}
# endif /* HAS_SETREUID */
--- 648,655 ----
}
# endif /* HAS_SETEUID */
if (delaymagic & DM_UID) {
! if (uid != euid && euid != 0)
! DIE("Failed setting real user id");
(void)setuid(uid);
}
# endif /* HAS_SETREUID */
***************
*** 677,684 ****
}
# endif /* HAS_SETEGID */
if (delaymagic & DM_GID) {
! if (gid != egid)
! DIE("No setregid available");
(void)setgid(gid);
}
# endif /* HAS_SETREGID */
--- 677,684 ----
}
# endif /* HAS_SETEGID */
if (delaymagic & DM_GID) {
! if (gid != egid && euid != 0)
! DIE("Failed setting real group id");
(void)setgid(gid);
}
# endif /* HAS_SETREGID */
*** perl5.004_04.orig/hints/bsdos.sh Wed Sep 10 09:34:42 1997
--- perl5.004_04/hints/bsdos.sh Mon Jan 19 16:39:16 1998
***************
*** 40,45 ****
--- 40,47 ----
'') optimize='-O2' ;;
esac
+ d_dosuid='define'
+
case "$bsdos_distribution" in
''|undef|false) ;;
*)
***************
*** 69,75 ****
'') cc='gcc2' ;;
esac
;;
! 2.0*|2.1*|3.0*)
so='o'
# default to GCC 2.X w/shared libraries
--- 71,77 ----
'') cc='gcc2' ;;
esac
;;
! 2.0*|2.1*|3.0*|3.1*)
so='o'
# default to GCC 2.X w/shared libraries
***************
*** 88,94 ****
libswanted="Xpm Xaw Xmu Xt SM ICE Xext X11 $libswanted"
libswanted="rpc curses termcap $libswanted"
;;
! 3.1*)
# ELF dynamic link libraries starting in 3.1
useshrplib='true'
so='so'
--- 90,96 ----
libswanted="Xpm Xaw Xmu Xt SM ICE Xext X11 $libswanted"
libswanted="rpc curses termcap $libswanted"
;;
! 3.2*)
# ELF dynamic link libraries starting in 3.1
useshrplib='true'
so='so'
------------------------------
Date: Mon, 08 Jun 1998 17:02:09 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Date fomatting.
Message-Id: <357C1A9D.65CC@min.net>
You know, just because printf came from C, doesn't mean you shouldn't
use it when appropriate.
@mytime = localtime();
my $filename = sprintf("%02d%02d%02d", $mytime[5], $mytime[4]+1,
$mytime[3] );
hth,
John Porter
------------------------------
Date: 8 Jun 1998 17:52:49 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Day of Week Display for User-defined date
Message-Id: <6lh8dh$9ga$2@client3.news.psi.net>
KC Lucchese (kcl@mindspring.com) wrote on MDCCXLII September MCMXCIII in
<URL: news:357BF02D.977101F2@mindspring.com>:
++ Please pardon a question that might have been asked a thousand times
No. Asking such questions is unforgivable; not just about Perl, but
in any newsgroup. That's what FAQs are for. Read it.
++ before! I know just enough PERL to be dangerous and to support someone
++ else's scripts (which is what I'm doing)...
That is no excuse for not reading the FAQ.
++ I need to display the day of the week (Sunday, Monday, etc.) for a date
++ which the user chooses from a drop-down list.
What have drop-down lists to do with Perl?
++ Is there a way to do this????
Read the FAQ.
Abigail
--
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
${qq$\x5F$} = q 97265646f9 and s g..g;
qq e\x63\x68\x72\x20\x30\x78$&eggee;
{eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'
------------------------------
Date: Mon, 8 Jun 1998 16:00:13 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Delete all files in a directory
Message-Id: <357C0A8D.40362606@inlink.com>
`del *.*`;
`rm *`;
$command="rm *";
system($command);
$dir="/usr/test/dir/.";
unlink($dir); #???
What have you tried??? Most, or all, of these should work. There are
many others too!
Give us some examples of what you have tried, then we have more of a
clue how to help you.
HTH,
Brent
------------------------------
Date: 8 Jun 1998 16:48:45 GMT
From: arensb@umiacs.umd.edu (Andrew Arensburger)
Subject: Re: Disabling garbage collection
Message-Id: <6lh4ld$elf$1@walter.cs.umd.edu>
[Is it bad form to follow up on one's own posting?]
Andrew Arensburger (arensb@umiacs.umd.edu) wrote:
> The problem I'm running into is that these objects are being
> destructed twice: once by $MyClass::DESTROY when the Perl interpreter
> exits, and once by MyClass::~MyClass after main() exits:
In case anyone cares: I tried adding magic to the imported
variables, but apparently Perl strips magic from variables before
destructing them, so that didn't work.
Eventually, I wound up creating MyClass::Imported (which ISA
MyClass), and defining a separate DESTROY method for it.
--
Andrew Arensburger, Systems guy Center for Automation Research
arensb@cfar.umd.edu University of Maryland
Throw another Ken on the Barbie.
------------------------------
Date: Mon, 8 Jun 1998 17:09:33 +0100
From: "Robin Smith" <r.d.smith@man0501.wins.icl.co.uk>
Subject: Field order from a Web Server
Message-Id: <357c0c78.0@145.227.194.253>
Does anyone know if it is possible to control/re-arrange the order that
fields are passed to a perl script. I have a questionaire that has fields
Q1.1, Q1.2, Q1.3, Q2.1, Q2.2, Q2.3 ...etc
The perl script just writes them to a file, and they come out in the order
Q1.1, Q1.2, Q2.1, Q1.3, Q2.2, Q3.1, Q1.4 ...etc
I need them to be in the correct order that they appear in on the form.
Why are they being changed??
I am Running Windows NT4 SP3, IIS4, and Perl 5.001m Build 105.
I am somewhat new to perl, so apologies if this is simple. Any help greatly
appreciated.
Some code snippets of what I am doing are as follows:
#Get the data into variables
$data = &getInput();
$originaldata=$data;
%data = &getData($data);
#Output each field to a file.
foreach $key (keys %data)
{
print FBFILE "$key:\n",&Fold($data{$key}),"\n\n"
unless $key =~ /ack|reject|fbdir|submit/i;
}
close FBFILE;
# end - subroutines below
# **********************************************************************
# getInput
# **********************************************************************
sub getInput {
local($data);
if ($ENV{"REQUEST_METHOD"} =~ /GET/i) {
$data = $ENV{"QUERY_STRING"};
}
else {
read(STDIN, $data, $ENV{"CONTENT_LENGTH"});
}
return $data;
}
# **********************************************************************
# getData
# **********************************************************************
sub getData {
local($data) = @_;
local(%input);
if ($data) {
$data = "$data&";
while ($data =~ s/(\S+?)=(\S*?)&//)
#if($debug) { print "<BR>assoc array - ".$1." : ".$2; }
$input{$1} = decode($2);
}
}
return %input;
}
# **********************************************************************
# decode
# **********************************************************************
sub decode
{
local($text) = @_;
local($char);
$text =~ s/\+/ /g;
while ($text =~ /%(\w\w)/) {
$char = sprintf("%c", hex($1));
$text =~ s/%$1/$char/g;
}
return $text;
}
------------------------------
Date: Mon, 08 Jun 1998 16:57:27 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Foreach Efficiency
Message-Id: <357C1982.1371@min.net>
samdie@wsfd.org wrote:
>...
> The question was not "How are (most) parenthesized expressions (lists, in
> particular) evaluated?" but , rather, "*When* are induction variables
> evaluated?" Programming languages differ on this point and those lacking a
> formal definition of their semantics (e.g. Perl) are often unclear about
> what approach they take.
>[major pseudo-literate bombast snipped]
BFD about "formal definition of the semantics".
The semantics of the construct in question are precisely and clearly
defined, and that's what matters.
John Porter
------------------------------
Date: 8 Jun 1998 15:47:39 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: I'm having problems:
Message-Id: <slrn6no1sr.7e2.Tom.Grydeland@mitra.phys.uit.no>
On 8 Jun 1998 13:57:45 GMT,
Tom Grydeland <Tom.Grydeland@phys.uit.no> wrote:
> Except find2perl doesn't use [File::Find]. (as of 5.004_04)
This turned out to be wrong. The output of "find2perl -name foo -print"
is
#!/usr/bin/perl
eval 'exec /store/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
require "find.pl";
# Traverse desired filesystems
&find('.');
exit;
sub wanted {
/^foo$/ &&
print("$name\n");
}
And on the strength of this, I made the above claim. However, find.pl
is just a thin wrapper over File::Find. The first line of code is
use File::Find ();
Ah well. If I'd only used POD markup, my statement would've been
"Except find2perl doesn't C<use File::Find;>"
and it would've been correct anyway.
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
- Do radioactive cats have 18 half-lives? -
------------------------------
Date: Mon, 08 Jun 1998 12:41:34 -0400
From: "James A. (Jamie) Dennis" <jdennis@netset.com>
Subject: if/then in perl/cgi scripts
Message-Id: <357C143E.1D7B036C@netset.com>
Hello
I am somewhat a novice in perl, although I have used it extensively over
the past year, and am becoming good at it, but I am having one BIG
nagging problem.
I need to check for the existence of a string from an HTML form, and if
it exists, have perl output a different string.
My form has an item called maidenname, if data exists, print out a line
with Maiden name, First name, Middle name. If it doesn't exist, print
out last name, first name, middle name.
Here is the syntax of my perl statements:
#Update 3/28/98 - added maidenname condition
if ( -r $FORM{'maidenname'} ){
print DATABASE "<h3><FONT COLOR=BLUE><A
NAME=$FORM{'maidenname'}>$FORM{'firstname'} $FORM{'middlename'}
$FORM{'lastname'}</font></h3>";
}
else {
print DATABASE "<h3><FONT COLOR=BLUE><A
NAME=$FORM{'lastname'}>$FORM{'firstname'} $FORM{'middlename'}
$FORM{'lastname'}</font></h3>";
}
BTW, I have tried this without the -r, and with other flags, to no avail
thus far.
Any and all help appreciated.
Jamie Dennis
The Unofficial CHS Alumni Home Page
http://www.netset.com/~jdennis
------------------------------
Date: Mon, 08 Jun 1998 17:51:29 GMT
From: tranhu@jsp.umontreal.ca (Huu Da Tran)
Subject: Re: if/then in perl/cgi scripts
Message-Id: <slrn6no953.2mb.tranhu@derby.jsp.umontreal.ca>
Un jour, James A. (Jamie) Dennis (jdennis@netset.com)
affirmait publiquement que:
| I need to check for the existence of a string from an HTML form, and if
| it exists, have perl output a different string.
^^^^^^^^^
if ( (exists $FORM{'maidenname'}) && ($FORM{'maidenname'} ne '') ) {
...
}
I like to double-check...
HTH...
--
__________________________________________________________________________
TRAN, Huu Da B.Sc.Info UdeM: tranhu@jsp.umontreal.ca
RISQ inc RISQ: HuuDa.Tran@risq.qc.ca
Iquipe riseau http://pages.risq.qc.ca/htran
------------------------------
Date: Mon, 08 Jun 1998 16:08:57 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Invoking perl debugger
Message-Id: <Pine.GSO.3.96.980608085933.29617t-100000@user2.teleport.com>
On Fri, 5 Jun 1998 dthanair@my-dejanews.com wrote:
> I have been trying to use the perl debugger by executing the
> interpreter in a different directory than where the perl.exe is, but it
> doesn't seem to work.
The -d option effectively puts something like this at the start of your
code.
BEGIN { require 'perl5db.pl' }
If that library isn't found in @INC, that's the end of that run. But you
can override this behavior by setting the PERL5DB environment variable.
Set that variable to contain the replacement BEGIN block that you need,
including any 'use libs' and such, and you should be fine. See the
perldebug and perlrun manpages for more info. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 8 Jun 1998 15:55:35 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: McCabe complexity analysis
Message-Id: <6lh1hn$3t3$2@csnews.cs.colorado.edu>
Why do people write code that's hard to grok with too many conditionals
and branches within loops? Is it because they're Prisoners of Pascal?
We end up getting really wicked code like this:
while (C1) {
if (C2) {
sadf;
zxcv;
qwerty;
poiuy;
if (C3) {
fee;
fie;
foe;
fum;
}
} else {
glargh;
}
}
When they should in fact write:
while (C1) {
unless (C2) {
glargh;
next;
}
sadf;
zxcv;
qwerty;
poiuy;
next unless C3;
fee;
fie;
foe;
}
Or even:
while (C1) {
glargh, next unless C2;
sadf;
zxcv;
qwerty;
poiuy;
next unless C3;
fee;
fie;
foe;
}
See how much simpler it should be?
--tom
--
"Bjarne Strousup was sharing a cubicle with me at the time he was creating
C++. That's part of the reason why I don't use it." --Rob Pike
------------------------------
Date: Mon, 08 Jun 1998 17:20:58 GMT
From: John Porter <jdporter@min.net>
Subject: Re: offline mode?
Message-Id: <357C1F05.1F32@min.net>
Bill 'Sneex' Jones wrote:
>
> I'm just leaning C and TCP and ... is there a way to read a file
> backwards?
> Oh and create a file (sort of a log) like using a here document???
What, no hit counter?
John Porter
------------------------------
Date: Mon, 8 Jun 1998 16:14:35 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Oracle connectivity
Message-Id: <357C0DEB.3E289612@inlink.com>
Try going to www.perl.com and click on "database" under the Perl
Reference header.
HTH,
Brent
------------------------------
Date: 8 Jun 1998 16:19:56 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Perl module for doing a unix 'which'?
Message-Id: <6lh2vc$9uv$1@ns1.arlut.utexas.edu>
Tom Christiansen <tchrist@mox.perl.com> writes:
>
> Your sh version is slower than my perl version.
Hmmm....
bash% time /bin/wh wh
/home/smcdow/Commonality/bin/wh
/bin/wh
/usr/bin/wh
real 0m0.076s
user 0m0.000s
sys 0m0.010s
bash% time ~/tmp/wh.tc wh
/home/smcdow/Commonality/bin/wh
/bin/wh
/usr/bin/wh
real 0m0.064s
user 0m0.010s
sys 0m0.010s
You're right. My perl version is nearly identical to yours. I did my
comparision about three years ago, and if my dim memory is correct,
the sh version was the better one. I wonder what I was doing wrong.
FWIW, I install the sh version on new machines, 'cause not all my
machines get perl. At least not initially.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"Look for beauty in roughness, unpolishedness"
------------------------------
Date: Mon, 8 Jun 1998 18:30:47 +0100
From: "Jeremy Goldberg" <jgoldberg@dial-but-dont-spam.pipex.com>
Subject: Preventing file conflicts
Message-Id: <6lh764$gdt$1@flex.london.pipex.net>
I asked about this a while back and got nothing save flames, but I'll try
again, since I still don't have an answer. How do you _reliably_ open a file
AFTER another file has finished writing to it? I don't mean in the middle
(or even before), but AFTER. e.g.
open( HANDLE, ">test.dat" ) || die $!;
while( <time-consuming-expression> )
{
print HANDLE <data>;
}
and at the same time in another process:
open( HANDLE, "test.dat" ) || die $!;
...
What happens here is (as far as I can tell), the 2nd open works and just
tries reading out anyway, but it is unclear exactly what it's reading -
before the 1st-file-write began, during the 1st-file-write (but before the
file cache is flushed), or... what? Also, if the 2nd file is opened for
writing - it can do that too... so what actually gets written, if not a
mishmash?
To anyone who can help:
1) Don't say to use flock() / fnctl() - I need a platform-independant system
2) Don't say RTFM - I already have, and found nothing.
3) Don't tell me to use a module... unless you know the module to use (in
which case I WILL be grateful).
- Jeremy Goldberg
------------------------------
Date: 8 Jun 1998 16:39:00 GMT
From: eedvab@eed.ericsson.se (Vjekoslav Balas)
Subject: problem setting textarea and text elements
Message-Id: <6lh434$dvl7@aken.eed.ericsson.se>
Hi,
I'd much appreciate if someone has some idea on how I can solve my problem:
Problem: - I use a html form (a) (text and textarea elements) to read
some values/variables which are saved and later re-read
either into a form (b) which just shows the values or
into a form (c) which has text/textarea input fields so
that the initial values/variables can be modified.
Showing the values in form (b), everything is OK.
When showing the form (c), there are some problems
eg value/variable is not shown at all or part of it
is shown.
I think the problem may have something to do with
line feeds / wrapping of lines when placing a value/variable
in a textarea / text.
BR,Vjeko
eedvab@eed.ericsson.se
------------------------------
Date: 8 Jun 1998 17:43:03 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: problem setting textarea and text elements
Message-Id: <6lh7r7$efo$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
eedvab@eed.ericsson.se writes:
:Problem: - I use a html form (a) (text and textarea elements) to read
: some values/variables which are saved and later re-read
: either into a form (b) which just shows the values or
: into a form (c) which has text/textarea input fields so
: that the initial values/variables can be modified.
I'm sure there must be Perl content here somewhere, but I
can't find it. Apparently you've confused this newsgroup
with the cgi group. Try looking there intead.
--tom
--
if (rsfp = mypopen("/bin/mail root","w")) { /* heh, heh */
--Larry Wall in perl.c from the perl source code
------------------------------
Date: Mon, 08 Jun 1998 17:28:19 GMT
From: ionFreeman@my-dejanews.com
Subject: Re: regexp: Validating UPC Code
Message-Id: <6lh6vi$drm$1@nnrp1.dejanews.com>
Ilya,
Thanks for your help. I guess ugly's bad, so I'll postpone my search for
the single UPC-validating regexp.
ion
In article <6l7h4a$ih1$1@mathserv.mps.ohio-state.edu>,
ilya@math.ohio-state.edu (Ilya Zakharevich) wrote:
>
> > On Thu, 4 Jun 1998 ionFreeman@my-dejanews.com wrote:
> >
> > > /[067]\d{11}/
> >
> > > matches a UPC code. However, that 12th digit has to equal ten less the
> > > ten- based modulus of thrice the sum of the odd digits plus the sum of
> > > the previous even digits. Is there a way I can do this with
> > > backreferences inside a regular expression?
>
> They can with recent enough Perl (5.004_55+). But this is still very
> ugly
> Ilya
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 08 Jun 1998 17:16:23 GMT
From: ionFreeman@my-dejanews.com
Subject: Re: regexp: Validating UPC Codes
Message-Id: <6lh697$cs9$1@nnrp1.dejanews.com>
Hey, I like that (10 - $Check)%10 way better than chop(10 - %Check%10).
Thanks!
ion
In article <35780EC2.513@min.net>,
jdporter@min.net wrote:
>
> Here's another way, using eval:
>
> $UPC = "063255878220"; # this is a known valid UPC code
>
> {
> $UPC =~ /^[067]\d{11}$/
> or die "$UPC is not a 12-digit string starting with 0, 6, or 7";
> my $upc = $UPC;
> my $Check;
> my $check_digit = chop $upc;
> for ( reverse 1..10 ) { substr( $upc, $_, 0 ) = '+'; }
> for ( reverse 0..5 ) { substr( $upc, 4*$_, 0 ) = '3*'; }
> eval '$Check='.$upc;
> (10 - $Check) % 10 == $check_digit or die "$UPC is not valid!\n";
> }
>
> warn "$UPC is valid!\n";
>
> hth,
> John Porter
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 08 Jun 1998 09:29:07 -0700
From: Ovanes Manucharyan <olm@mail1.csun.edu>
Subject: Skipping iterations in while
Message-Id: <357C1153.750F836F@mail1.csun.edu>
How can I skip the very first, (or for that matter "any") iteration of a
while loop.
I am reading in the output of a unix command, the first line of which I
don't need, and I need to
ignore somehow. Is there a control statement in perl that would skip a
particular iteration in the w
while loop.
Thanks in advance for your help.
Sincerely,
ovanes m.
--
------------------------------
Date: 8 Jun 1998 10:35:25 -0600
From: snowhare@xmission.xmission.com (Snowhare)
Subject: Re: Why is there no "in" operator in Perl?
Message-Id: <6lh3sd$6d4$1@xmission.xmission.com>
Nothing above this line is part of the signed message.
In article <6lgsuk$5k7$1@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>Snowhare (snowhare@xmission.xmission.com) wrote on MDCCXL September
>MCMXCIII in <URL: news:6lbv58$t5r$1@xmission.xmission.com>:
>++ In article <6l926h$7of$2@client3.news.psi.net>,
>++ Abigail <abigail@fnx.com> wrote:
>++ >Even if you have huge arrays, if you're searching only once, there's
>++ >no point in hashing, as building the hash table is linear too.
>++
>++ But searching it is not. It depends on the relative constants for building
>++ the array *AND* linearly searching it vs. building the hash and finding an
>++ entry.
>++
>++ The question is which is larger:
>++
>++ K O(N) + S O(N) (for building and searching an array)
>
>Building? What's the build when the array is given?
Naughty naughty. If you get to assume that your array is 'given' then I
get to assume my hash is 'given' as well. Then the comparision becomes
S O(N) vs T and the hash wins _all_ the time for large enough N. Data
structures do not come from nowhere.
>++ vs
>++
>++ M O(N) + T (for building and finding an entry in a hash).
>++
>++ if (M < (K + S)) then, for large enough N, it will be faster to build the
>++ hash _even for only one search_.
>
>Yeah, but if it turns out 'eq' is slower than hashing the elements,
>something would be very wrong.
Hard to say. Bit operation level implementations of hashing functions can
be VERY efficient: x33 is nothing more than a shift left 5 and an
addition. Depending on the machine architecture that might be only two
highly efficient machine instructions per character vs one (compare and
branch) for the 'eq' for every char in the array to be searched. And the
array lookups involves a general multiplication - which is always a good
place to look for a performance hit. And for long highly similar strings
the loop required to compare each character could weight down the equality
comparision quite a lot.
My _instinct_ says that _most_ of the time, for a single search, with
perfectly optimized array search and hash functions and short variable
strings, the array search will win for a single search. But I wouldn't bet
money on it without a formal analysis and certainly not on the vagaries of
real life where a less than optimal array implementation might lose _all_
the time to a more optimal hash implemention or where the difference might
be completely swamped by _other_ effects like I/O performance while
reading a datafile (in an efficient design where I/O is performed
asynchronously to the list building, the limiting factor would be I/O
throughput - the CPU bound portion of the task would be completely
swallowed by it) or degenerate cases like lists of identically sized
200000 character strings differing only in their final 10 positions.
Benjamin Franz
Version: 2.6.2
iQCVAwUBNXwSr+jpikN3V52xAQHduQP8C7MrS0rTPK52qCzD/7l6Pm4M6x5gEApB
V7Pyqkxhm2B/0VPxFPIc8tgGZH7cD7Dvl/lF0OeBegT4PzejLcm7miEEqOBCh4A9
IK9KgBbYiL6BtaXma3zaXRzd+TGrmnYyWAtqWCagFD6xxBhqzPKszFbS9+vBvba9
ahNPADvXMNI=
=1U2L
-----END PGP SIGNATURE-----
------------------------------
Date: 8 Jun 1998 17:50:36 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Why is there no "in" operator in Perl?
Message-Id: <6lh89c$9ga$1@client3.news.psi.net>
Snowhare (snowhare@xmission.xmission.com) wrote on MDCCXLII September
MCMXCIII in <URL: news:6lh3sd$6d4$1@xmission.xmission.com>:
++
++
++ Nothing above this line is part of the signed message.
++
++ In article <6lgsuk$5k7$1@client3.news.psi.net>,
++ Abigail <abigail@fnx.com> wrote:
++ >Snowhare (snowhare@xmission.xmission.com) wrote on MDCCXL September
++ >MCMXCIII in <URL: news:6lbv58$t5r$1@xmission.xmission.com>:
++ >++ In article <6l926h$7of$2@client3.news.psi.net>,
++ >++ Abigail <abigail@fnx.com> wrote:
++ >++ >Even if you have huge arrays, if you're searching only once, there's
++ >++ >no point in hashing, as building the hash table is linear too.
++ >++
++ >++ But searching it is not. It depends on the relative constants for building
++ >++ the array *AND* linearly searching it vs. building the hash and finding an
++ >++ entry.
++ >++
++ >++ The question is which is larger:
++ >++
++ >++ K O(N) + S O(N) (for building and searching an array)
++ >
++ >Building? What's the build when the array is given?
++
++ Naughty naughty. If you get to assume that your array is 'given' then I
++ get to assume my hash is 'given' as well. Then the comparision becomes
++ S O(N) vs T and the hash wins _all_ the time for large enough N. Data
++ structures do not come from nowhere.
This thread started with the question:
Am I missing something or does Perl lack the ability to check if
something is part of a list,
<3576f315.106536561@news.mindspring.com>
That looks to me the list is already there, but the hash isn't.
++
++ >++ vs
++ >++
++ >++ M O(N) + T (for building and finding an entry in a hash).
++ >++
++ >++ if (M < (K + S)) then, for large enough N, it will be faster to build the
++ >++ hash _even for only one search_.
++ >
++ >Yeah, but if it turns out 'eq' is slower than hashing the elements,
++ >something would be very wrong.
++
++ Hard to say. Bit operation level implementations of hashing functions can
++ be VERY efficient: x33 is nothing more than a shift left 5 and an
++ addition. Depending on the machine architecture that might be only two
++ highly efficient machine instructions per character vs one (compare and
++ branch) for the 'eq' for every char in the array to be searched. And the
++ array lookups involves a general multiplication - which is always a good
++ place to look for a performance hit. And for long highly similar strings
++ the loop required to compare each character could weight down the equality
++ comparision quite a lot.
Perl would be in a sad state if eq was implemented that way. First of
all, if two strings are not the same length, no character by character
compare is required. Secondly, a character by character compare is
*one* compare per character - I'd be surprised if that is slower than
multiplying by 33. Thirdly, a single compare can stop as soon it found
two characters are different - you can't do that if you are hashing.
Fourthly, if you are searching the array, you can stop as soon as you
found the searched for string. Fifthly, would it turn out that comparing
bytes is a highly inefficient operation and multiplying by 33 isn't,
one could always implement 'eq' by first hash it, and only do the byte
by byte compare if the strings hash to the same value.
As for array lookups, yes they require in general a multiplication.
But how do you think hash keys and values are stored?
++ My _instinct_ says that _most_ of the time, for a single search, with
++ perfectly optimized array search and hash functions and short variable
++ strings, the array search will win for a single search.
Which is what I was claiming.
++ But I wouldn't bet
++ money on it without a formal analysis and certainly not on the vagaries of
++ real life where a less than optimal array implementation might lose _all_
++ the time to a more optimal hash implemention or where the difference might
++ be completely swamped by _other_ effects like I/O performance while
++ reading a datafile (in an efficient design where I/O is performed
++ asynchronously to the list building, the limiting factor would be I/O
++ throughput - the CPU bound portion of the task would be completely
++ swallowed by it) or degenerate cases like lists of identically sized
++ 200000 character strings differing only in their final 10 positions.
And don't forget the phases of the moon!
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my @array = map {my $str = '';
foreach (1 .. 2 + int rand (5) + int rand (5)) {
$str .= chr (int rand 256);
}
$str} 1 .. 5000;
my $q = '';
foreach (1 .. 2 + int rand (5) + int rand (5)) {$q .= chr (int rand 256);}
timethese 1000, {
'in' => sub {foreach (@array) {return 1 if $_ eq $q}},
'hash' => sub {my %hash; @hash {@array} = (); exists $hash {$q} ? 1 : 0}
};
__END__
Benchmark: timing 1000 iterations of hash, in...
hash: 103 secs (84.21 usr 0.18 sys = 84.39 cpu)
in: 49 secs (38.49 usr 0.07 sys = 38.56 cpu)
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
------------------------------
Date: Mon, 08 Jun 1998 16:35:04 GMT
From: bubbha@my-dejanews.com
Subject: y2k Database prelaunch...please help.
Message-Id: <6lh3rp$9bd$1@nnrp1.dejanews.com>
Please help
My name is Alan Do, a college co-op who is working for Devon Consulting.
I have just finished the initial development of a dynamic database that will
eventually be known as the y2k (interactive) Database that will reside at
www.y2kdatabase.com. For now, it is on a developmental server at
http://bubba.devonconsulting.com
The database aims to provide a dynamic search and analyze database to locate
home/business software and hardware and return their year 2000 compliance
status as well as provide solution to problematic software. The site also
provides a section for you to add and edit information on any particular
product. It also includes a section where you can analyze your computer
system for any potential problem during the transition to the new millenium.
As far as I know, this is the first of its kind. Hopefully, with enough
attention, we can provide this free service. It could be very useful to
everyone in the next year and a half.
The problem? My MIS manager absolutely loves the database. However, the
companys president is still skeptical about its potential popularity and
usefulness and doesnt want to spend resource to populate the database with
more product entries unless he gets enough good feedback from internet users.
If you like the idea mentioned in theparagraph above, please stop by the
developmental site at http://bubba.devonconsulting.com and test out the
database. You can submit your comments through the Contact Information
section. You feedback will be extremely essential to the completion of the
database. Please let me know who you are as well. In return, I will add your
relevant site to our database before the official launch. As much resources
as I have now, I have no incentive to offer but my utmost gratitude.
Sincerely,
Alan Linh Do
buddha@drexel.edu
or ado@devonconsulting.com
Here is the list of some of the products in the database that you can
use to test it out:
Desk Pro 2000
Office 97 Professional Edition
CBT Courseware
WinFrame
Lotus Notes and Domino Server
Mac OS (Rhapsody)
Apple Computer
WinFax PRO
NetWare
Norton Anti-Virus
pcANYWHERE
cc:Mail
Zip/Jazz Tools
High-End Router
Navigator
FaxPress
WinZip
PowerChute Plus for NetWare
Domino
D-serve
ACT!
SQL Server
Windows
Windows
Windows
Courier & Sportster modems / x2 modems / Courier &
NIC's
BSDI
TeckChek
Computer Desktop Encyclopedia
MAS
JetDirect Cards
ProLiant 1000
Deskpro 5100
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
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 2812
**************************************