[23523] in Perl-Users-Digest
Perl-Users Digest, Issue: 5732 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 31 03:05:51 2003
Date: Fri, 31 Oct 2003 00:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 31 Oct 2003 Volume: 10 Number: 5732
Today's topics:
Re: DBI problems: from MySQL to Access <usenet@morrow.me.uk>
Re: DHCP client tool (Peter Lohmeier)
Re: difference between defined & exists <grazz@pobox.com>
Re: difference between defined & exists <usenet@morrow.me.uk>
Re: DOS window. <syscjm@gwu.edu>
Re: Fastest Perl Interpreter <trevie@cox.net>
Re: Logic Flow Question <usenet@morrow.me.uk>
Re: Perl Cut Command <me@privacy.net>
Re: Perl Cut Command (Charles DeRykus)
Re: Perl Cut Command <grazz@pobox.com>
Re: Perl Cut Command <usenet@morrow.me.uk>
Reading from XML <member46479@dbforums.com>
Re: Reading from XML <mgjv@tradingpost.com.au>
Re: Script Help <usenet@morrow.me.uk>
Re: ssh2+checksum+ perl module ? <jwillmore@remove.adelphia.net>
Re: strange effect with [:lower:] in perl <usenet@morrow.me.uk>
Re: Video::Capture example? <stanb@panix.com>
Re: Video::Capture example? <stanb@panix.com>
Re: What am I doing wrong?! <tore@aursand.no>
Re: What am I doing wrong?! <usenet@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 31 Oct 2003 00:01:36 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: DBI problems: from MySQL to Access
Message-Id: <bns8p0$cv1$3@wisteria.csv.warwick.ac.uk>
"joe" <tunmaster@hotmail.com> wrote:
> My question: is there a possibillity to use the exact same queries on
> Windows as on UNIX?
As a general rule, (more complex) SQL isn't portable between different
implementations. Such is life with standards <sigh>.
If it is easier than rewriting your SQL, you could install MySQL on
your windows box and use that.
> I tried installing Win32::ODBC but didn't get far. Is Win32::ODBC my
> promised land?
Not if the problem is that Access doesn't understand the same SQL as
MySQL.
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: 30 Oct 2003 19:13:43 -0800
From: pelohh@compuserve.de (Peter Lohmeier)
Subject: Re: DHCP client tool
Message-Id: <ebbdbbfe.0310301913.7989ae53@posting.google.com>
Ben Morrow <usenet@morrow.me.uk> wrote in message news:<bns37b$afn$3@wisteria.csv.warwick.ac.uk>...
> pelohh@compuserve.de (Peter Lohmeier) wrote:
> > But I'm not shure wether it works with my Active State Perl
> > Answer to "perl -v" is
> > "This is perl, version 5.005_03 built for MSWin32-x86-object
> > ......."
>
> That's very old... are you unable to upgrade for some reason?
>
> Ben
Ok. On other PC I get:
c:\work-prl>perl -v
This is perl, v5.8.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
But actually I don't use perl with linux, and I have no experience to
work with CPAN Modules.
And there is absolutely no hint to DHCP in the installed folders.
.pl
------------------------------
Date: Thu, 30 Oct 2003 23:50:03 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: difference between defined & exists
Message-Id: <Lshob.47733$1C5.23791@nwrdny02.gnilink.net>
Ben Morrow <usenet@morrow.me.uk> wrote:
> Is exists() not still useful for an array element, with exists($a[$n])
> being equivalent to ($n < @a)?
Those aren't exactly equivalent:
my @x;
$x[1] = undef;
$#x = 2;
for (0..3) {
printf "x[%d] %s\n", $_,
exists $x[$_] ? "exists" : "doesn't"
}
-------
x[0] doesn't
x[1] exists
x[2] doesn't
x[3] doesn't
--
Steve
------------------------------
Date: Fri, 31 Oct 2003 00:03:18 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: difference between defined & exists
Message-Id: <bns8s6$cv1$4@wisteria.csv.warwick.ac.uk>
Steve Grazzini <grazz@pobox.com> wrote:
> Ben Morrow <usenet@morrow.me.uk> wrote:
> > Is exists() not still useful for an array element, with exists($a[$n])
> > being equivalent to ($n < @a)?
>
> Those aren't exactly equivalent:
No, but they ought to be. The only reason they're not is to make
pseudohashes work.
Ben
--
I've seen things you people wouldn't believe: attack ships on fire off the
shoulder of Orion; I've watched C-beams glitter in the darkness near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die. |-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-| ben@morrow.me.uk
------------------------------
Date: Thu, 30 Oct 2003 20:08:50 -0500
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: DOS window.
Message-Id: <3FA1B622.4020904@gwu.edu>
Ben Morrow wrote:
> "Richard S Beckett" <spikeywan@bigfoot.com.delete.this.bit> wrote:
>
>>It's a shame that microsoft not supporting their own hardware
>
>
> Err.. I don't think Microsoft are a hardware company... :)
>
<Looks at Microsoft mouse>
<Looks at Microsoft keyboard>
<Looks at Microsoft joystick>
They aren't?
Chris Mattern
------------------------------
Date: Thu, 30 Oct 2003 16:49:46 -0700
From: "Michael J. Astrauskas" <trevie@cox.net>
Subject: Re: Fastest Perl Interpreter
Message-Id: <oshob.85146$vj2.15995@fed1read06>
Peter Cooper wrote:
> If you could elaborate on your 'intense amount of network and processor
> work' we might be able to narrow things down a bit. For example, your
> process might not be memory intensive, meaning money saved there could go
> into other areas of the system architecture.
The task is basically a head NNTP server. It will be balancing incoming
loads to various other servers on the network. Apparently CPU isn't so
important as network i/o.
> I'd also echo the comments of another respondant, and recommend you look
> into producing a compiled version of whatever it is you want to do. The
> increased power would, in most cases, pay for itself if the project is over
> a certain length, unless the application is too complex.
It's for a contest, more or less, so I can't choose what the task is.
It's a Perl script not written by myself.
--
- Michael J. Astrauskas
------------------------------
Date: Fri, 31 Oct 2003 00:08:57 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Logic Flow Question
Message-Id: <bns96p$cv1$5@wisteria.csv.warwick.ac.uk>
jrolandumuc@yahoo.com (JR) wrote:
> I'm having trouble understanding the logic flow of recipe 4.3 in the
> Perl Cookbook (the below script is only slightly different from the
> recipe in the Cookbook), and am hoping someone can clarify it for me.
>
> Here's where I'm confused:
>
> In the below permute subroutine, I don't understand how the $i
> variable can ever reach 1 and 2.
>
> use strict;
> use warnings;
>
> my @array = ('A'..'C');
>
> permute([@array]);
> sub permute {
> my @items = @{ $_[0] };
> my @perms = @{ $_[1] } if defined @{ $_[1] };
> if (!@items) {
> print "\@perms=@perms\n";
> }
> else {
> my (@newitems, @newperms);
> my $i = 0;
Did you add this line?
> for my $i (0..$#items) {
The 'my' here makes this create a new variable called $i, masking the
old one, which now counts up from 0 to $#items. The old $i from the
line above is never incremented, but neither is it ever printed.
If you want access to the loop variable outside the loop, remove the
'my'.
> print "\$i=$i\n";
> @newitems = @items;
> @newperms = @perms;
> ## Splice @newitems element and prepend it to @newperms
> unshift(@newperms, splice(@newitems, $i, 1));
> permute([@newitems], [@newperms]);
> }
> }
> }
>
> __END__
Ben
--
If you put all the prophets, | You'd have so much more reason
Mystics and saints | Than ever was born
In one room together, | Out of all of the conflicts of time.
ben@morrow.me.uk |----------------+---------------| The Levellers, 'Believers'
------------------------------
Date: Fri, 31 Oct 2003 14:19:53 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: Perl Cut Command
Message-Id: <bnsdhm$159h3b$1@ID-172104.news.uni-berlin.de>
"Michael Zawrotny" <zawrotny@jaguar.sb.fsu.edu> wrote in message
news:slrnbq2p68.48c.zawrotny@jaguar.sb.fsu.edu...
> On Thu, 30 Oct 2003 18:52:10 GMT, Buck Turgidson <jc_va@hotmail.com>
wrote:
> > > 21-40, and just print 1-20 and 21 thru 60 on a line.
> >
> > That should read "just print 1-20 and 41 thru 60 on a line"
>
> You could try "cut -b1-20,41-60".
$ perldoc -f cut
No documentation for perl function 'cut' found
------------------------------
Date: Fri, 31 Oct 2003 01:06:15 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Perl Cut Command
Message-Id: <HnLKEF.GC9@news.boeing.com>
In article <2b80f0b4eb23d637d017ded1a65e79a0@news.teranews.com>,
Buck Turgidson <jc_va@hotmail.com> wrote:
>I have a file of data that is 60 bytes long. I want to cut (remove) bytes
>21-40, and just print 1-20 and 21 thru 60 on a line.
>
>The Unix cut command does the opposite of what I want. "cut --bytes=21-40"
>returns those bytes, but I want to remove them.
>
>Is there a simple perl one-liner that will remove them?
>
>
perl -nle 'print /(.{20}).{40}(.*)/' <file>
--
Charles DeRykus
------------------------------
Date: Fri, 31 Oct 2003 02:31:49 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Perl Cut Command
Message-Id: <pQjob.40008$4O1.5168@nwrdny01.gnilink.net>
David K. Wall <usenet@dwall.fastmail.fm> wrote:
> Buck Turgidson <jc_va@hotmail.com> wrote:
> > That should read "just print 1-20 and 41 thru 60 on a line"
>
> perl -ne "print substr($_,0,20), substr($_,40,20)" filename
perl -pe 'substr($_, 20, 20, "")' filename
--
Steve
------------------------------
Date: Fri, 31 Oct 2003 07:19:57 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Perl Cut Command
Message-Id: <bnt2et$ks9$1@wisteria.csv.warwick.ac.uk>
"Buck Turgidson" <jc_va@hotmail.com> wrote:
> > 21-40, and just print 1-20 and 21 thru 60 on a line.
> >
>
> That should read "just print 1-20 and 41 thru 60 on a line"
perl -ne'BEGIN { $/ = \1 } print if $. < 21 or $. > 40'
perl -ne'print ((unpack "a"x60, $_)[0..19,40..59])'
perl -ne'print unpack "a20x20a20", $_'
perl -pe'pos = 21; s/\G.{20}//'
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Thu, 30 Oct 2003 23:44:08 -0500
From: newtoxml <member46479@dbforums.com>
Subject: Reading from XML
Message-Id: <3544140.1067575448@dbforums.com>
Please help!!!! I can't figure out how to read from xml.
I have my SQL in XML file like this:
<report>
....
.... more code
</report>
/* This is what I am trying to read */
<statements>
<sql name="MyDailyQuery">
SELECT title, count(id_number) as total
from table_title,
table_tickets
where table_title.id = table_tickets.id
and table_title.name = '<param name="project"/>')
</sql>
</statements>
I am trying to read the SQL from xml file, put the parameter value(from
the user input) in the attribute of the SQL (= '<param
name="project"/>') ) so that I can use executeQuery() to run the query
in the database.
And possible right the ResultSet value back to the xml file.
--
Posted via http://dbforums.com
------------------------------
Date: 31 Oct 2003 05:25:06 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Reading from XML
Message-Id: <slrnbq3shl.ppp.mgjv@verbruggen.comdyn.com.au>
On Thu, 30 Oct 2003 23:44:08 -0500,
newtoxml <member46479@dbforums.com> wrote:
>
> Please help!!!! I can't figure out how to read from xml.
http://search.cpan.org/search?query=xml&mode=module
HTH.
Martien
--
|
Martien Verbruggen | The four horsemen of the apocalypse are
Trading Post Australia | called Abort, Retry, Ignore and Fail.
|
------------------------------
Date: Thu, 30 Oct 2003 23:57:42 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Script Help
Message-Id: <bns8hm$cv1$2@wisteria.csv.warwick.ac.uk>
Jim Gibson <jgibson@mail.arc.nasa.gov> wrote:
> In article <vifob.37757$4O1.28090@nwrdny01.gnilink.net>, Kev
> <karigna@verizon.net> wrote:
>
> > I'm writing a script that is part of a larger script to index a
> > defined list of websites. The portion that I'm working on is used
> > to find all pages ending in .htm / .html so that I can search
> > those pages and index them. I got the script to map out all the
> > links. Can anyone help in eliminating the non .htm / html links
> > obtained?
<snip>
>
> You can accept only URLs with '.htm' in them:
> $seen{$attr_value}++ if $attr_value =~ /\.htm/;
<snip>
>
> You will miss some HTML links that don't have explicit file names but
> ar depending on the server to supply index.html or its ilk if only a
> directory name is give.
...or otherwise are text/html but not named with .html, such as most
CGIs, for instance. Since you're using LWP anyway, you can make a HEAD
request for each page (after eliminating scripts/imgs) and check the
type. This will (should) be rather faster than making a full request.
> There might be some false matches for files
> that have '.htm' in them somewhere other than the end, but finding the
> end of a file name in a URL seems a bit tricky.
$seen{$attr_value}++ if $attr_value =~ / \. htm l? (?: $ | \? ) /x;
Ben
--
. | .
\ / The clueometer is reading zero.
. .
__ <-----@ __ ben@morrow.me.uk
------------------------------
Date: Fri, 31 Oct 2003 04:49:17 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: ssh2+checksum+ perl module ?
Message-Id: <20031030234917.0741a1e6.jwillmore@remove.adelphia.net>
On 30 Oct 2003 15:57:55 GMT
zeke03 <zeke03_@caramail.com> wrote:
> I would like to work on ssh and checksum. In fact, this is what i
> would like to
> do :
>
> - chekcsum files to send on the local server
> - send files + checksum files by ssh (ssh2) to the distant server
> - connect to the distant server by ssh (the public key are ok) to do
> a checksum on the files which were send
> - compare the two checksums
>
> => so, my questions is : is there a perl module that allow such
> things ?!
> which one ?
Net::SSH and Net::SCP modules - for the ssh part of your post.
Any one of the Digest modules _should_ fit the bill for the checksum.
You can find other module to your liking by using the search on
http://search.cpan.org/
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
"Nirvana? Thats the place where the powers that be and their
<friends hang out. -- Zonker Harris
------------------------------
Date: Thu, 30 Oct 2003 23:47:47 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: strange effect with [:lower:] in perl
Message-Id: <bns7v3$cv1$1@wisteria.csv.warwick.ac.uk>
"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote:
> On Wed, 29 Oct 2003, Ben Morrow wrote:
>
> This is odd. If I execute this code which we discussed before:
<snip>
> Could I summarise that by saying (applies to both versions):
>
> * if the locale does not include utf-8, then "use locale" switches on
> the reporting of lower-case accented letters.
>
> This is what you already explained as being a compatibility feature
> in the absence of "use locale", right?
Yup.
> * but if the locale _does_ imply utf-8, then it seems something
> different happens. In this test, "use locale" doesn't report accented
> lower-case letters, in either Perl version.
>
> As we saw in the earlier discussion: if the string has been forcibly
> upgraded to Perl's unicode format, then those accented letters were
> reported, irrespective of "use locale", which is fine by me.
>
> But it seems that if the string has not been upgraded to unicode
> format, then even with "use locale" in effect, the accented letters
> are not reported - this bit seems, at least, unintuitive (even a
> mistake?).
>
> Are my observations correct? Any insights?
Well, what you say certainly holds on my machine as well... I think
the answer to this is in perlunicode:
| BUGS
| Interaction with Locales
|
| Use of locales with Unicode data may lead to odd results.
| [...] Use of locales with Unicode is discouraged.
and yes, it probably is a bug. Certainly, a UTF8 locale is treated
qualitatively differently from any other.
What seems to be happening in that in 5.6 'use locale' with a UTF8
locale is treated identically to 'use utf8', and in 5.8 it is ignored
(at least as far as character sets/encodings are concerned); perl then
treats all non-upgraded data as though locale support wasn't present,
and assumes it's encoded in iso8859-1 when it needs to be upgraded.
This is arguably incorrect :), but I guess it's a reasonable
compromise. It would be nice to have a 'all data has the utf8 flag on,
all the time, except under 'use bytes'' pragma; or is this what the
new -C flag (or having a UTF8 locale in 5.8.0) does, in effect?
The Right Answer, I guess, is this:
Under 'no locale':
* Upgraded data is in utf8. [[:lower:]] et al match exactly the same
as \p{Ll}: i.e., by the definitions given in the Unicode database.
* All non-upgraded data is considered to be ASCII[2]. Strings
containing top-bit-set bytes are binary, and cannot be
upgraded... or maybe all the top-bit-set chars are upgraded to
their corresponding Unicode codepoints, with or without a
warning.
I don't like the current 'let's just randomly assume iso8859-1'
approach. I would like to say that top-bit-set chars should all be
upgraded to U+FFFD, but I feel this might cause problems... :)
* Since non-upgraded data is ASCII, [[:lower:]] == [a-z] [3]. Matching
against \p{Ll} causes the data to be upgraded (if you're using
Unicode-y operators, you can't object to Perl upgrading), and
matched against the Unicode database.
Under 'use locale':
* Upgraded data is utf8. Non-upgraded data (when treated as text) is
considered to be encoded as the charset[1] portion of the locale,
and is upgraded to utf8 on that basis when necessary.
* [[:lower:]] != \p{Ll}. [[:lower:]] matches (character set implied
by locale) intersect (\p{Ll}), on both non- and upgraded data.
* Opened filehandles have an appropriate :encoding() layer
automatically pushed.
Under 'use bytes' (which overrides 'use locale'):
* All data is considered to be binary, and the use of any text-y
regex components such as [[:lower:]] or \p is an error. [a-z] is
interpreted as [\x61-\x7a] (or the equivalent EBCDIC).
* Opened filehandles have :raw automatically pushed.
locale should have an two functions, locale::to_local and
locale::from_local which work identically to Encode::(en|de)code with
the appropriate encoding supplied.
Hmm, wonder what p5p's opinion on all that would be? "Go away, it's
working now, the right time to have said this was some time ago" would
certainly be fair enough... :)
Ben
[1] ...in the MIME sense, i.e. an encoding. I am aware of the
difference, it's just tiresome to be Correct all the time :).
[2] or EBCDIC, as appropriate, throughout.
[3] or rather, [abcd...xyz], to account for EBCDIC.
--
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
-Assyrian stone tablet, c.2800 BC ben@morrow.me.uk
------------------------------
Date: Fri, 31 Oct 2003 00:32:20 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: Re: Video::Capture example?
Message-Id: <bnsaik$1lh$1@reader2.panix.com>
In <4u32qvgthijulq4baguj941i6a9jhr8g7p@4ax.com> zentara <zentara@highstream.net> writes:
>On Wed, 29 Oct 2003 15:15:27 +0000 (UTC), Stan Brown <stanb@panix.com>
>wrote:
>>I'm writing a perl script to capture images from some cameras, and make
>>mpes out of them on Linux.
>>
>>I't basicly working using system() calls to v4lctl, but that is slowing
>>things dow, spawning a seperate task for each capture.
>>
>>I've found the Video::Captur module, and I think it's the way to go.
>>However it has no documentation for the calls, and the example programs
>>have no comments.
>>
>>Could anyone point me to a working example of capturing an image using
>>this? I suspect I jyst need to traslate a couple of v4;ctl commands to the
>>corect syntax for using this module. EG:
>Here is a Tk camera capture program is wrote. The biggest obstacles are
>making sure the camera syncs, and converting the raw BGR data to RGB.
>There are a couple of different ways you can do this, I used a technique
>of reversing the data, then flipping it with Imager. Imager also has a
>more direct matrix method, but I think it was a bit slower that way.
>Read "perldoc Imager::Transformations".
Thanks for the help on this again!
I've managed to integrate major peices of this into my script, and have it
working! But I've got a few questiosn, if some kind soul could enlighten me
a bit further.
First, why do we go through the capture/convert loop twice per grab?
for ( 0 .. 1 ) {
my $nfr = $grab->capture( 1 - $frame, 640, 480 );
I've been benchmarking, and it seems that the 2nd pass take much longer
than the first.
second, could someone explain these calls to me?
my $channel = $grab->channel(0);
my $tuner = $grab->tuner(0);
$tuner->mode(1);
$channel->norm(1);
$tuner->set;
$channel->set;
It appears to me that first read the chanlel (and tuner ? what's a tuner?)
The set them back?
And finally, if I want to use the 2nd capture card, I pass a 1 to the first
2 calls, right?
Thansk again for all the help on this!
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
------------------------------
Date: Fri, 31 Oct 2003 01:21:35 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: Re: Video::Capture example?
Message-Id: <bnsdev$2f7$1@reader2.panix.com>
In <bnsaik$1lh$1@reader2.panix.com> Stan Brown <stanb@panix.com> writes:
>In <4u32qvgthijulq4baguj941i6a9jhr8g7p@4ax.com> zentara <zentara@highstream.net> writes:
>>On Wed, 29 Oct 2003 15:15:27 +0000 (UTC), Stan Brown <stanb@panix.com>
>>wrote:
>>>I'm writing a perl script to capture images from some cameras, and make
>>>mpes out of them on Linux.
>>>
Well the short version is, I have no idea how to make Videp::Capture use
the 2nd card (/dev/video1). I suppose it hase to do with the new
Video::Capture::V4l to create a new object. But with no docs, I could be
guessing for a while :-(
Anyone know the magic incatation Here?
And nowing what magic numers to pass to what set-> routine to get composite
video would be useful too.
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
------------------------------
Date: Fri, 31 Oct 2003 08:03:06 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: What am I doing wrong?!
Message-Id: <pan.2003.10.30.20.36.35.91998@aursand.no>
On Thu, 30 Oct 2003 18:10:17 +0000, Jürgen Exner wrote:
>>> I'm now trying
>>> for (@entry)
>> Use 'foreach';
>> foreach ( @array )
> What exactly would be the difference between 'for' and 'foreach'
> (besides the additional 4 letters)?
I would say readability, plus that it simply works better than writing
'for (my $i = 0..@array)' (if you had bothered quoting the relevant text
from my post.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Fri, 31 Oct 2003 07:23:24 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: What am I doing wrong?!
Message-Id: <bnt2lc$ks9$2@wisteria.csv.warwick.ac.uk>
Tore Aursand <tore@aursand.no> wrote:
> On Thu, 30 Oct 2003 18:10:17 +0000, Jürgen Exner wrote:
> >>> I'm now trying
> >>> for (@entry)
>
> >> Use 'foreach';
> >> foreach ( @array )
>
> > What exactly would be the difference between 'for' and 'foreach'
> > (besides the additional 4 letters)?
>
> I would say readability,
Debatable, but yes.
> plus that it simply works better than writing
> 'for (my $i = 0..@array)'
No. The problem there is nothing to do with for/foreach. foreach can
in every single case be replaced with for.
Ben
--
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~ Jorge Luis Borges, 'The Babylon Lottery'
------------------------------
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 5732
***************************************