Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counting a split

Status
Not open for further replies.

columb

IS-IT--Management
Feb 5, 2004
1,231
EU
I have a string which looks like
Code:
bit1,bit2,bit3,bit4
and I want to count the number of bits. What I have so far is
Code:
my @bits = split /,/;
print $#bits, "\n";
which works fine but do I really need to declare the array? I've tried constructs such as
Code:
print $#(split /,/)
and a number of variants but I can't seem to get it. Any pointers please?

Thanks

On the internet no one knows you're a dog

Columb Healy
 
Thanks - perfect answer(s)

On the internet no one knows you're a dog

Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top