Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How to get the number of fields found by split without a warning?

by Roy Johnson (Monsignor)
on Dec 08, 2003 at 21:32 UTC ( [id://313249]=note: print w/replies, xml ) Need Help??


in reply to How to get the number of fields found by split without a warning?

If you don't want to actually split but just want to know how many fields split would return, try one of the methods illustrated here:
#!perl use strict; use warnings; my $str = "a,b,c,d,e"; my $n = 1 + $str =~ tr/,//; # Field separator is a single char print "$n\n"; $n = 1 + (() = $str =~ /,/g); # Field separator is a regex print "$n\n";

The PerlMonk tr/// Advocate

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://313249]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-03-29 11:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found