wwang suggested:
>How about using split function?  I mean something like:

my @myCounts = split @YourData, /;/
print $#myCounts;

Er, close - your split is reversed and you want to split the string, not 
an array:
my @myCounts = split /;/, $YourData;

but this points to an interesting thing we just ran into - split, w/o the 
limit field and using an RE to split on, will drop null fields at the end 
of the split so:
my $YourData = 'one;;three;four';
my @myCounts = split /;/, $YourData ;
# '$#array give last index for array
print "cn: ", $#myCounts, "\n";
# add 2 null fields at end
$YourData = 'one;;three;four;;';
@myCounts = split /;/, $YourData ;
print "cn: ", $#myCounts, "\n";
# split using limit param
@myCounts = split /;/, $YourData , 6;
print "cn: ", $#myCounts, "\n";
# array in scalar context gives # of elements
print "cn: ", scalar @myCounts, "\n";

gives:
cn: 3
cn: 3
cn: 5
cn: 6

even thouhg the 2nd one has 5 semis in it.  The last only shows a 'five' 
as

a

Andy Bach
Internet: [EMAIL PROTECTED]
VOICE: (608) 261-5738  FAX 264-5932

Have you noticed that people whose parents did not have 
children, also tend not to have children?
  - Robert J. Kolker in sci.math, "Re: Genetics and Math-Ability"
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to