[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Finding the length of the longest string



>From: John Porter <jdporter@min.net>
>Date: Thu, Jun 24, 1999, 10:59 AM
>

>
> @a[ map { length } @data ] = ();
>
> print $#a;
>

:]

It looks good - but, why was an array used for @data?
I couldn't get it to test all the elements, so I
just used $data...

@a[ map { length } $data ] = ();
print $#a;

Also, I found it funny (while I was trying to walk thru
array elements) that the following prints nothing:

(@a[ map { length } $data ] = ()) ? print $#a : print '';

Seems to me that while the first portion does set $#a,
it returns 0 (zero) when it's done...

PROOF:
#!/usr/local/bin/perl -wT

use strict;
use diagnostics;

my $data = 'This string is counted'; # It's 22 characters...
my @a    = '';

(@a[ map { length } $data ] = ()) ? print $#a : print ' ? ';

print $#a; # $#a was set, however...


???
-Sneex-  :]
FCCJ Data Security Group
______________________________________________________________________
Bill Jones  Data Security Specialist  http://www.fccj.org/cgi/mail?dss

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org