[23535] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5743 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 3 09:06:05 2003

Date: Mon, 3 Nov 2003 06:05:10 -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           Mon, 3 Nov 2003     Volume: 10 Number: 5743

Today's topics:
        apache and perl (Thomas)
    Re: apache and perl <usenet@morrow.me.uk>
    Re: Aps and Linux (Bryan Castillo)
        Condos in Canada @ 75 cents on the US Dollar! redgryphon@shaw.ca
        Could someone successfully compile perl 5.8.1 with ming (Albert Albani)
        derefing a nested table full of refs <member41443@dbforums.com>
    Re: derefing a nested table full of refs <member41443@dbforums.com>
    Re: derefing a nested table full of refs <nospam@bigpond.com>
        Help with encrypt password and uid. <pengtaoli@hotmail.com>
    Re: Help with encrypt password and uid. <kaspREMOVE_CAPS@epatra.com>
    Re: How big can an array be ? (Bryan Castillo)
    Re: How big can an array be ? <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: How big can an array be ? <tore@aursand.no>
    Re: neuronal pattern / network (Anno Siegel)
    Re: Newbie to perl, need help <stjm2@cam.ac.uk.remove>
        Parrot 0.0.13 "Screaming Pumpkin" Released! <slrn@toetsch.at>
        Something like JSP tags (Laszlo)
    Re: sub confusion <me@privacy.net>
    Re: sub confusion <tore@aursand.no>
    Re: What am I doing wrong?! (Tony Walker)
    Re: What am I doing wrong?! (Anno Siegel)
    Re: What am I doing wrong?! <tore@aursand.no>
    Re: What am I doing wrong?! (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 3 Nov 2003 03:04:02 -0800
From: sctommi@gmx.net (Thomas)
Subject: apache and perl
Message-Id: <5a1109df.0311030304.4b4fb7a8@posting.google.com>

hi,

i have different perl versions installed on my computer (Linux) and
like to tell my webserver apache, that he can also upgrade/use from
perl v. 5.6 to Perl v. 5.8...i'm sorry i can't find the right
location, where i can change the path of the new perl version...

best regards
Thomas

(i fear i need to build a new apache ?)


------------------------------

Date: Mon, 3 Nov 2003 11:19:17 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: apache and perl
Message-Id: <bo5djl$a4n$1@wisteria.csv.warwick.ac.uk>


sctommi@gmx.net (Thomas) wrote:
> hi,
> 
> i have different perl versions installed on my computer (Linux) and
> like to tell my webserver apache, that he can also upgrade/use from
> perl v. 5.6 to Perl v. 5.8...i'm sorry i can't find the right
> location, where i can change the path of the new perl version...

[This isn't really a Perl question, but an Apache question]

If you're running your scripts with mod_cgi then you just need to
change the #! line in your script to point to the new perl. If you're
using mod_perl or so then you need to rebuild mod_perl against the new
perl.

Ben

-- 
"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: 2 Nov 2003 22:09:06 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Aps and Linux
Message-Id: <1bff1830.0311022209.529bde4b@posting.google.com>

James Willmore <jwillmore@remove.adelphia.net> wrote in message news:<20031031113501.46bff5d8.jwillmore@remove.adelphia.net>...
> On Fri, 31 Oct 2003 12:00:02 -0500
> Chris Mattern <syscjm@gwu.edu> wrote:
> 
> > James Willmore wrote:
> > > On Fri, 31 Oct 2003 13:33:42 +0100
> > > "Ste" <nonspammare@nospam.com> wrote:
> > > <snip>
> > > 
> > > This is ASP code, not Perl.
> > > 
> > > Wrong group :-(
> > > 
> > 
> > Nope, it's "Aps" code.  The OP said so.
> > 
> >          Chris Mattern
> > 
> 
> Sorry, but I believe the OP is mistaken.  It appears, to me, to be
> ASP.  ASP is very similar to Visual Basic and it appears from the code

VBScript can be used within ASP, but many languages can be used in
ASP,
including perl (well on IIS you would need to use PerlScript from
ActiveState,
which allows perl to be used from WSH).

> published that it's ASP (because of the syntax used).
> 
> But, of course, I could be wrong :-)
> 
> In any event, It don't look, talk, etc. like Perl code :-)
> 

Interestingly enough, if you check the URL the user posted for the
script
you will see errors with references to Apache::ASP, which from what I
know only
supports perl as its scripting language.  

I imagine the user tried to put an ASP page using VBScript as the
scripting
language on Apache::ASP.  Perhaps the user read that perl was used for
Apache::ASP and came here.

Anyway, you have to convert all the stuff between <% and %> to perl
(from whatever language you used VB, JScript, Python, Perl, etc....

The objects such as Request and Session should be the same.  Instead
of
Request.method() it would be Request->method().  Check the Apache::ASP
website.




> -- 
> 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 ...
> I have great faith in fools -- self confidence my friends call
> <it.   -- Edgar Allan Poe


------------------------------

Date: Mon, 03 Nov 2003 10:14:06 GMT
From: redgryphon@shaw.ca
Subject: Condos in Canada @ 75 cents on the US Dollar!
Message-Id: <OTppb.275733$9l5.275305@pd7tw2no>

Summer home, investment or retirement home, one or two bedroom condo suites in
a townhouse style in one of Alberta's most popular tourist areas, Sylvan Lake.<BR><BR>
Two blocks from the Marina and lake, boating, fishing, swimming, go-karts, waterslide
park, good shopping and excellent clubs and restaurants.<BR><BR>
Only ten minutes from a medium sized city, Red Deer, with all its city features
including some excellent casinos.<BR><BR>
<i>(Gambling is legal in Alberta!)</I><BR><BR>
Investors, ask for a Prospectus. Free info to all for an e-mail to 
<a href="mailto:redgryphon@shaw.ca">Red Gryphon</a> or visit our website at
<a href="http://members.shaw.ca/redgryphon/index.htm">Rainbow Park </a> and take
the tour.

--
Posted by News Bulk Poster
Unregistered version


------------------------------

Date: 3 Nov 2003 04:40:53 -0800
From: albanialbert@yahoo.de (Albert Albani)
Subject: Could someone successfully compile perl 5.8.1 with mingw 3.1.0-1?
Message-Id: <7c2ca73a.0311030440.41710954@posting.google.com>

Hello everybody

I am wondering if there is someone who was able to successfully
compile perl 5.8.1 with ming 3.1.0-1, and I'd be very happy
if such a person could give me a hint as to what I could do
to compile my perl as well.

When I try to compile my perl, I get the following linker
errors:

Info: resolving ___pioinfo by linking to __imp____pioinfo (auto-import)
fu000001.o(.idata$3+0xc): undefined reference to `libmsvcrt_a_iname'
fu000002.o(.idata$3+0xc): undefined reference to `libmsvcrt_a_iname'
fu000003.o(.idata$3+0xc): undefined reference to `libmsvcrt_a_iname'
fu000004.o(.idata$3+0xc): undefined reference to `libmsvcrt_a_iname'
fu000005.o(.idata$3+0xc): undefined reference to `libmsvcrt_a_iname'
nmth000000.o(.idata$4+0x0): undefined reference to `_nm____pioinfo'
dmake.exe:  Error code 1, while making '..\miniperl.exe'




I have used win32\makefile.mk (together with dmake) and done the following changes:
#
# Visual C++ 2.x
#CCTYPE		*= MSVC20
# Visual C++ > 2.x and < 6.x
#CCTYPE		*= MSVC
# Visual C++ >= 6.x
#CCTYPE		*= MSVC60
# Borland 5.02 or later
#CCTYPE		*= BORLAND
# mingw32+gcc-2.95.2 or better
CCTYPE		*= GCC
# Uncomment this if you are using the latest MinGW release (2.0.0)
# with gcc3.2
USE_GCC_V3_2	*= define

 .....

 .IF "$(CCTYPE)" == "BORLAND"
CCHOME		*= C:\borland\bcc55
 .ELIF "$(CCTYPE)" == "GCC"
CCHOME		*= C:\tools\MinGW
 .ELSE
CCHOME		*= $(MSVCDIR)
 .ENDIF
CCINCDIR	*= $(CCHOME)\include
CCLIBDIR	*= $(CCHOME)\lib


------------------------------

Date: Mon, 03 Nov 2003 06:43:35 -0500
From: AVataRR <member41443@dbforums.com>
Subject: derefing a nested table full of refs
Message-Id: <3552435.1067859815@dbforums.com>


okay.. say I gots me a table and each row of this table has a nested
table full of refs.. I know I have to somehow get to each "tuple" of the
nested table and deref them individually, but PL/SQL being worse than
BASIC, I have absolutley no idea of how to do this.



helpy?


--
Posted via http://dbforums.com


------------------------------

Date: Mon, 03 Nov 2003 06:46:58 -0500
From: AVataRR <member41443@dbforums.com>
Subject: Re: derefing a nested table full of refs
Message-Id: <3552439.1067860018@dbforums.com>


oopsie :D I don't know how this got posted here, but I meant to put it
up in the SQL/PL SQL board. Can someone please move it?


--
Posted via http://dbforums.com


------------------------------

Date: Mon, 03 Nov 2003 22:44:39 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: derefing a nested table full of refs
Message-Id: <6290286.lIserQVUTC@gregs-web-hosting-and-pickle-farming>

It was a dark and stormy night, and AVataRR managed to scribble:

> 
> oopsie :D I don't know how this got posted here, but I meant to put it
> up in the SQL/PL SQL board. Can someone please move it?

NO!

But referring to your original question, a relationaly database may not be the best way to store complex network relationships. A object oriented database may be more appropriate.
Relational calculus knows nothing about dereferencing.

gtoomey


------------------------------

Date: Mon, 3 Nov 2003 10:08:53 +0800
From: "Franklin Lee" <pengtaoli@hotmail.com>
Subject: Help with encrypt password and uid.
Message-Id: <bo4del$1o6@netnews.proxy.lucent.com>

Now I want to write one CGI(Perl) program.

User will login to a web page, and have to enter a user id and
password(Inlcuding registering). And submit to Server.

Then I need encrypt the UID and password. In server, I get the encrypted msg
and then decode the msg to get
UID and password.

How should I do? Is there some document for this?

Thank you!

Franklin





------------------------------

Date: Mon, 3 Nov 2003 13:13:38 +0530
From: "Kasp" <kaspREMOVE_CAPS@epatra.com>
Subject: Re: Help with encrypt password and uid.
Message-Id: <bo510q$gj5$1@newsreader.mailgate.org>

> How should I do? Is there some document for this?

Search on cpan.org

-- 
"Accept that some days you are the pigeon and some days the statue."
"A pat on the back is only a few inches from a kick in the butt." - Dilbert.




------------------------------

Date: 2 Nov 2003 21:43:40 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: How big can an array be ?
Message-Id: <1bff1830.0311022143.11f1461c@posting.google.com>

Andreas Kahari <ak+usenet@freeshell.org> wrote in message news:<slrnbqa851.1a4.ak+usenet@mx.freeshell.org>...
> In article <3fa4b8de_1@news.iprimus.com.au>, Andrew Rich (VK4TEC) wrote:
> > Is there any limitation to a PERL array size ?
> > 
> > If I was to load a MySQL database into an array...
> > 
> > or
> > 
> > open (FILE,"/somemonsterfile"):
> > while (<FILE>)
> > {
> > push @array, $_
> > }
> 
> 
> You probably can't load more into memory than what can be fit
> into primary memory.  Some operating systems may possibly let
> you load enough to fill out both primary and [disk based]
> virtual memory.
> 
> 
> However, most of the time you should work on large files line by
> line.  There is very seldom any need to slurp a whole monster
> file into memory at once, especially not databases since the
> whole point of the database is to query it with a structured
> query and parse the result row by row.


Using linux I was able to load a hash, where the process was taking up
~ 1GB of memory.  I only had 512 MB of RAM.  I had 1 GB of swap.  I
imagine that on some OS's you might not be able to occupy more that
4GB of RAM, since pointers would go over their limit (for 32 bit
pointers at least).  I was also root while doing this, I don't know if
some users are prohibited more than others.  Trying this non-root on
Solaris, I was told that I ran out of memory much earlier. (I don't
know why  ulimit  maybey???)

*** I had 2 huge files to cross reference with each other.
    I originally tried doing the calculation with both 
    a relational database (Informix) and with Berkely DB. 
    Loading all of one file into memory and using that in memory hash
    for processing against the 2nd file was at least 10 times faster
    than using a database. ***


------------------------------

Date: Sun, 2 Nov 2003 23:47:14 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: How big can an array be ?
Message-Id: <2615ob.rjr.ln@goaway.wombat.san-francisco.ca.us>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

On 2003-11-03, Bryan Castillo <rook_5150@yahoo.com> wrote:
> *** I had 2 huge files to cross reference with each other.
>     I originally tried doing the calculation with both 
>     a relational database (Informix) and with Berkely DB. 
>     Loading all of one file into memory and using that in memory hash
>     for processing against the 2nd file was at least 10 times faster
>     than using a database. ***

Well, the OP already has MySQL, so it might not be so helpful to dump
his query results to a file then process it.

- --keith

- -- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/pggBhVcNCxZ5ID8RApydAJ44U6IfxFwxUvX3eUmQZA2zdq6wZwCcDHx4
hX3l+19ipf+PjHkbnK8S9s8=
=6phz
-----END PGP SIGNATURE-----


------------------------------

Date: Mon, 03 Nov 2003 12:38:53 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: How big can an array be ?
Message-Id: <pan.2003.11.02.20.58.35.654170@aursand.no>

On Sun, 02 Nov 2003 17:57:01 +1000, Andrew Rich (VK4TEC) wrote:
> Is there any limitation to a PERL array size ?

Not really.  It depends on the OS and how much memory the computer has.

> If I was to load a MySQL database into an array...

Why would you do that?

> open (FILE,"/somemonsterfile"):
> while (<FILE>)
> {
> push @array, $_
> }

You might as well write

  open( FILE, '/somemonsterfile' ) or die "$!\n";
  @array = <FILE>;
  close( FILE );

But you really need to read the whole file in one take?  Are you
absolutely sure you can't process one line at a time?


-- 
Tore Aursand <tore@aursand.no>


------------------------------

Date: 3 Nov 2003 09:03:20 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: neuronal pattern / network
Message-Id: <bo55ko$a08$1@mamenchi.zrz.TU-Berlin.DE>

[top posting re-arranged.  don't do that]

Stefan Mohr <sm-ml@mediascape.de> wrote in comp.lang.perl.misc:
> <ctcgag@hotmail.com> schrieb im Newsbeitrag
> news:20031101133951.496$dL@newsreader.com...
> > "Stefan Mohr" <sm-ml@mediascape.de> wrote:
> > > hello,
> > >
> > > does anybody of you have had the opportunity to program a neuronal
> > > pattern / network in perl? has anybody some hints for me where to find
> > > some info about that?
> >
> > Your first stop for finding such info should be CPAN,
> > http://search.cpan.org.

> hi,
> 
> i have seen that in the meantime - you know about somewhat newer?

How about taking the hint and doing your own CPAN search?

Anno


------------------------------

Date: Mon, 03 Nov 2003 11:34:51 +0000
From: Stuart Moore <stjm2@cam.ac.uk.remove>
Subject: Re: Newbie to perl, need help
Message-Id: <bo5egs$qai$1@pegasus.csx.cam.ac.uk>


Samurai Jesus wrote:

> Hi.  I was hoping that someone with more experience in perl could help me
> out.
> 
> I'm trying to come up with a perl script that will reside on one of my
> systems to change the names of directories on a NetApp Filer.  I connect to
> the filer using rsh.
> 
> I have to be able to change the names of directories on the filer.
> 
> Currently the directories have names that are totally useless, and I have to
> change them to something useful, using the access time stamp as the name of
> the directory.  As it is, I know that the $atime component of
> stat($filename) should give me the access time of the directory, and the
> command to change the directory name is "snap rename <volume name>
> <directory name> <new directory name>"
> 
> I'm hoping that someone can help point me in the correct direction.

Build up the new directory name using stat (and possibly looking at 
localtime) - see the documentation for both in perlfunc.

Then use system to call the "snap" command - again, see perlfunc.

HTH

Stuart



------------------------------

Date: Fri, 31 Oct 2003 14:32:04 GMT
From: Leopold Toetsch <slrn@toetsch.at>
Subject: Parrot 0.0.13 "Screaming Pumpkin" Released!
Message-Id: <Hns081.1v5r@zorch.sf-bay.org>

Parrot 0.0.13 "Screaming Pumpkin" Released!

Your new Bluza[1] proudly presents Parrot 0.0.13 Halloween edition[2].
Proposed originally as a fun release it has a remarkable list of
improvements, additions, and fixes[3].
While not really milestones are reached, many steps towards these are
done.

After some pause you can grab it from
<http://www.cpan.org/authors/id/L/LT/LTOETSCH/parrot-0.0.13.tar.gz>
or just get the latest and best from CVS by following the directions at
<http://dev.perl.org/cvs/>.

Turn your web browser towards <http://www.parrotcode.org/> for more
information about Parrot, get involved, and:

Have fun!
leo

[1] Austrian dialect word for pumpkin with some aftermath of an head
    filled with water.

[2] Version number fits nicely todays date - and we don't release
    by the dozen.

[3] The list of changes includes:

    - The Big Move: Parrot source and build files rearranged into sub dirs
    - Build imcc as parrot
    - Objects more finished
    - Delegate vtable methods to byte code
    - Binary multi-method dispatching
    - Isa and does methods for PMCs
    - Call byte code from C
    - Start of extension interface
    - Experimental struct handling
    - Catch access to NULL PMCs
    - Experimental network socket interface code and opcodes
    - IO fixes and improvements
    - Dynamic opcode libraries
    - Fix-assigned opcode numbers
    - Argument flattening for function calls
    - More native call interface (NCI) signatures
    - Ncurses, postgres, and pcre interface libraries
    - Forth language is vastly improved
    - New tcl and urm languages
    - BSD and Win32 build improvements
    - Many new tests and fixes

-- 
leo




------------------------------

Date: 3 Nov 2003 05:44:40 -0800
From: graf.laszlo@axis.hu (Laszlo)
Subject: Something like JSP tags
Message-Id: <205f57b7.0311030544.5b06b35f@posting.google.com>

Hi Gurus

Did somebody develop a mechanism for Perl (and Apache web server)
like JSP tag ?

Graf Laszlo


------------------------------

Date: Mon, 3 Nov 2003 20:35:58 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: sub confusion
Message-Id: <bo510g$17ls3k$1@ID-172104.news.uni-berlin.de>


<walterg@example.com> wrote in message
news:xUdpb.2524$Wy2.34429@typhoon.sonic.net...
> I couldn't find the solution to this on google, so...  There must be
> some way to write two simple functions to convert a single digit date
> to a two digit date and strip the ":" characters from time.
>
> Thanks in advance,
> Walter
>
> #!perl
> $today=`date`;
> ($weekday, $month, $day, $time, $junk) = split(' ', $today, 5);
> $daynum = DayToNum( $day );
> $timenum = TimeToNum( $time );
>
> ## 1 -> 01
> print "\$daynum\( $day \) = $daynum \n";
> ## 12:16:56 -> 121656
> print "\$timenum\( $time \) = $timenum \n";
>
> sub DayToNum {
>     ## doesn't work
>     if ( length lt 2 ) { $_ = "0" . "$_"; }
>     ## doesn't work
>     # if (/^1$/) { return "01"; }
>     # elsif (/^2$/) { return "02"; }
>     # elsif (/^3$/) { return "03"; }
>     # elsif (/^4$/) { return "04"; }
>     # elsif (/^5$/) { return "05"; }
>     # elsif (/^6$/) { return "06"; }
>     # elsif (/^7$/) { return "07"; }
>     # elsif (/^8$/) { return "08"; }
>     # elsif (/^9$/) { return "09"; }
>     # else { return "$_"; }
> }
> sub TimeToNum {
>     ## doesn't work
>     s/://g;
>     ## doesn't work
>     # $_ =~ s/://g;
>     ## works...
>     # $timenum = $time;
>     # $timenum=~ s/://g;
> }

Holy Moly!!  Perl aint that cumbersome.

You'll find this code a little shorter and more portable :-)

#!/usr/bin/perl
use POSIX;
print strftime("Day:  %d\n",localtime);
print strftime("Time: %H%M%S\n",localtime);




------------------------------

Date: Mon, 03 Nov 2003 12:38:53 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: sub confusion
Message-Id: <pan.2003.11.02.21.11.34.732364@aursand.no>

On Sun, 02 Nov 2003 20:35:41 +0000, walterg wrote:
> #!perl 

use strict;
use warnings;

> $today=`date`;
> ($weekday, $month, $day, $time, $junk) = split(' ', $today, 5); 

No need for a system call here.  Just to this:

  my ($sec, $min, $hour, $day, $month, $year) = (localtime)[0..5];
  $year += 1900;
  $month++;

perldoc -f localtime

> $daynum = DayToNum( $day );
> $timenum = TimeToNum( $time );

Those sub-routines was horrible.  You might want to look into these:

  perldoc -f printf
  perldoc -f sprintf

Here's and example to print out the current date (from the code above):

  printf("%4d-%02d%02d %02d:%02d:%02d", $year, $month, $day, $hour, $min,
  $sec);


-- 
Tore Aursand <tore@aursand.no>


------------------------------

Date: 3 Nov 2003 01:49:20 -0800
From: tony.walker@dhl.com (Tony Walker)
Subject: Re: What am I doing wrong?!
Message-Id: <72461e59.0311030149.3a35f538@posting.google.com>

Jeff Boes <jboes@nexcerpt.com> wrote in message news:<d9ec083e87ec0c92bd12d425e3d5a80a@news.teranews.com>...
> Tony Walker wrote:
> >         my $LINE = @entry[$i];
> >         if ($CUR =~/$LINE/){
> >         print $CUR;
> >         }
> 
> Consider "$CUR =~ /\Q$LINE\E/" here; if the text in $LINE contains any 
> regular expression meta-characters (like "."), your match may not work 
> the way you want it to.

Thanks for all the input Gentlemen. Since posting my rather 'useless'
error description I have cracked the problem and the script I
originally posted this message about is running nicely without
problems. Nice to have found such a rich source of information...

Tony


------------------------------

Date: 3 Nov 2003 10:51:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: What am I doing wrong?!
Message-Id: <bo5bvf$dad$1@mamenchi.zrz.TU-Berlin.DE>

Tore Aursand  <tore@aursand.no> wrote in comp.lang.perl.misc:
> On Fri, 31 Oct 2003 07:23:24 +0000, Ben Morrow wrote:
> >> 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.
> 
> I know that, but look at the actual code.  Maybe I'm misunderstanding
> something here, but have tried this?
> 
>   my @array = qw( a b c d e f );
>   for ( my $i = 0 .. @array ) {
>       print $i . ' = ' . $array[ $i ] . "\n";
>   }
> 
> Doesn't look nice to me.

No, but it doesn't work with foreach either.

While "for" and "foreach" are really synonyms, there are still two
entirely different loop constructs they can *both* introduce.  The
difference is in the syntax of what follows for/foreach.

Anno


------------------------------

Date: Mon, 03 Nov 2003 13:21:23 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: What am I doing wrong?!
Message-Id: <pan.2003.11.03.11.41.51.225943@aursand.no>

On Mon, 03 Nov 2003 10:51:27 +0000, Anno Siegel wrote:
>> my @array = qw( a b c d e f );
>> for ( my $i = 0 .. @array ) {
>>     print $i . ' = ' . $array[ $i ] . "\n";
>> }
>> 
>> Doesn't look nice to me.

> No, but it doesn't work with foreach either.

I never said that.  I just said that one should use...

  foreach ( @array ) {
      ...
  }

 ...instead of the code above.  I know that 'for' and 'foreach' do excactly
the same.


-- 
Tore Aursand <tore@aursand.no>


------------------------------

Date: 3 Nov 2003 12:37:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: What am I doing wrong?!
Message-Id: <bo5i67$jo4$1@mamenchi.zrz.TU-Berlin.DE>

Tore Aursand  <tore@aursand.no> wrote in comp.lang.perl.misc:
> On Mon, 03 Nov 2003 10:51:27 +0000, Anno Siegel wrote:
> >> my @array = qw( a b c d e f );
> >> for ( my $i = 0 .. @array ) {
> >>     print $i . ' = ' . $array[ $i ] . "\n";
> >> }
> >> 
> >> Doesn't look nice to me.
> 
> > No, but it doesn't work with foreach either.
> 
> I never said that.  I just said that one should use...
> 
>   foreach ( @array ) {
>       ...
>   }

But the code above isn't just bad, or hard to read, it's *wrong*.  It
doesn't loop over the array.  Instead it assigns the result of "scalar
0 .. @array" to $i (once), assigns the result to $_, and executes the
loop body (once).

(Apart from that, you'd want $#array instead of @array, but that doesn't
matter anymore.)

Anno


------------------------------

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 5743
***************************************


home help back first fref pref prev next nref lref last post