User Control Panel
Advertisements

HELP US, HELP YOU!

Getting Part Of A Line?

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl
View unanswered posts
Author Message
kings_on_steeds
Senior Member
Senior Member


Joined: 05 Apr 2004
Posts: 290
Location: Bookham, Surrey, UK
Reputation: 35.1Reputation: 35.1Reputation: 35.1Reputation: 35.1

PostPosted: Wed Apr 13, 2005 1:13 pm    Post subject: Reply with quote

Hello, I Know It Can Be Done But I Dont Know How, I Would Like To Get My Program To Open A File, Read Each Line But Only Take Say 20 Chars From The Line, Now I Know How To Do The Open And Send To A Var, But I Dont Know How To Tell It To Only Push 20 Chars, Can Any One Help? Tnks

Example

Quote:
File Says:

Hello My Name Is Fred And I Like Cheese.

Prog Says:

Hello My Name Is Fred ....
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Wed Apr 13, 2005 1:18 pm    Post subject: Reply with quote

have a look at one of the many quotes commands
Back to top
malefactor
Member
Member


Joined: 27 Jan 2005
Posts: 109
Location: Lewiston, ME
Reputation: 17.7Reputation: 17.7

PostPosted: Wed Apr 13, 2005 4:36 pm    Post subject: Reply with quote

substr(string,start,length)
Back to top
mattaustin
Sentinel
Sentinel


Joined: 19 Jul 2004
Posts: 556
Location: Los Angeles, CA
Reputation: 50.7
votes: 1

PostPosted: Wed Apr 13, 2005 4:39 pm    Post subject: Reply with quote

SUBSTR:

print substr($str,0,20);

Pattern matching:

($data) = $str =~ m/(.{20})/;

_________________
[ matt ]
Back to top
kings_on_steeds
Senior Member
Senior Member


Joined: 05 Apr 2004
Posts: 290
Location: Bookham, Surrey, UK
Reputation: 35.1Reputation: 35.1Reputation: 35.1Reputation: 35.1

PostPosted: Wed Apr 13, 2005 5:00 pm    Post subject: Reply with quote

tnks guys.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group