[18617] in Perl-Users-Digest
Perl-Users Digest, Issue: 785 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 27 21:05:44 2001
Date: Fri, 27 Apr 2001 18:05:13 -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: <988419913-v10-i785@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 27 Apr 2001 Volume: 10 Number: 785
Today's topics:
Re: "return" from a "require"? (Logan Shaw)
Re: "return" from a "require"? <xris@dont.send.spam>
Re: "return" from a "require"? <bart.lateur@skynet.be>
$?=32512 Translation please <stumo@bigfoot.com>
Re: $?=32512 Translation please <Jonathan.L.Ericson@jpl.nasa.gov>
Re: [Very OT] Sex and apathy <sjerk@foo.zark.off>
Re: Appending to files and flock. (Abigail)
Re: Appending to files and flock. <ren@tivoli.com>
Re: Appending to files and flock. (Gwyn Judd)
Re: Appending to files and flock. (Anno Siegel)
Re: Appending to files and flock. (Randal L. Schwartz)
Re: Appending to files and flock. <bart.lateur@skynet.be>
Re: Appending to files and flock. <joe+usenet@sunstarsys.com>
Re: Appending to files and flock. (Abigail)
Boole's tools (was Things I'm just not getting in Perl) <andrew_lee@nospamearthlink.net>
Boole's tools (was Things I'm just not getting in Perl) <andrew_lee@nospamearthlink.net>
Boole's tools (was Things I'm just not getting in Perl) <andrew_lee@nospamearthlink.net>
Boole's tools (was Things I'm just not getting in Perl) <andrew_lee@nospamearthlink.net>
Re: Boole's tools (was Things I'm just not getting in P (Anno Siegel)
capture jpg from avi/mpeg file <ilmbase@zacksmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Apr 2001 17:22:49 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: "return" from a "require"?
Message-Id: <9ccrfp$nri$1@daggoo.cs.utexas.edu>
In article <xris-D8DCAC.16092827042001@news.evergo.net>,
xris <xris@dont.send.spam> wrote:
>Is there any way to return early from a "require" - like return() allows
>you to from a subroutine?
Yes, and it's remarkably like when you return() from a subroutine.
What you do is you return() from the file.
If foo.pl is this:
$x = 5;
return 1;
$y = 5;
And bar.pl is this:
$x = $y = 2;
require "foo.pl";
print "x is $x, y is $y\n";
"perl bar.pl" prints this:
x is 5, y is 2
Hope that helps.
- Logan
--
my your his her our their _its_
I'm you're he's she's we're they're _it's_
------------------------------
Date: Fri, 27 Apr 2001 18:59:10 -0500
From: xris <xris@dont.send.spam>
Subject: Re: "return" from a "require"?
Message-Id: <xris-902B69.18591027042001@news.evergo.net>
In article <9ccrfp$nri$1@daggoo.cs.utexas.edu>,
logan@cs.utexas.edu (Logan Shaw) wrote:
> Yes, and it's remarkably like when you return() from a subroutine.
> What you do is you return() from the file.
ah, weird. I seem to remember that not working when I tried it years
ago. maybe it was just a weird version of perl. guess I'll have to try
again (I didn't really need the code, but thought it might be nice to
have at some point down the road).
------------------------------
Date: Sat, 28 Apr 2001 00:19:45 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: "return" from a "require"?
Message-Id: <j43ketg748sgut87635v617r7kkh3vgj5s@4ax.com>
xris wrote:
>> Yes, and it's remarkably like when you return() from a subroutine.
>> What you do is you return() from the file.
>
>ah, weird. I seem to remember that not working when I tried it years
>ago. maybe it was just a weird version of perl. guess I'll have to try
>again (I didn't really need the code, but thought it might be nice to
>have at some point down the road).
I would have doubts myself, because it most definitely doesn't work in
the main script, so I don't trust it in a required file either.
I try to do this instead:
if(COND) {
...
} else {
...
}
--
Bart.
------------------------------
Date: Sat, 28 Apr 2001 01:29:10 +0100
From: "Stuart Moore" <stumo@bigfoot.com>
Subject: $?=32512 Translation please
Message-Id: <V8oG6.199$iX1.28700@news6-win.server.ntlworld.com>
A program I am trying to run in ``s in perl on FreeBSD is not working, and
returns $?=32512. Is there any way to decode this to find out exactly what the
error is?
Much obliged
Stuart
------------------------------
Date: 28 Apr 2001 00:51:54 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: $?=32512 Translation please
Message-Id: <86itjpalsl.fsf@jon_ericson.jpl.nasa.gov>
"Stuart Moore" <stumo@bigfoot.com> writes:
> A program I am trying to run in ``s in perl on FreeBSD is not
> working, and returns $?=32512. Is there any way to decode this to
> find out exactly what the error is?
From perlvar:
$? The status returned by the last pipe close, back-
tick ("``") command, successful call to wait() or
waitpid(), or from the system() operator. This is
just the 16-bit status word returned by the wait()
system call (or else is made up to look like it).
Thus, the exit value of the subprocess is really
("$? >> 8"), and "$? & 127" gives which signal, if
any, the process died from, and "$? & 128" reports
whether there was a core dump. (Mnemonic: similar
to sh and ksh.)
Jon
------------------------------
Date: 28 Apr 2001 00:42:06 GMT
From: some jerk <sjerk@foo.zark.off>
Subject: Re: [Very OT] Sex and apathy
Message-Id: <9cd3ku$ll3$1@news.datasync.com>
In article <osRF6.136726$HR6.15535238@nnrp4.clara.net>,
Milton Road <miltonroad@btinternet.com> wrote:
>> i am sure you do it better
>> than you code perl and the chill will do you good.
>Ooh! Casting aspersions on my sex life and my Perl code. I must
>attempt to defend both!!
NO need -- just go to CPAN and download Wank.pm.
------------------------------
Date: Fri, 27 Apr 2001 22:06:55 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Appending to files and flock.
Message-Id: <slrn9ejrbv.mm6.abigail@tsathoggua.rlyeh.net>
Paul the Nomad (taka@yarn.demon.co.uk) wrote on MMDCCXCVI September
MCMXCIII in <URL:news:871yqeb1kn.fsf@euterpe.yarn.demon.co.uk>:
""
"" Is there *any* documentation *anywhere* written by someone who knows
"" what they are talking about that covers having one file open by many
"" processes for appending?
It's been pointed out to you too many times already. But I bet you
wouldn't even recognize it when it's used to beat you to death.
OPEN(2) Linux Programmer's Manual OPEN(2)
NAME
open, creat - open and possibly create a file or device
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
int creat(const char *pathname, mode_t mode);
DESCRIPTION
open attempts to open a file and return a file descriptor
(a small, non-negative integer for use in read, write,
etc.)
flags is one of O_RDONLY, O_WRONLY or O_RDWR which request
opening the file read-only, write-only or read/write,
respectively.
flags may also be bitwise-or'd with one or more of the
following:
O_CREAT
If the file does not exist it will be created.
O_EXCL When used with O_CREAT, if the file already exists
it is an error and the open will fail. O_EXCL is
broken on NFS file systems, programs which rely on
it for performing locking tasks will contain a race
condition. The solution for performing atomic file
locking using a lockfile is to create a unique file
on the same fs (e.g., incorporating hostname and
pid), use link(2) to make a link to the lockfile
and use stat(2) on the unique file to check if its
link count has increased to 2. Do not use the
return value of the link() call.
O_NOCTTY
If pathname refers to a terminal device -- see
tty(4) -- it will not become the process's control
ling terminal even if the process does not have
one.
O_TRUNC
If the file already exists it will be truncated.
O_APPEND
The file is opened in append mode. Initially, and
before each write, the file pointer is positioned
at the end of the file, as if with lseek. O_APPEND
may lead to corrupted files on NFS file systems if
more than one process appends data to a file at
Linux 2.0.32 December 20, 1996 1
OPEN(2) Linux Programmer's Manual OPEN(2)
once. This is because NFS does not support append
ing to a file, so the client kernel has to simulate
it, which can't be done without a race condition.
O_NONBLOCK or O_NDELAY
The file is opened in non-blocking mode. Neither
the open nor any subsequent operations on the file
descriptor which is returned will cause the calling
process to wait.
O_SYNC The file is opened for synchronous I/O. Any writes
on the resulting file descriptor will block the
calling process until the data has been physically
written to the underlying hardware. See RESTRIC
TIONS below, though.
Some of these optional flags can be altered using fcntl
after the file has been opened.
mode specifies the permissions to use if a new file is
created. It is modified by the process's umask in the
usual way: the permissions of the created file are (mode &
~umask).
The following symbolic constants are provided for mode:
S_IRWXU
00700 user (file owner) has read, write and execute
permission
S_IRUSR (S_IREAD)
00400 user has read permission
S_IWUSR (S_IWRITE)
00200 user has write permission
S_IXUSR (S_IEXEC)
00100 user has execute permission
S_IRWXG
00070 group has read, write and execute permission
S_IRGRP
00040 group has read permission
S_IWGRP
00020 group has write permission
S_IXGRP
00010 group has execute permission
S_IRWXO
00007 others have read, write and execute permis
sion
Linux 2.0.32 December 20, 1996 2
OPEN(2) Linux Programmer's Manual OPEN(2)
S_IROTH
00004 others have read permission
S_IWOTH
00002 others have write permisson
S_IXOTH
00001 others have execute permission
mode should always be specified when O_CREAT is in the
flags, and is ignored otherwise.
creat is equivalent to open with flags equal to
O_CREAT|O_WRONLY|O_TRUNC.
RETURN VALUE
open and creat return the new file descriptor, or -1 if an
error occurred (in which case, errno is set appropri
ately). Note that open can open device special files, but
creat cannot create them - use mknod(2) instead.
On NFS file systems with UID mapping enabled, open may
return a file descriptor but e.g. read(2) requests are
denied with EACCES. This is because the client performs
open by checking the permissions, but UID mapping is per
formed by the server upon read and write requests.
ERRORS
EEXIST pathname already exists and O_CREAT and O_EXCL were
used.
EISDIR pathname refers to a directory and the access
requested involved writing.
ETXTBSY
pathname refers to an executable image which is
currently being executed and write access was
requested.
EFAULT pathname points outside your accessible address
space.
EACCES The requested access to the file is not allowed, or
one of the directories in pathname did not allow
search (execute) permission.
ENAMETOOLONG
pathname was too long.
ENOENT A directory component in pathname does not exist or
is a dangling symbolic link.
ENOTDIR
A component used as a directory in pathname is not,
Linux 2.0.32 December 20, 1996 3
OPEN(2) Linux Programmer's Manual OPEN(2)
in fact, a directory.
EMFILE The process already has the maximum number of files
open.
ENFILE The limit on the total number of files open on the
system has been reached.
ENOMEM Insufficient kernel memory was available.
EROFS pathname refers to a file on a read-only filesystem
and write access was requested.
ELOOP Too many symbolic links were encountered in resolv
ing pathname.
ENOSPC pathname was to be created but the device contain
ing pathname has no room for the new file.
CONFORMING TO
SVr4, SVID, POSIX, X/OPEN, BSD 4.3
RESTRICTIONS
There are many infelicities in the protocol underlying
NFS, affecting amongst others O_SYNC and O_NDELAY.
SEE ALSO
read(2), write(2), fcntl(2), close(2), unlink(2),
mknod(2), stat(2), umask(2), mount(2), socket(2),
socket(2), fopen(3), link(2).
Now, please fuck off and die.
Abigail
------------------------------
Date: 27 Apr 2001 16:43:36 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Appending to files and flock.
Message-Id: <m3elueqarb.fsf@dhcp9-172.support.tivoli.com>
On 27 Apr 2001, taka@yarn.demon.co.uk wrote:
> Bart Lateur <bart.lateur@skynet.be> writes:
>
>> No, it's something about ">>". This garantees that writing to this
>> file will append the data at the end of the file. If the data to
>> print is small enough, you may be pretty sure it won't ever be
>> corrupted. But don't bet your life on it.
>
> Therefore should use flock.
FWIW, here is an excerpt from open(2) on my RedHat 7.0 system:
O_APPEND
The file is opened in append mode. Before each
write, the file pointer is positioned at the end of
the file, as if with lseek. O_APPEND may lead to
corrupted files on NFS file systems if more than
one process appends data to a file at once. This
is because NFS does not support appending to a
file, so the client kernel has to simulate it,
which can't be done without a race condition.
The key point is that the append mode isn't just "open the file and
start writing at the end". Instead it is, "open the file and start
*every* write at the end". This difference is what makes it safe to
append from multiple processes at the same time.
In addition to the NFS problem mentioned in the man page, there are at
least two additional problems:
1. If the write is larger than the buffer size, then it will possibly
be broken into multiple writes that could be interleaved with other
writes.
Now, this isn't a problem if you're writing single lines to a log
file, for example. You can feel confident that each such write will
occur atomically and no corruption will occur.
2. It is OS-specific. It may be the case that some OSes do not
provide this semantic for O_APPEND. I'm honestly not sure how
prolific this functionality is.
Of course, flock isn't portable either, so using flock because you
can't trust the semantics of append mode is pretty silly.
If you want to use flock, use flock. But don't think it is bringing
much additional robustness to the situation.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Fri, 27 Apr 2001 23:17:46 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Appending to files and flock.
Message-Id: <slrn9ejvgp.978.tjla@thislove.dyndns.org>
"mein Luftkissenfahrzeug ist voll von den Aalen"
said nobull@mail.com (nobull@mail.com) in
<u9u23af6ps.fsf@wcl-l.bham.ac.uk>:
>OK here's the truth.
<snip really good answer>
That's excellent. I think this should go into the faq.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"I prefer to think that God is not dead, just drunk"
-- John Huston
------------------------------
Date: 27 Apr 2001 23:44:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Appending to files and flock.
Message-Id: <9cd08b$qtc$2@mamenchi.zrz.TU-Berlin.DE>
According to Gwyn Judd <tjla@guvfybir.qlaqaf.bet>:
> "mein Luftkissenfahrzeug ist voll von den Aalen"
> said nobull@mail.com (nobull@mail.com) in
> <u9u23af6ps.fsf@wcl-l.bham.ac.uk>:
>
> >OK here's the truth.
>
> <snip really good answer>
>
> That's excellent. I think this should go into the faq.
Seconded.
Anno
------------------------------
Date: 27 Apr 2001 17:16:17 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Appending to files and flock.
Message-Id: <m1wv85zxny.fsf@halfdome.holdit.com>
>>>>> "Ren" == Ren Maddox <ren@tivoli.com> writes:
Ren> 2. It is OS-specific. It may be the case that some OSes do not
Ren> provide this semantic for O_APPEND. I'm honestly not sure how
Ren> prolific this functionality is.
It wasn't in V7 Unix. It was added in some BSD release, if I recall,
and then later adopted into Sys V, so it's possible that V7-based,
early BSD-based, or early SysV based Unixen won't have it.
Just another guy who has used Unix for 23 years... :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sat, 28 Apr 2001 00:17:20 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Appending to files and flock.
Message-Id: <j03ketg4ktj5n00qdi5am12ijdnj3ld8vk@4ax.com>
Ren Maddox wrote:
>The key point is that the append mode isn't just "open the file and
>start writing at the end". Instead it is, "open the file and start
>*every* write at the end".
At least, it's as safe as ignoring opens that failed on OSes that do
autoflock on open, because the file was open in another program.
--
Bart.
------------------------------
Date: 27 Apr 2001 20:29:46 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Appending to files and flock.
Message-Id: <m3d79xn9xh.fsf@mumonkan.sunstarsys.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> According to Gwyn Judd <tjla@guvfybir.qlaqaf.bet>:
> > "mein Luftkissenfahrzeug ist voll von den Aalen"
> > said nobull@mail.com (nobull@mail.com) in
> > <u9u23af6ps.fsf@wcl-l.bham.ac.uk>:
> >
> > >OK here's the truth.
> >
> > <snip really good answer>
> >
> > That's excellent. I think this should go into the faq.
>
> Seconded.
So this would be a bug then, right?
% strace -fe trace=write perl -e 'open STDOUT, ">>/dev/null" or die $!;
fork; @_ = ($$ & 1) x 1_000; print @_'
[pid 5494] write(1, "00000000000000000000000000000000"..., 128) = 128
[pid 5494] write(1, "00000000000000000000000000000000"..., 128) = 128
[pid 5494] write(1, "00000000000000000000000000000000"..., 128) = 128
[pid 5494] write(1, "00000000000000000000000000000000"..., 128) = 128
[pid 5493] write(1, "11111111111111111111111111111111"..., 128) = 128
[pid 5493] write(1, "11111111111111111111111111111111"..., 128) = 128
[pid 5493] write(1, "11111111111111111111111111111111"..., 128) = 128
[pid 5493] write(1, "11111111111111111111111111111111"..., 128) = 128
[pid 5493] write(1, "11111111111111111111111111111111"..., 128) = 128
[pid 5493] write(1, "11111111111111111111111111111111"..., 128) = 128
[pid 5493] write(1, "11111111111111111111111111111111"..., 128) = 128
[pid 5493] write(1, "11111111111111111111111111111111"..., 104) = 104
write(1, "00000000000000000000000000000000"..., 128) = 128
write(1, "00000000000000000000000000000000"..., 128) = 128
write(1, "00000000000000000000000000000000"..., 128) = 128
write(1, "00000000000000000000000000000000"..., 104) = 104
This was generated with 5.6.1 on linux 2.4 with PerlIO + SFIO 1999.
It seems to be associated with printing a long list of numeric scalars
as opposed to their stringified counterparts.
% perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
...
config_args='-Doptimize=-g'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=define uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
...
I don't encounter this problem when compiled with useperlio=undef.
--
Joe Schaefer "Get the facts first, and then you can distort them as you
like."
--Mark Twain
------------------------------
Date: Sat, 28 Apr 2001 00:50:47 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Appending to files and flock.
Message-Id: <slrn9ek4v7.mm6.abigail@tsathoggua.rlyeh.net>
Ren Maddox (ren@tivoli.com) wrote on MMDCCXCVI September MCMXCIII in
<URL:news:m3elueqarb.fsf@dhcp9-172.support.tivoli.com>:
))
)) In addition to the NFS problem mentioned in the man page, there are at
)) least two additional problems:
))
)) 1. If the write is larger than the buffer size, then it will possibly
)) be broken into multiple writes that could be interleaved with other
)) writes.
Yes, but in that case, you could always use syswrite().
)) Now, this isn't a problem if you're writing single lines to a log
)) file, for example. You can feel confident that each such write will
)) occur atomically and no corruption will occur.
))
)) 2. It is OS-specific. It may be the case that some OSes do not
)) provide this semantic for O_APPEND. I'm honestly not sure how
)) prolific this functionality is.
They way I interpret APUE is that there is just one semantic of O_APPEND.
It points out that "older versions of Unix" don't have O_APPEND. And
APUE usually spells out differences between the BSD and Sys V versions
from 1986 onwards, so this suggest that 15 years ago, both BSD and Sys V
supported O_APPEND.
I doubt there is anyone programming systems that old *not* knowing that
O_APPEND isn't supported for that system.
APUE: Advanced Programming in the UNIX Environment, by the late and great
W. Richard Stevens. May he rest in peace.
Abigail
--
BEGIN {$^H {q} = sub {pop and pop and print pop}; $^H = 2**4.2**12}
"Just "; "another "; "Perl "; "Hacker\n";
------------------------------
Date: Fri, 27 Apr 2001 23:50:10 GMT
From: Andrew Lee <andrew_lee@nospamearthlink.net>
Subject: Boole's tools (was Things I'm just not getting in Perl)
Message-Id: <3AEA06A5.4E41DC3F@nospamearthlink.net>
> Andrew Lee (andrew_lee@nospamearthlink.net) wrote on MMDCCXCVI September
Maybe your problem stems from your misuse of Roman Numerals ... either that or I
posted the refered to article 795 years from now.
>
> MCMXCIII in <URL:news:3AE939B2.3D01BA08@nospamearthlink.net>:
> }} Abigail wrote:
> }}
> }} > Hell, not even '||' returns 1 for "true".
> }}
> }} '||' is a binary operator ... it takes two arguments ... e.g. True OR true i
> }} true .... write a program and see for yourself.
>
> $ perl -wle 'print +(2 || 1)'
> 2
> $
>
> Doesn't seem to return 1 ....
That is amazing -- are you going to publish??? This will turn the CS world on it's
head!
>
> }} > [1] boolean function? In *Perl*?!? There are no flippin' booleans in Perl.
> }} > It just inherits the moronic behaviour of C. Real languages have boolea
> }}
> }} So ... please define a "real" language ...
>
> Java.
>
Go make your pithy little comments in comp.lang.java.* then.
See ya!
To the point of the original post:
In the mid 19th century George Boole devised a way to deal with logical statements
in algebraic terms. Some where along the way the term 'boolean' was introduced to
SQL and some other modern computing languages to describe a variable that has two
states (on, off, true, false, yes, no, 1, 0). It is basically superfluous, since
anyone who has ever toyed with binary representations knows that you can use bits to
encode "true", "false" or "yes", "no" or "on", "off".
C, and consequently Perl has bit operators, |, &, ^ ... it also has logical
operators ||, &&. Perl then adds string logical operators 'or', 'and'.
Anyway, 0x01 | 0x01 = 0x01 ... etc ... so all of your boolean operations are
available via integers and bitwise operators. || and && CAN be used, if you promise
to use ONLY 0 or 1! Since that is too limiting (you want to use other integers,
yes?), use | and & for bitwise operations.
To see an application, look at http://www.ssh.com/tech/crypto/algorithms.html -- a
discussion of various cryptographic techniques.
However, there is no such thing as a "boolean context" in Perl :-)
HTH
Andrew F. Lee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When I say, "Ignore the man behind the curtain."
That is because there is no man behind the curtain.
------------------------------
Date: Fri, 27 Apr 2001 23:50:50 GMT
From: Andrew Lee <andrew_lee@nospamearthlink.net>
Subject: Boole's tools (was Things I'm just not getting in Perl)
Message-Id: <3AEA06CD.4233CA2E@nospamearthlink.net>
> Andrew Lee (andrew_lee@nospamearthlink.net) wrote on MMDCCXCVI September
Maybe your problem stems from your misuse of Roman Numerals ... either that or I
posted the referred to article 795 years from now.
>
> MCMXCIII in <URL:news:3AE939B2.3D01BA08@nospamearthlink.net>:
> }} Abigail wrote:
> }}
> }} > Hell, not even '||' returns 1 for "true".
> }}
> }} '||' is a binary operator ... it takes two arguments ... e.g. True OR true i
> }} true .... write a program and see for yourself.
>
> $ perl -wle 'print +(2 || 1)'
> 2
> $
>
> Doesn't seem to return 1 ....
That is amazing -- are you going to publish??? This will turn the CS world on it's
head!
>
> }} > [1] boolean function? In *Perl*?!? There are no flippin' booleans in Perl.
> }} > It just inherits the moronic behaviour of C. Real languages have boolea
> }}
> }} So ... please define a "real" language ...
>
> Java.
>
Go make your pithy little comments in comp.lang.java.* then.
See ya!
To the point of the original post:
In the mid 19th century George Boole devised a way to deal with logical statements
in algebraic terms. Some where along the way the term 'boolean' was introduced to
SQL and some other modern computing languages to describe a variable that has two
states (on, off, true, false, yes, no, 1, 0). It is basically superfluous, since
anyone who has ever toyed with binary representations knows that you can use bits to
encode "true", "false" or "yes", "no" or "on", "off".
C, and consequently Perl has bit operators, |, &, ^ ... it also has logical
operators ||, &&. Perl then adds string logical operators 'or', 'and'.
Anyway, 0x01 | 0x01 = 0x01 ... etc ... so all of your boolean operations are
available via integers and bitwise operators. || and && CAN be used, if you promise
to use ONLY 0 or 1! Since that is too limiting (you want to use other integers,
yes?), use | and & for bitwise operations.
To see an application, look at http://www.ssh.com/tech/crypto/algorithms.html -- a
discussion of various cryptographic techniques.
However, there is no such thing as a "boolean context" in Perl :-)
HTH
Andrew F. Lee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When I say, "Ignore the man behind the curtain."
That is because there is no man behind the curtain.
------------------------------
Date: Fri, 27 Apr 2001 23:51:51 GMT
From: Andrew Lee <andrew_lee@nospamearthlink.net>
Subject: Boole's tools (was Things I'm just not getting in Perl)
Message-Id: <3AEA070A.212DA9C0@nospamearthlink.net>
> Andrew Lee (andrew_lee@nospamearthlink.net) wrote on MMDCCXCVI September
Maybe your problem stems from your misuse of Roman Numerals ... either that or I
posted the referred to article 795 years from now.
>
> MCMXCIII in <URL:news:3AE939B2.3D01BA08@nospamearthlink.net>:
> }} Abigail wrote:
> }}
> }} > Hell, not even '||' returns 1 for "true".
> }}
> }} '||' is a binary operator ... it takes two arguments ... e.g. True OR true i
> }} true .... write a program and see for yourself.
>
> $ perl -wle 'print +(2 || 1)'
> 2
> $
>
> Doesn't seem to return 1 ....
That is amazing -- are you going to publish??? This will turn the CS world on it's
head!
>
> }} > [1] boolean function? In *Perl*?!? There are no flippin' booleans in Perl.
> }} > It just inherits the moronic behaviour of C. Real languages have boolea
> }}
> }} So ... please define a "real" language ...
>
> Java.
>
Go make your pithy little comments in comp.lang.java.* then.
See ya!
To the point of the original post:
In the mid 19th century George Boole devised a way to deal with logical statements
in algebraic terms. Some where along the way the term 'boolean' was introduced to
SQL and some other modern computing languages to describe a variable that has two
states (on, off, true, false, yes, no, 1, 0). It is basically superfluous, since
anyone who has ever toyed with binary representations knows that you can use bits to
encode "true", "false" or "yes", "no" or "on", "off".
C, and consequently Perl has bit operators, |, &, ^ ... it also has logical
operators ||, &&. Perl then adds string logical operators 'or', 'and'.
Anyway, 0x01 | 0x01 = 0x01 ... etc ... so all of your boolean operations are
available via integers and bitwise operators. || and && CAN be used, if you promise
to use ONLY 0 or 1! Since that is too limiting (you want to use other integers,
yes?), use | and & for bitwise operations.
To see an application, look at http://www.ssh.com/tech/crypto/algorithms.html -- a
discussion of various cryptographic techniques.
However, there is no such thing as a "boolean context" in Perl :-)
HTH
Andrew F. Lee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When I say, "Ignore the man behind the curtain."
That is because there is no man behind the curtain.
------------------------------
Date: Fri, 27 Apr 2001 23:52:31 GMT
From: Andrew Lee <andrew_lee@nospamearthlink.net>
Subject: Boole's tools (was Things I'm just not getting in Perl)
Message-Id: <3AEA0738.F0D69175@nospamearthlink.net>
> Andrew Lee (andrew_lee@nospamearthlink.net) wrote on MMDCCXCVI September
Maybe your problem stems from your misuse of Roman Numerals ... either that or I
posted the referred to article 795 years from now.
>
> MCMXCIII in <URL:news:3AE939B2.3D01BA08@nospamearthlink.net>:
> }} Abigail wrote:
> }}
> }} > Hell, not even '||' returns 1 for "true".
> }}
> }} '||' is a binary operator ... it takes two arguments ... e.g. True OR true i
> }} true .... write a program and see for yourself.
>
> $ perl -wle 'print +(2 || 1)'
> 2
> $
>
> Doesn't seem to return 1 ....
That is amazing -- are you going to publish??? This will turn the CS world on it's
head!
>
> }} > [1] boolean function? In *Perl*?!? There are no flippin' booleans in Perl.
> }} > It just inherits the moronic behaviour of C. Real languages have boolea
> }}
> }} So ... please define a "real" language ...
>
> Java.
>
Go make your pithy little comments in comp.lang.java.* then.
See ya!
To the point of the original post:
In the mid 19th century George Boole devised a way to deal with logical statements
in algebraic terms. Some where along the way the term 'boolean' was introduced to
SQL and some other modern computing languages to describe a variable that has two
states (on, off, true, false, yes, no, 1, 0). It is basically superfluous, since
anyone who has ever toyed with binary representations knows that you can use bits to
encode "true", "false" or "yes", "no" or "on", "off".
C, and consequently Perl has bit operators, |, &, ^ ... it also has logical
operators ||, &&. Perl then adds string logical operators 'or', 'and'.
Anyway, 0x01 | 0x01 = 0x01 ... etc ... so all of your boolean operations are
available via integers and bitwise operators. || and && CAN be used, if you promise
to use ONLY 0 or 1! Since that is too limiting (you want to use other integers,
yes?), use | and & for bitwise operations.
To see an application, look at http://www.ssh.com/tech/crypto/algorithms.html -- a
discussion of various cryptographic techniques.
However, there is no such thing as a "boolean context" in Perl :-)
HTH
Andrew F. Lee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When I say, "Ignore the man behind the curtain."
That is because there is no man behind the curtain.
------------------------------
Date: 28 Apr 2001 00:23:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Boole's tools (was Things I'm just not getting in Perl)
Message-Id: <9cd2h6$qtc$4@mamenchi.zrz.TU-Berlin.DE>
Andrew Lee shows his savoir-faire by posting five times:
> > Andrew Lee (andrew_lee@nospamearthlink.net) wrote on MMDCCXCVI September
>
> Maybe your problem stems from your misuse of Roman Numerals ... either that or I
> posted the refered to article 795 years from now.
Thanks for making a fool of yourself right from the start. That saves
me the effort of reading the rest of your drivel. Abigail dates postings
creatively but accurately.
[rest snipped]
Anno
PS: Don't bother to adjust your line length. It doesn't matter much
anymore.
------------------------------
Date: Fri, 27 Apr 2001 22:31:30 GMT
From: "ilmbase" <ilmbase@zacksmail.com>
Subject: capture jpg from avi/mpeg file
Message-Id: <6rmG6.30722$ii.3425801@afrodite.telenet-ops.be>
Hi,
I am searching for a package that makes it possible to capture a screenshot
from a avi or mpeg file and saves it as an .jpg file.
Any help is appreciated !
Thank You,
Ilmbase
------------------------------
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 785
**************************************