Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Counting characters in a string

by arden (Curate)
on Mar 11, 2004 at 17:10 UTC ( [id://335878]=note: print w/replies, xml ) Need Help??


in reply to Re: Counting characters in a string
in thread Counting characters in a string

If you wish to avoid any modules, you can do it this way:
#!/usr/local/bin/perl use strict; use warnings; my $var = "this is just a sample of a string, there is nothing really +important in the scalar, just a lot of text"; my $pos = 9; while(( $pos = index($var, ' ', $pos)) > -1 ) { substr($var, $pos, 1) = "\n"; $pos += 10; } print "\n$var\n";
Just remember, TIMTOWTDI.

- - arden.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-19 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found