CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Help In Cutting A String....

 



yotam_k
Deleted

Jan 12, 2001, 3:46 AM

Post #1 of 7 (1713 views)
Help In Cutting A String.... Can't Post

Lets Say i have a text , article , that I load it from a file ,
the text contains Plain text .
I need to cutt each line in the text after 40 Charcters in the line and then transfer it to the next line and then cut The next line by the same messurments (after 40 Char.) [ all this content should be of course , in a Integral (with $ sign...) ] .
I need this for adding this text into a thin table space .

I know that there is a Cammand in perl that does it Which I think it beeing called SUBSTRING but i realy dont know it's syntex and that whay I'm Asking .

If I didn't simplfy my question :
" Could someone tell me the syntex SUBSTRING to cut the first 40 Charcters From the Integral "$string" ?




thank you all !!!!!!!!




randor
User

Jan 12, 2001, 8:46 AM

Post #2 of 7 (1710 views)
Re: Help In Cutting A String.... [In reply to] Can't Post

Yotem_k,

the syntax for the substring is as follows:

$var= substr("$string", starting position, length of cutout);

so from what i am gathering you would need something like this:
$var= substr("$string", 40); #if you leave the last number off it will by default return all from that point on.
print "$var\n";

i hope this clears it up for you.

Randor



yotam_k
Deleted

Jan 13, 2001, 5:29 AM

Post #3 of 7 (1700 views)
Re: Help In Cutting A String.... [In reply to] Can't Post

Thank You Very Much Randor , It Helped Very Much !
Thank You !




yotam_k
Deleted

Jan 13, 2001, 5:35 AM

Post #4 of 7 (1700 views)
Re: Help In Cutting A String.... [In reply to] Can't Post

But I have one more question to deep my knowlge :
you said that :

$var= substr("$string", starting position, length of cutout);

so if i want to cutt from the 28 char. I should write :
$var= substr("$string", 28 , 40);

?
And thank you again.
Yotam.




randor
User

Jan 13, 2001, 6:20 AM

Post #5 of 7 (1699 views)
Re: Help In Cutting A String.... [In reply to] Can't Post

$var= substr("$string", 28 , 40);

that will cut from the 28th character to the 40th, if you want to cut everything from the 28th on use this:
$var= substr("$string", 28);

glad i could help:)



japhy
Enthusiast / Moderator

Jan 13, 2001, 7:58 AM

Post #6 of 7 (1698 views)
Re: Help In Cutting A String.... [In reply to] Can't Post

No, it does not cut from the 28th to the 40th. You were right when you said the third argument is the length of the substr. It cuts from the 28th to the 67th, which is 40 characters.

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author


randor
User

Jan 13, 2001, 9:53 AM

Post #7 of 7 (1697 views)
Re: Help In Cutting A String.... [In reply to] Can't Post

yeap, my bad..

i rushed and did not think about what i was saying.. i appologize, and thank you for showing me the error of my ways.



 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives