[25083] in Perl-Users-Digest
Perl-Users Digest, Issue: 7333 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 28 18:05:49 2004
Date: Thu, 28 Oct 2004 15: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)
Perl-Users Digest Thu, 28 Oct 2004 Volume: 10 Number: 7333
Today's topics:
Re: Am *I* allowed to make a suggestion for PG <nospam@nospam.com>
Re: browser output <abigail@abigail.nl>
Re: browser output <nospam@nospam.com>
Re: browser output <uguttman@athenahealth.com>
Re: browser output (Daniel R. Tobias)
Re: Common file operations <bradd+news@szonye.com>
Re: Common file operations <bik.mido@tiscalinet.it>
Re: Common file operations <jwkenne@attglobal.net>
Re: Common file operations <1usa@llenroc.ude.invalid>
Re: Compress::Zlib vs. external gzip call (odigity)
Re: Compress::Zlib vs. external gzip call (odigity)
Re: Compress::Zlib vs. external gzip call (odigity)
cpan <stuart--nospam--@carrison.co.uk.nospam>
Re: cpan <mritty@gmail.com>
Re: cpan <1usa@llenroc.ude.invalid>
FAQ 4.46: How do I handle linked lists? <comdog@panix.com>
file tests <dont.spam.me@spamhate.com>
Re: file tests <dsgSPAMFILTER@alum.dartmouth.org>
Re: file tests <noreply@gunnar.cc>
Re: file tests <mritty@gmail.com>
Re: goto (was browser output) <abigail@abigail.nl>
Re: goto (was browser output) <abigail@abigail.nl>
How can I change a Perl floating-point value to a bit v <none@nowhere.invalid>
Re: How can I change a Perl floating-point value to a b ctcgag@hotmail.com
Re: How to get an image file and display it on the scre <Allen.Windhorn@LSUSA.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 28 Oct 2004 15:36:56 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: Am *I* allowed to make a suggestion for PG
Message-Id: <1098992273.480451@nntp.acecape.com>
"krakle" <krakle@visto.com> wrote in message
news:237aaff8.0410280914.6975dde2@posting.google.com...
>If you offend them seriously who cares.
>If you also got offended, ...
well, my philosiphy in life is to try and rememebr that the only hting you
have 100% control over is how you treat people, it is the ultimate in proper
behavior....i try to be this way, but am not always sucessful, but i will
keep trying
> But I do agree the flaming and cruelness need to stop.
agreed on the agreed ;-)
------------------------------
Date: 28 Oct 2004 20:12:36 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: browser output
Message-Id: <slrnco2klk.3ac.abigail@alexandra.abigail.nl>
Brian Wakem (no@email.com) wrote on MMMMLXXVI September MCMXCIII in
<URL:news:2ucmdrF28qp54U1@uni-berlin.de>:
{} Tore Aursand wrote:
{}
{} > On Wed, 27 Oct 2004 15:34:01 -0400, daniel kaplan wrote:
{} >> with regards to your EXIT comment, if i hear correctly , just make sure
{} >> your script is at the bottom of the file (subroutines on top) and just
{} >> let it run through?
{} >
{} > No. It - normally - doesn't matter where your subroutines are, and in
{} > "traditional" CGI programming you should _never_ use 'exit'.
{} >
{} > Why do you need to use exit? A CGI program runs from A to Z, then it's
{} > done, right? Why do you need to exit at - for instance - F og M in the
{} > script?
{}
{}
{} #!/usr/bin/perl
{}
{} use strict;
{} use CGI;
{} my $query = new CGI;
{}
{}
{} if (..some condition is met..) {
{} print $query->redirect(..some other url..);
{} exit;
{} }
{}
{} .. more code..
{}
{}
{} Without the exit the script continues to run even though the person
{} accessing the script is long gone.
{}
{} What would be better than exit here?
Some people would say:
if (... some condition is met ...) {
print $query->redirect(..some other url..);
exit;
}
else {
... more code ...
}
Not me. I think that using 'exit' halfway your program is as natural
as using 'return' halfway a subroutine.
Abigail
--
#!/opt/perl/bin/perl -w
$\ = $"; $SIG {TERM} = sub {print and exit};
kill 15 => fork for qw /Just another Perl Hacker/;
------------------------------
Date: Thu, 28 Oct 2004 16:24:52 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: browser output
Message-Id: <1098995150.42427@nntp.acecape.com>
"Abigail" <abigail@abigail.nl> wrote in message
news:slrnco2klk.3ac.abigail@alexandra.abigail.nl...
> Not me. I think that using 'exit' halfway your program is as natural
> as using 'return' halfway a subroutine.
going by your point, i would love to hear some more (clarification) on
this....since to me what abigail states seems proper. as long as exit does
all its resource freeing in a clean manner, why not use it?
------------------------------
Date: Thu, 28 Oct 2004 16:46:02 -0400
From: Uri Guttman <uguttman@athenahealth.com>
Subject: Re: browser output
Message-Id: <m3r7niwoz9.fsf@linux.local>
>>>>> "A" == Abigail <abigail@abigail.nl> writes:
A> Some people would say:
A> if (... some condition is met ...) {
A> print $query->redirect(..some other url..);
A> exit;
A> }
A> else {
A> ... more code ...
A> }
A> Not me. I think that using 'exit' halfway your program is as natural
A> as using 'return' halfway a subroutine.
i go the other way. early returns are good ways to handle interesting
flow control. and exiting in the right place is as useful. a simple
example is exit (or die) in a usage sub which is called from several
places in the arg parsing code.
and i would do the above code without the else since you exited in the
then clause. saves an indent and pair of expensive braces and an else
token! :)
uri
------------------------------
Date: 28 Oct 2004 14:39:32 -0700
From: dan@tobias.name (Daniel R. Tobias)
Subject: Re: browser output
Message-Id: <aab17256.0410281339.6ea7a8b3@posting.google.com>
"Bill Segraves" <segraves_f13@mindspring.com> wrote in message news:<KEWfd.9845$5i5.4791@newsread2.news.atl.earthlink.net>...
> Also, it appears the OP is interested in preventing the browser from
> interpreting HTML that is embedded in what is returned to the browser.
The best solution to that problem is to use a more standards-compliant
browser... Mozilla or Firefox will display plain text as plain text
regardless of the URL "extension", presence of stuff that looks like
"tags", and so on.
--
Dan
------------------------------
Date: Thu, 28 Oct 2004 18:39:18 GMT
From: "Bradd W. Szonye" <bradd+news@szonye.com>
Subject: Re: Common file operations
Message-Id: <slrnco2f6m.rfg.bradd+news@szonye.com>
Shmuel (Seymour J.) Metz wrote:
>> [2] OS/2 uses \ as a separator rather than /.
Michele Dondi wrote:
> Well, I don't know OS/2, and so I cannot tell about Perl under OS/2,
> but under DOS/Windows the directory separator is \ too, however Perl
> lets you use / anyway. I *guess* that it may be the same for OS/2.
I suspect that OS/2 uses the same rules as MS-DOS and Windows: While
command-line utilities conventionally use backslashes as path
separators, system calls accept both slashes and backslashes.
--
Bradd W. Szonye
http://www.szonye.com/bradd
------------------------------
Date: Thu, 28 Oct 2004 21:07:07 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Common file operations
Message-Id: <82g2o05lf7d62h3euntuc2uki349umhctf@4ax.com>
On Wed, 27 Oct 2004 18:32:28 -0300, "Shmuel (Seymour J.) Metz"
<spamtrap@library.lspace.org.invalid> wrote:
>>He does not trust the assertions you make without providing test
>>cases that exhibit the problems you mention.
>
>If he doesn't believe me, then why would he believe that the test
>output came from my computer? He didn't simply say that she wanted to
>see the test code and output, she called me a liar.
It-was-a-joke! I have already explained that my cmt was not intended
to be offensive, and I even apologized in case it inadvertently was.
Would you mind reading the other posts too?!?
I didn't call you a liar. But your claim as it was stated is
unsupported and would require more input, precisely in the form of a
(possibly minimal) example exhibiting the problem.
You said that I made up my mind. It seems to me that the one who has
mad up his mind is just you, precisely on the alleged fact that "I
don't believe you". To me you're nothing more than a name for now,
"Shmuel (Seymour J.) Metz", and certainly I don't judge you and mark
you with a label once and forever by a single claim of yours.
Oh, and I apologize for having tried to help you too...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Thu, 28 Oct 2004 19:34:22 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Common file operations
Message-Id: <2Rbgd.6484$UC4.2671316@news4.srv.hcvlny.cv.net>
Bradd W. Szonye wrote:
> I suspect that OS/2 uses the same rules as MS-DOS and Windows: While
> command-line utilities conventionally use backslashes as path
> separators, system calls accept both slashes and backslashes.
Yes. In these matters, OS/2 is pretty much identical to MS-DOS and Windows.
(Part of the confusion appears to be that this discussion is being done
in terms of REXX, IBM's scripting language.)
--
John W. Kennedy
"Compact is becoming contract,
Man only earns and pays."
-- Charles Williams. "Bors to Elayne: On the King's Coins"
------------------------------
Date: 28 Oct 2004 21:50:27 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Common file operations
Message-Id: <Xns9590B57C97B18asu1cornelledu@132.236.56.8>
"Shmuel (Seymour J.) Metz" <spamtrap@library.lspace.org.invalid> wrote in
news:418103fd$1$fuzhry+tra$mr2ice@news.patriot.net:
>>Sorry, but I think that you didn't clearly say what it is that you
>>want.
>
> 1. If I have a partial file name, how do I get the complete path?
>
> The answer seems to be Cwd::abs_path
It seems like you are using "partial name" to mean something other than I
would naturally expect it to mean. abs_path has nothing to do with partial
filenames. It converts a potentially relative path to an absolute path.
However, the file in question is fully identified.
On the other hand, when you say partial, one thinks of a file specification
such as te??.p* or even c:\dir\path\more\te??.p* Both of those patterns are
partial file names.
> 2. If I have a directory name and a file specification, how do I find
> all files in that directory matching the specification. File::Find
> and issuing an ls command seem like overkill. I could use readdir
> if I don't need a recursive search, but I was hoping for an
> equivalent of SysFileTree in OS/2.
>
> There doesn't seem to be a single service that will handle recursion.
> File::Find as documented doesn't do the matching.
See File::Find::Rule
Feel free to search CPAN next time.
Sinan
------------------------------
Date: 28 Oct 2004 14:13:37 -0700
From: ofer@netapt.com (odigity)
Subject: Re: Compress::Zlib vs. external gzip call
Message-Id: <de652f7.0410281313.45d1de81@posting.google.com>
Stuart Moore <usenet_05_08_2004@stuartmoore.org.uk> wrote in message news:<clpa84$fg9$1@gemini.csx.cam.ac.uk>...
> odigity wrote:
>
> > I'm writing a script that needs to run in as fast a time as possible.
> > Every minute counts. The script crawls a tree of gzipped files
> > totalling about 30gb. Originally I was calling open() with "gzip
> > $file |", but I hate making external calls - it requires a fork, and
> > you have very limited communication with the process for catching
> > errors and such. I always like using perl functions and modules when
> > possible over external calls. However, I wanted to make sure I
> > wouldn't take a performance hit before switching to Compress::Zlib.
> >
>
> Just thinking out loud here:
> - Would the time measured by "Benchmark" include the time to start gzip?
> Does it measure total time, or just time when the perl process is using
> the CPU? Do the times mentioned match what you'd get with a stopwatch?
I'm not sure if Benchmark is capable of supervising child processes
off the top of my head. I probably need to take that into account and
just use straight clocktime and enough iterations to smooth out system
behaviour.
> - Might it be worth looking at some of the smaller files as well,
> possibly the time taken to open gzip is less significant on the large
> ones than the small ones?
Perhaps... most of the files are small, but I think most of the time
is spent on the few big files. And I also simply wanted to determine
which was faster at actual decompression. Still, a valid point.
> - Is there any way you can keep the gzip process open and only call it
> once to decompress multiple files? One fork is better than many
Hmm... I suppose I could use open2 to connect to both STDIN and STDOUT
and keep feeding it, but then I'd have to read the files myself into
the perl environment and print it out to the gzip process, which I'd
bet money will be slower. And there are too many files to build a
list and shove them onto a single command line. Man gzip reveals no
option for fetching a list of files from the command line.
------------------------------
Date: 28 Oct 2004 14:15:24 -0700
From: ofer@netapt.com (odigity)
Subject: Re: Compress::Zlib vs. external gzip call
Message-Id: <de652f7.0410281315.48060830@posting.google.com>
Sisyphus <kalinaubears@iinet.net.au> wrote in message news:<41805c6f$0$13768$5a62ac22@per-qv1-newsreader-01.iinet.net.au>...
> odigity wrote:
>
> > sub ext_gzip
> > {
> > my $fh = IO::File->new( "gzip -cd $file |" ) or die( "could not gzip
> > -cd '$file' for reading: $!" );
> > my $lines = 0;
> > while ( defined(my $line = $fh->getline()) ) {
> > $lines++;
> > }
> > $fh->close();
> > print "ext_gzip: $lines lines\n";
> > }
> >
> >
> > sub compress_zlib
> > {
> > my $gz = gzopen( $file, 'rb' ) or die( "could not gzopen '$file' for
> > reading: $!" );
> > my $line;
> > my $lines = 0;
> > while ( ( my $bytes = $gz->gzreadline( $line ) ) > 0 ) {
>
> The next line is a waste of time. If $bytes is -1 then the code inside
> the loop will not be executed. Also this is one test that the other
> subroutine doesn't have to do. I don't think, however, that it will
> account for the entire time difference .... remove it and see.
Yes; I rearranged my code a few times before settling on a pattern I
like, and that bug remained as a consequence. I don't think a scalar
comparison operation is going to have a noticeable effect relative to
the cost of reading from disk, decompressing data, and copying it
around in memory.
> I also wonder whether there is more overhead in determining whether
> $bytes>0 than there is determining whether $line is defined.
Benchmark it! :) But I don't think it matters here.
> And I don't know how 'getline()' and 'gzreadline()' compare - both in
> terms of what they actually do, and in terms of how fast they do it.
Yes, well... that's half the question.
-ofer
------------------------------
Date: 28 Oct 2004 14:15:52 -0700
From: ofer@netapt.com (odigity)
Subject: Re: Compress::Zlib vs. external gzip call
Message-Id: <de652f7.0410281315.5ecb2cc0@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<clqi1q$jfh$1@mamenchi.zrz.TU-Berlin.DE>...
> odigity <ofer@netapt.com> wrote in comp.lang.perl.misc:
> > I'm writing a script that needs to run in as fast a time as possible.
> > Every minute counts. The script crawls a tree of gzipped files
> > totalling about 30gb. Originally I was calling open() with "gzip
> > $file |", but I hate making external calls - it requires a fork, and
> > you have very limited communication with the process for catching
> > errors and such. I always like using perl functions and modules when
> > possible over external calls. However, I wanted to make sure I
> > wouldn't take a performance hit before switching to Compress::Zlib.
> >
> > I picked one of the bigger files (75mb) and ran some benchmarking on
> > it, comparing Compress::Zlib to an exernal call to the gzip utility.
> > Here's the code:
> >
> > #!/usr/bin/perl -w
> > use strict;
> > use Benchmark qw( cmpthese );
> > use Compress::Zlib;
> > use IO::File;
> >
> > my $file = 'sample.gz';
> >
> > print "warming up the file...\n";
> > system( "zcat $file > /dev/null" );
> >
> > print "starting comparison...\n";
> > cmpthese( 3, {
> > 'ext_gzip' => \&ext_gzip,
> > 'compress_zlib' => \&compress_zlib,
> > });
> >
> >
> > sub ext_gzip
> > {
> > my $fh = IO::File->new( "gzip -cd $file |" ) or die( "could not gzip
> > -cd '$file' for reading: $!" );
> > my $lines = 0;
> > while ( defined(my $line = $fh->getline()) ) {
> > $lines++;
> > }
> > $fh->close();
> > print "ext_gzip: $lines lines\n";
> > }
> >
> >
> > sub compress_zlib
> > {
> > my $gz = gzopen( $file, 'rb' ) or die( "could not gzopen '$file' for
> > reading: $!" );
> > my $line;
> > my $lines = 0;
> > while ( ( my $bytes = $gz->gzreadline( $line ) ) > 0 ) {
> > die( $gz->gzerror ) if ( $bytes == -1 );
> > $lines++;
> > }
> > $gz->gzclose();
> > print "compress_zlib: $lines lines\n";
> > }
> >
> > Here's the output:
> >
> > warming up the file...
> > starting comparison...
> > compress_zlib: 15185003 lines
> > compress_zlib: 15185003 lines
> > compress_zlib: 15185003 lines
> > (warning: too few iterations for a reliable count)
> > ext_gzip: 15185003 lines
> > ext_gzip: 15185003 lines
> > ext_gzip: 15185003 lines
> > (warning: too few iterations for a reliable count)
> > s/iter compress_zlib ext_gzip
> > compress_zlib 68.6 -- -23%
> > ext_gzip 52.8 30% --
> >
> > Now, this wasn't the best possible benchmarking test, but I still
> > think I am justified in being concerned.
>
> I'm afraid the benchmark is useless. Benchmark doesn't count the
> CPU time spent in children, so you're not catching the interesting
> part in ext_gzip.
You're probably right. I need to redo this and just use straight clock time.
-ofer
------------------------------
Date: Thu, 28 Oct 2004 19:15:43 +0000 (UTC)
From: "Stuart Carrison" <stuart--nospam--@carrison.co.uk.nospam>
Subject: cpan
Message-Id: <clrggv$cgl$1@titan.btinternet.com>
Hi folks,
Please excuse me I'm a serious noob....
I'm running Mandrake 7.2 on Sparc with Perl 5.6.0.
I need at least 5.6.1 to use razor and spamassassin, but I'm having problems
with RPMs - there just doesn't seem to be a precompiled version of 5.6.1 for
Sparc anymore (well, one that works anyway) and compiling isn't going well
either.
However, I've heard of this thing called CPAN, which I'm led to beleive can
be used to up-grade PERL.
Can someone confirm this and perhaps provide some _simple_ instructions for
me?
If this is the wrong NG I apologise but ask that you point me to the right
one.
Thanks all
Stuart
------------------------------
Date: Thu, 28 Oct 2004 19:47:54 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: cpan
Message-Id: <K1cgd.5370$9R4.3331@trndny09>
"Stuart Carrison" <stuart--nospam--@carrison.co.uk.nospam> wrote in
message news:clrggv$cgl$1@titan.btinternet.com...
> Please excuse me I'm a serious noob....
>
> I'm running Mandrake 7.2 on Sparc with Perl 5.6.0.
>
> I need at least 5.6.1 to use razor and spamassassin, but I'm having
problems
> with RPMs - there just doesn't seem to be a precompiled version of
5.6.1 for
> Sparc anymore (well, one that works anyway) and compiling isn't going
well
> either.
>
> However, I've heard of this thing called CPAN,
www.cpan.org
> which I'm led to beleive can be used to up-grade PERL.
perl is the program, Perl is the language. Not 'PERL'.
> Can someone confirm this and perhaps provide some _simple_
instructions for
> me?
CPAN is the "Comprehensive Perl Archive Network". It is (primarily) a
collection of modules for use in developing Perl programs. It is not
intended as a means to upgrade your local copy of perl. It does,
however, maintain a list of known binary and source distributions. I
reccomend reading this: http://www.cpan.org/ports/index.html#linux to
see if one of the pointers or links there is helpful to you.
Paul Lalli
------------------------------
Date: 28 Oct 2004 21:29:03 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: cpan
Message-Id: <Xns9590B1DBD3B47asu1cornelledu@132.236.56.8>
"Stuart Carrison" <stuart--nospam--@carrison.co.uk.nospam> wrote in
news:clrggv$cgl$1@titan.btinternet.com:
> Hi folks,
>
> Please excuse me I'm a serious noob....
>
> I'm running Mandrake 7.2 on Sparc with Perl 5.6.0.
>
> I need at least 5.6.1 to use razor and spamassassin, but I'm having
> problems with RPMs - there just doesn't seem to be a precompiled
> version of 5.6.1 for Sparc anymore (well, one that works anyway) and
> compiling isn't going well either.
>
> However, I've heard of this thing called CPAN, which I'm led to
> beleive can be used to up-grade PERL.
See http://faq.perl.org/perlfaq2.html, especially
http://faq.perl.org/perlfaq2.html#What_modules_and_ext
Sinan
------------------------------
Date: Thu, 28 Oct 2004 22:03:02 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 4.46: How do I handle linked lists?
Message-Id: <clrqam$mhd$1@reader1.panix.com>
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 Perl.
--------------------------------------------------------------------
4.46: How do I handle linked lists?
In general, you usually don't need a linked list in Perl, since with
regular arrays, you can push and pop or shift and unshift at either end,
or you can use splice to add and/or remove arbitrary number of elements
at arbitrary points. Both pop and shift are both O(1) operations on
Perl's dynamic arrays. In the absence of shifts and pops, push in
general needs to reallocate on the order every log(N) times, and unshift
will need to copy pointers each time.
If you really, really wanted, you could use structures as described in
perldsc or perltoot and do just what the algorithm book tells you to do.
For example, imagine a list node like this:
$node = {
VALUE => 42,
LINK => undef,
};
You could walk the list this way:
print "List: ";
for ($node = $head; $node; $node = $node->{LINK}) {
print $node->{VALUE}, " ";
}
print "\n";
You could add to the list this way:
my ($head, $tail);
$tail = append($head, 1); # grow a new head
for $value ( 2 .. 10 ) {
$tail = append($tail, $value);
}
sub append {
my($list, $value) = @_;
my $node = { VALUE => $value };
if ($list) {
$node->{LINK} = $list->{LINK};
$list->{LINK} = $node;
} else {
$_[0] = $node; # replace caller's version
}
return $node;
}
But again, Perl's built-in are virtually always good enough.
--------------------------------------------------------------------
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. All rights
reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
------------------------------
Date: Thu, 28 Oct 2004 15:37:20 -0400
From: "Xenos" <dont.spam.me@spamhate.com>
Subject: file tests
Message-Id: <clrhpo$9sd8@cui1.lmms.lmco.com>
Do file tests only works with statements of the form:
do_something if -e filename;
can't I do something like:
if -e filename
{
do several things here
}
It doesn't see to like this. What is the best way to do more than on
statement on a file test if? This seems klunky:
my exists = 0;
exists = 1 if -e filename;
if (exists)
{
do stuff
}
Thanks,
DrX
------------------------------
Date: Thu, 28 Oct 2004 15:53:51 -0400
From: "David Gale" <dsgSPAMFILTER@alum.dartmouth.org>
Subject: Re: file tests
Message-Id: <2ud0ttF27n4kdU1@uni-berlin.de>
Quoth Xenos <dont.spam.me@spamhate.com>:
> Do file tests only works with statements of the form:
>
> do_something if -e filename;
>
> can't I do something like:
>
> if -e filename
> {
> do several things here
> }
>
> It doesn't see to like this. What is the best way to do more than on
> statement on a file test if? This seems klunky:
Try proper parenthesizing. :-)
if( -e filename ) {
do several things here
}
------------------------------
Date: Thu, 28 Oct 2004 21:45:34 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: file tests
Message-Id: <2ud0uhF27m3v4U1@uni-berlin.de>
Xenos wrote:
> Do file tests only works with statements of the form:
>
> do_something if -e filename;
>
> can't I do something like:
>
> if -e filename
> {
> do several things here
> }
Which programming language are you dealing with? Post real code!!
> It doesn't see to like this.
How would we know when you haven't showed us real code. :(
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 28 Oct 2004 19:53:41 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: file tests
Message-Id: <97cgd.2022$CX4.1944@trndny06>
"Xenos" <dont.spam.me@spamhate.com> wrote in message
news:clrhpo$9sd8@cui1.lmms.lmco.com...
> Do file tests only works with statements of the form:
>
> do_something if -e filename;
No.
> can't I do something like:
>
> if -e filename
> {
> do several things here
> }
no, because that's not proper syntax. You're missing the parentheses.
> It doesn't see to like this.
That's a very poor error description. What results are you seeing? How
do they not match your expectations? What error messages are being
printed?
>What is the best way to do more than on
> statement on a file test if?
if (-e 'file.txt'){
#do thing 1
#do thing 2
}
> This seems klunky:
>
> my exists = 0;
> exists = 1 if -e filename;
> if (exists)
> {
> do stuff
> }
Yes, it does. There's no reason to do anything like that. Furthermore,
that is also not valid syntax.
Have you read the Posting Guidelines that are posted twice weekly? They
ask you to please post a *short but complete* script which demonstrates
the problem you're having.
Paul Lalli
------------------------------
Date: 28 Oct 2004 20:05:33 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: goto (was browser output)
Message-Id: <slrnco2k8d.3ac.abigail@alexandra.abigail.nl>
Tintin (tintin@invalid.invalid) wrote on MMMMLXXVI September MCMXCIII in
<URL:news:2ubo3fF27cah6U1@uni-berlin.de>:
^^
^^ I notice that File::Compare and File::Copy both make extensive use of goto
^^ LABEL.
^^
^^ Anyone care to comment on whether it's really needed in these modules?
It's not really needed. But I don't understand the question.
I've noticed that File::Copy makes extensive use of 'while' and
lexical variables. Anyone care to comment on whether it's really
needed in these modules?
Almost any construct is not "really needed", because there's always
another way to do the same thing.
Abigail
--
:;$:=~s:
-:;another Perl Hacker
:;chop
$:;$:=~y:;::d;print+Just.$:
------------------------------
Date: 28 Oct 2004 20:09:00 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: goto (was browser output)
Message-Id: <slrnco2kes.3ac.abigail@alexandra.abigail.nl>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMMLXXVI
September MCMXCIII in <URL:news:clqm9i$m3q$1@mamenchi.zrz.TU-Berlin.DE>:
//
// The question is not if it's needed, but if it is used reasonably.
//
// Goto is evil when used as the primary means of flow control. At the
// time Dijkstra mounted his campaign against "goto", there were
// languages (most notably Fortran), that *had* no other large-scale
// flow control ("if" only worked on one statement). That used to make
// a mess of programs. The campaign wasn't so much against the use of
// "goto" by individual programmers (they often had no choice), but
// to foster the design of "structured" languages that didn't force
// "goto" upon their users.
//
// These days there are no more mainstream languages that aren't
// "structured", so nobody talks about "structured programming" anymore,
// but everyone does it. In that framework, the occasional "goto" is
// no big deal, and it can be the operation of choice.
Let me also point to Donald Knuths "Structured Programming with goto
Statements", where he shows that using goto and structured programming
aren't multiple exclusive.
Abigail
--
A perl rose: perl -e '@}-`-,-`-%-'
------------------------------
Date: Thu, 28 Oct 2004 18:29:03 GMT
From: none <none@nowhere.invalid>
Subject: How can I change a Perl floating-point value to a bit vector?
Message-Id: <PTagd.2366$eU2.1381@trndny05>
I'd like to do bit manipulation on Perl floating-point values. Is there
any way that I can get the floating-point values into some sort of bit
vector?
Thanks,
-Mike
------------------------------
Date: 28 Oct 2004 18:48:52 GMT
From: ctcgag@hotmail.com
Subject: Re: How can I change a Perl floating-point value to a bit vector?
Message-Id: <20041028144852.854$3q@newsreader.com>
none <none@nowhere.invalid> wrote:
> I'd like to do bit manipulation on Perl floating-point values. Is there
> any way that I can get the floating-point values into some sort of bit
> vector?
>
my @x = unpack "b*", pack "d", 1/3;
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 28 Oct 2004 14:42:16 -0500
From: Allen Windhorn <Allen.Windhorn@LSUSA.com>
Subject: Re: How to get an image file and display it on the screen?
Message-Id: <ur7niwrxj.fsf@LSUSA.com>
Thanks to all for the helpful suggestions. I knew about TK -- just
didn't think of it in this context.
Regards,
Allen
--
Allen Windhorn (507) 345-2782 FAX (507) 345-2805
Kato Engineering (Though I do not speak for Kato)
P.O. Box 8447, N. Mankato, MN 56002
Allen.Windhorn@LSUSA.com
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7333
***************************************