[22982] in Perl-Users-Digest
Perl-Users Digest, Issue: 5202 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 9 21:33:13 2003
Date: Wed, 9 Jul 2003 18:30:57 -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 Wed, 9 Jul 2003 Volume: 10 Number: 5202
Today's topics:
Re: oneliner failed on Win2k with space in path name <bwalton@rochester.rr.com>
Re: Perl 5.8.0 compilation fails in chrooted environmen <nospam-abuse@ilyaz.org>
Perl Coverage (Himal)
Re: Perl Coverage <bart.lateur@pandora.be>
Perl debugger no longer lets me arrow up and down <jaspax@u.washington.edu>
Re: Perl debugger no longer lets me arrow up and down <cc@zazou.demon.co.uk>
Re: Perl debugger no longer lets me arrow up and down <jaspax@u.washington.edu>
Perl Logic Required (Go Perl)
Re: Perl Logic Required <emschwar@pobox.com>
Re: Perl Logic Required <kkeller-spammmm@wombat.san-francisco.ca.us>
Re: Perl Logic Required <dover@nortelnetworks.com>
Re: Perl Logic Required <eric-amick@comcast.net>
Re: Perl Logic Required (Helgi Briem)
Re: Perl Logic Required <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Re: perl restaurant menu (John D)
perl Script error (Go Perl)
Re: perl Script error <john.thetenant-s@moving-picture.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 09 Jul 2003 00:05:57 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: oneliner failed on Win2k with space in path name
Message-Id: <3F0B5C5B.6040004@rochester.rr.com>
Yang, Xu wrote:
[from a private email correspondence]:
> Sorry Bob for my careless, I did cut and pasted my code, unfortunately, my
> cut missed the single quote at the end of the first line.
> The problem does come from the perl's capability to handle long file name
> when space presents.
> I can prove this by replacing "program files" with "progra~1", which is 8.3
> formatted. The *.tt are files I put there for testing purpose.
> I have seen the Win32::GetShortName() but not in my old version perl
> package. Anyway, I end up with using the short name as
> a work around.
Oh, yeah, the Win32 command "shell" doesn't expand wildcard filenames
like most Unix shells do. You'll have to do that inside Perl yourself.
Something like @ARGV=<$ARGV[0]>; I suppose, then proceed to read from
<>. I missed that first time through. But I see that that doesn't work
either if the path contains a space character. Apparently the Windoze
implementation of glob() doesn't handle paths containing spaces?
This may be seen by executing:
perl -e "@files=glob('c:/program files/*.tt');print @files;"
Actually, that behavior is documented in the File::Glob module, and will
occur on other OS's too [untested on other than Windoze 98SE]. You can
use File::Glob qw(:glob);
and then:
@ARGV=bsd_glob($ARGV[0]);
to get your list of expanded filenames, the path to which contains
spaces, ready for while(<>){...}. But by now the one-liner has become
too long for Windoze's lousy command "shell". Bummer.
But I see that introducing a Unix-style quote of the space will fix the
problem. So if you do:
perl -e "@ARGV=<$ARGV[0]>;while(<>){print '#'.$_.qq(\n)}"
"c:/program\ files/*.tt"
[above all one line]
it will work. I note that it does *not* work, however, if you use the
Windoze style "c:\program\ files\*.tt" for an argument, not sure why.
The Windoze-style "'s around the argument file specification remain
required, however.
Bleaugh. But that's probably better than DOS 8.3 filenames.
>
> Xu
>
> -----Original Message-----
> From: Bob Walton [mailto:bwalton@rochester.rr.com]
> Sent: Monday, July 07, 2003 7:45 PM
> To: Xu Yang
> Subject: Re: oneliner failed on Win2k with space in path name
>
> Xu Yang wrote:
>
> ...
>
>
>
>>I have an oneliner Perl script (see below) works fine when the path
>>name is 8.3 format on Win2K, but failed after it operated on a path
>>name contains space:
>>
>>c:\perl -e "while(<>) {if(/^define/){print $ARGV.#'.$_;}}" c:\usr\*.tt
>>
>
> '--------------------------------------------------^
> *please* copy/paste working code, don't just type it in -- the above as
> given doesn't compile because the # is seen as the start of a Perl
> comment, resulting in unbalanced braces. I assume it should be ...'#'...
>
>
>
>>If I change the "c:\usr" to "c:\program files", it failed with error:
>>Can't open c:\program files\*.tt.
>>I double quote the path, did not help either.
>>
>>Is this because the old version (5.x) of perl I am using?
>>
>>
>>Xu
>>
>>
>
> Your error message indicates that the command "shell" got the correct
> filename, but that such a file was not actually present. Check in your
> "c:\program files" directory and see if there are any *.tt files in that
> directory. Usually, there aren't any files in that directory -- only
> additional subdirectories. The problem should have nothing to do with
> your version of Perl, and, in fact, doesn't appear to be a Perl problem
> at all.
>
>
--
Bob Walton
------------------------------
Date: Tue, 8 Jul 2003 16:11:22 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Perl 5.8.0 compilation fails in chrooted environment
Message-Id: <beeqfa$1lk4$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Bernie Cosell
<bernie@fantasyfarm.com>], who wrote in article <geelgv8qrg9iotr6brc8smbnb0ggomqcnp@library.airnews.net>:
> } If `pwd' works, try replacing Cwd.pm with
> }
> } package Cwd;
> } sub cwd { my $p = `pwd`; chop $p; $p }
> } 1;
>
> Meta-question: why use 'chop' instead of 'chomp'?
How do you know the current value of $/? chomp() has very little
usefulness in modules...
> Isn't there a danger on a system that returns \r\n that chop will
> leave the \r?
Perl's line end is \n. Do not see how system comes into consideration here...
Hope this helps,
Ilya
------------------------------
Date: 9 Jul 2003 06:00:17 -0700
From: himal5@hotmail.com (Himal)
Subject: Perl Coverage
Message-Id: <365e1935.0307090500.44222b8c@posting.google.com>
Hi All,
What is the best way of doing code coverage in perl ?
What is the difference between Devel::Coverage and Devel::Cover ?
Any help and info will be very useful ?
Cheers,
Himal.
------------------------------
Date: Wed, 09 Jul 2003 14:28:25 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl Coverage
Message-Id: <f39ogv4u4i3q414c8fqhil04aka3ritlms@4ax.com>
Himal wrote:
>What is the best way of doing code coverage in perl ?
>What is the difference between Devel::Coverage and Devel::Cover ?
>Any help and info will be very useful ?
Check bian d foy's articles about this subject in DDJ. They can be read
online, for free.
<http://www.ddj.com/columns/perl/2001/>
I don't know anything about Devel::Cover, but the last line on this
slide:
<http://homepage.hispeed.ch/pjcj/testing_and_code_coverage/slide066.html>
doesn't make it look too good.
OTOH, since then, the most recent version of this module has moved up a
few notches. :)
--
Bart.
------------------------------
Date: Tue, 8 Jul 2003 18:33:55 -0700
From: JS Bangs <jaspax@u.washington.edu>
Subject: Perl debugger no longer lets me arrow up and down
Message-Id: <Pine.A41.4.55.0307081830030.90668@dante18.u.washington.edu>
This may very well be an OS problem, in which case I'll humbly accept your
suggestions to go elsewhere with it.
In the meantime: the perl debugger no longer lets me use the up and down
arrow keys to page through my history. Instead, I get lovely bits of ^[[A
and ^[[B. This started after I upgraded from v5.6.1 to v5.8 (possibly
upgrading/messing up the debugger?). Is there a config file somewhere I
can fix?
History arrows still work as expected in bash and mysql, making me think
that it's *not* an OS problem. TIA--
Jesse S. Bangs jaspax@u.washington.edu
------------------------------
Date: Wed, 9 Jul 2003 03:49:50 +0000 (UTC)
From: Colin Campbell <cc@zazou.demon.co.uk>
Subject: Re: Perl debugger no longer lets me arrow up and down
Message-Id: <slrnbgn46t.nd.cc@ze.zazou.org>
In article <Pine.A41.4.55.0307081830030.90668@dante18.u.washington.edu>,
JS Bangs wrote:
>
> In the meantime: the perl debugger no longer lets me use the up and down
> arrow keys to page through my history. Instead, I get lovely bits of ^[[A
> and ^[[B. This started after I upgraded from v5.6.1 to v5.8 (possibly
> upgrading/messing up the debugger?). Is there a config file somewhere I
> can fix?
I think you might be missing the Term::Readline module off CPAN.
Colin
------------------------------
Date: Wed, 9 Jul 2003 00:29:03 -0700
From: JS Bangs <jaspax@u.washington.edu>
Subject: Re: Perl debugger no longer lets me arrow up and down
Message-Id: <Pine.A41.4.55.0307090027580.103928@dante18.u.washington.edu>
Colin Campbell sikyal:
> In article <Pine.A41.4.55.0307081830030.90668@dante18.u.washington.edu>,
> JS Bangs wrote:
> >
> > In the meantime: the perl debugger no longer lets me use the up and down
> > arrow keys to page through my history. Instead, I get lovely bits of ^[[A
> > and ^[[B. This started after I upgraded from v5.6.1 to v5.8 (possibly
> > upgrading/messing up the debugger?). Is there a config file somewhere I
> > can fix?
> I think you might be missing the Term::Readline module off CPAN.
Isn't that part of the standard Perl library?
In any case, I went to install it, and CPAN said it wanted an upgrade. So
I did that, which automatically upgraded/reinstalled Term::ReadLine, which
fixed the problem.
Thanks!
Jesse S. Bangs jaspax@u.washington.edu
------------------------------
Date: 8 Jul 2003 13:41:35 -0700
From: puissant00@yahoo.com (Go Perl)
Subject: Perl Logic Required
Message-Id: <d3825316.0307081241.4070aacf@posting.google.com>
Guys,
I am having a problem with implementing a simple logic in Perl. The
following is
a file containing the following numbers..
200 11 36.5
11 12 43.5
12 212 78.9
213 45 56.9
45 46 66.8
46 47 88.0
47 48 89.9
48 49 7.8
49 215 8.9
Now i want to add up all the numbers between (200,212) and (213,215)
and so on.
The numbers i want to add up is the third column for example for
200-212 i want to add 36.5,43.5,78.9. And i want to add up stuff only
if the first column starts with 200 series numbers and the second
column starts with 200 series numbers.
Help Appreciated.
thanks in advance
------------------------------
Date: 08 Jul 2003 14:51:14 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Perl Logic Required
Message-Id: <etoof04agjh.fsf@wormtongue.emschwar>
puissant00@yahoo.com (Go Perl) writes:
> I am having a problem with implementing a simple logic in Perl. The
> following is a file containing the following numbers..
>
> 200 11 36.5
> 11 12 43.5
> 12 212 78.9
> 213 45 56.9
> 45 46 66.8
> 46 47 88.0
> 47 48 89.9
> 48 49 7.8
> 49 215 8.9
>
> Now i want to add up all the numbers between (200,212) and (213,215)
> and so on.
> The numbers i want to add up is the third column for example for
> 200-212 i want to add 36.5,43.5,78.9. And i want to add up stuff only
> if the first column starts with 200 series numbers and the second
> column starts with 200 series numbers.
This is very confusing. You really need to stop and think clearly
about what it is you're trying to do, and explain it better. As it
is, from your description, I can only assume you wouldn't add up *ANY*
of the numbers in the third column of the file.
Using my PSI::ESP module, I guess that you have a file which defines a
set of records. Each set starts with a number of the form '2xx' in
the first column. The second column of that row contains the number
in the first column of the next entry in that set. When the number in
second column is of the form '2xx', then the set is over, and you
should record the start and end numbers of the set, and the total of
the numbers in the third column of each entry in the set, and start
over.
But that's only a guess. Please try to be clearer about what you're
asking for.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Tue, 8 Jul 2003 15:01:05 -0700
From: Keith Keller <kkeller-spammmm@wombat.san-francisco.ca.us>
Subject: Re: Perl Logic Required
Message-Id: <1vefeb.00h.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In article <etoof04agjh.fsf@wormtongue.emschwar>, Eric Schwartz wrote:
>
> Using my PSI::ESP module,
Will this module be on CPAN anytime soon? :)
- --keith
- --
kkeller-mmmspam@wombat.san-francisco.ca.us
(try just my userid to email me)
alt.os.linux.slackware FAQ: http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAj8LPyAACgkQhVcNCxZ5ID87wQCdFYnNN/VdBPUFFSMOH4BDOHOT
ulIAn1ejWQkGHgbWyAMOTVyc88s09Wy/
=Skwa
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 8 Jul 2003 17:07:23 -0500
From: "Bob Dover" <dover@nortelnetworks.com>
Subject: Re: Perl Logic Required
Message-Id: <beff7h$8qs$1@zcars0v6.ca.nortel.com>
"Go Perl" wrote...
>
> I am having a problem with implementing a simple logic in Perl.
Care to show us what you've tried?
-BD
------------------------------
Date: Tue, 08 Jul 2003 18:47:50 -0400
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: Perl Logic Required
Message-Id: <35hmgvgc2jg7m9hfd088v85agt5gk4lkss@4ax.com>
On 8 Jul 2003 13:41:35 -0700, puissant00@yahoo.com (Go Perl) wrote:
>Guys,
>I am having a problem with implementing a simple logic in Perl. The
>following is
>a file containing the following numbers..
>
>200 11 36.5
>11 12 43.5
>12 212 78.9
>213 45 56.9
>45 46 66.8
>46 47 88.0
>47 48 89.9
>48 49 7.8
>49 215 8.9
>
>Now i want to add up all the numbers between (200,212) and (213,215)
>and so on.
>The numbers i want to add up is the third column for example for
>200-212 i want to add 36.5,43.5,78.9. And i want to add up stuff only
>if the first column starts with 200 series numbers and the second
>column starts with 200 series numbers.
I tested with your sample data; it should be extremely close. I assumed
that the values in the first and second columns would never exceed 299.
my ($i, $total, @columns);
while (<>) {
chomp(@columns = split);
if ($i = ($columns[0] >= 200) .. ($columns[1] >= 200)) {
$total += $columns[2];
if ($i =~ /E0$/) {
# end-of-range processing here
$total = 0;
}
}
}
See perldoc perlop, paying particular attention to the range operators.
--
Eric Amick
Columbia, MD
------------------------------
Date: Wed, 09 Jul 2003 10:08:49 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl Logic Required
Message-Id: <3f0be98f.1385686718@news.cis.dfn.de>
On Tue, 8 Jul 2003 15:01:05 -0700, Keith Keller
<kkeller-spammmm@wombat.san-francisco.ca.us> wrote:
>In article <etoof04agjh.fsf@wormtongue.emschwar>, Eric Schwartz wrote:
>>
>> Using my PSI::ESP module,
>
>Will this module be on CPAN anytime soon? :)
It's always been there, but you need to be
psychic to find out where.
------------------------------
Date: Wed, 9 Jul 2003 13:33:29 +0100
From: "Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Subject: Re: Perl Logic Required
Message-Id: <beh20r$6qs$1$8300dec7@news.demon.co.uk>
"Go Perl" <puissant00@yahoo.com> wrote in message
news:d3825316.0307081241.4070aacf@posting.google.com...
> Guys,
> I am having a problem with implementing a simple logic in Perl.
<SNIP>
> Now i want to add up all the numbers between (200,212) and (213,215)
> and so on.
How strange..
I've had no problem implementing this at all.
------------------------------
Date: 8 Jul 2003 10:25:47 -0700
From: johndageek@yahoo.com (John D)
Subject: Re: perl restaurant menu
Message-Id: <c608545f.0307080925.458c0db1@posting.google.com>
Mark Reed <mreed@reedassociates.com> wrote in message news:<Xns93B1C8BA3E302mreedreedassociatesc@216.168.3.44>...
> Does anyone have a perl script that can be used to manage an online
> restaurant menu?
>
> Im looking for examples to study and cant find any on the net at the
> popular archives.
>
> thanks
Please take a shot at it and we can help you out with any perl
probelms you may encounter.
A little more definition might help also.
"Manage an online resteraunt menu"
-do you want code to run an online store?
-do you want code to display a menu only
-do you want a page to be displayed based upon a database
(implying a method to maintain the database entries)
-do you have experience with databases, cgi, javascript and web
servers?
Good luck
JD
------------------------------
Date: 9 Jul 2003 08:08:06 -0700
From: puissant00@yahoo.com (Go Perl)
Subject: perl Script error
Message-Id: <d3825316.0307090708.4d966280@posting.google.com>
Thanks Eric Avick for helping me here
The following is the perl script which is not giving out any output
open (TT_FILE, ">sample.txt");
while ($tt_line=<TT_FILE>) {
chop($tt_line);
my $i;
my $total;
@columns = split(/ +/, $tt_line);
if ($i = ($columns[0] >= 700) .. ($columns[1] >= 700)) {
$total += $columns[2];
if ($i =~ /E0$/) {
# end-of-range processing here
$total = 0;
}
print "$total\n";
}
}
close(TT_FILE);
my sample.txt file is the following
711 12 100
12 13 80
13 14 90
14 714 85
714 15 90
15 16 45
16 17 55
17 18 50
18 19 45
19 20 56
20 21 45
21 22 34
22 23 78
23 723 87
723 24 45
24 25 34
25 26 45
26 27 65
27 28 23
28 29 23
29 729 44
729 30 77
30 31 67
31 32 87.4
32 33 56.9
33 34 66.1
34 35 45.5
35 36 78.4
36 37 76.8
37 38 2.8
38 738 6.9
when i am executing this script, i am not getting any output, where as
it is supposed to print the sum of numbers between two pairs of 7xx
series numbers from first column and second column.
------------------------------
Date: Wed, 9 Jul 2003 16:53:36 +0100
From: John Strauss <john.thetenant-s@moving-picture.com>
Subject: Re: perl Script error
Message-Id: <20030709165336.33597670.john.thetenant-s@moving-picture.com>
On 9 Jul 2003 08:08:06 -0700
puissant00@yahoo.com (Go Perl) wrote:
>
> Thanks Eric Avick for helping me here
> The following is the perl script which is not giving out any output
>
> open (TT_FILE, ">sample.txt");
> while ($tt_line=<TT_FILE>) {
on the previous two lines, it looks like you are opening
a file for writing, then trying to read from the filehandle.
if i'm not making sense to you, read "perldoc -f open"
use warnings; #this would have warned you about this.
you are also not handling open() errors.
perhaps you'd have been better off with:
use warnings;
open (TT_FILE, "<sample.txt") or die "cannot open sample.txt, '$!'\n";
> chop($tt_line);
minor point: use chomp() instead of chop()
> my $i;
> my $total;
> @columns = split(/ +/, $tt_line);
> if ($i = ($columns[0] >= 700) .. ($columns[1] >= 700)) {
wow, that's a strange one, mate.
> $total += $columns[2];
> if ($i =~ /E0$/) {
> # end-of-range processing here
> $total = 0;
> }
> print "$total\n";
> }
> }
> close(TT_FILE);
you should change your indentation style for readability.
>
> my sample.txt file is the following
> 711 12 100
> 12 13 80
> 13 14 90
> 14 714 85
> 714 15 90
> 15 16 45
> 16 17 55
> 17 18 50
> 18 19 45
> 19 20 56
> 20 21 45
> 21 22 34
> 22 23 78
> 23 723 87
> 723 24 45
> 24 25 34
> 25 26 45
> 26 27 65
> 27 28 23
> 28 29 23
> 29 729 44
> 729 30 77
> 30 31 67
> 31 32 87.4
> 32 33 56.9
> 33 34 66.1
> 34 35 45.5
> 35 36 78.4
> 36 37 76.8
> 37 38 2.8
> 38 738 6.9
>
> when i am executing this script, i am not getting any output, where as
> it is supposed to print the sum of numbers between two pairs of 7xx
> series numbers from first column and second column.
i can't say i understand what you want, but i doubt you'll
get it even if you fix your open() call. it would help *me*
if you gave an example of the output you expect (though i
grant that smarter news readers may have divined your intent.)
from what i see, you never add anything to $total apart from
entries in the third column, and you scope $total everytime
you read a line from TT_FILE, so i don't see how you get a sum.
maybe you want to move "mt $total;" outside your while() block?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drop the .thetenant to get me via mail
------------------------------
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 5202
***************************************