freelanceprogrammers.org Forum Index » Perl

How to get the value column of a File


View user's profile Post To page top
david_iraheta Posted: Sun Sep 04, 2005 2:25 am


Joined: 14 Jun 2004

Posts: 3
How to get the value column of a File
I`ve a file with some columns separate by a pipe, like this:

aaaa|bb|ccc|ddd|eee|fff|ggg|hhh|iii|jjj|kkk|lllll|mm|nn|o|pp|qqq|r|ss|
aaaa|bb|ccc|ddd|eee|fff|ggg|hhh|iii|jjj|kkk|llll|mm|nn|o|pp|qqq|r|ss|
aa|bb|ccc|ddd|eee|fff|ggg|hhh|iii|jjj|kkk|lllll|mm|nn|o|pp|qqq|r|ss|
aaaa|bb|cc|ddd|eee|fff|ggg|hhh|iii|jjj|kkk|lllll|mm|nn|o|pp|qqq|r|ss|
aaaa|bb|ccc|ddd|eee|ff|ggg|hh|iii|jj|kkk|ll|mm|nn|o|pp|qqq|r|ss|

I need to take the column with the letters "r". This file has different
lenght, means that, the letter "r" doesn`t have the same position.

Any idea how to do this?

Thanks in advance.

Dave.
Reply with quote
Send private message
View user's profile Post To page top
skpkrish Posted: Mon Sep 05, 2005 9:31 am


Joined: 13 Aug 2005

Posts: 12
How to get the value column of a File
Hai David,

Greetings.....

Say your filename containing the below data is "data.txt", your code should be
like this.

open(TXT,"data.txt");
while(<TXT>)
{

if($_ =~ /r/)
{
$text .= $_;
}
}
close(TXT);

open(TXT,"output.txt");
print TXT $text;
close(TXT);

I hope you will definitely get a solution through this.

Thanks & Regards
Krish.


david_iraheta <david_iraheta@...> wrote:
I`ve a file with some columns separate by a pipe, like this:

aaaa|bb|ccc|ddd|eee|fff|ggg|hhh|iii|jjj|kkk|lllll|mm|nn|o|pp|qqq|r|ss|
aaaa|bb|ccc|ddd|eee|fff|ggg|hhh|iii|jjj|kkk|llll|mm|nn|o|pp|qqq|r|ss|
aa|bb|ccc|ddd|eee|fff|ggg|hhh|iii|jjj|kkk|lllll|mm|nn|o|pp|qqq|r|ss|
aaaa|bb|cc|ddd|eee|fff|ggg|hhh|iii|jjj|kkk|lllll|mm|nn|o|pp|qqq|r|ss|
aaaa|bb|ccc|ddd|eee|ff|ggg|hh|iii|jj|kkk|ll|mm|nn|o|pp|qqq|r|ss|

I need to take the column with the letters "r". This file has different
lenght, means that, the letter "r" doesn`t have the same position.

Any idea how to do this?

Thanks in advance.

Dave.









SPONSORED LINKS
Basic programming language C programming language Computer programming languages
The c programming language C programming language List of programming languages

---------------------------------
YAHOO! GROUPS LINKS


Visit your group "perl_official" on the web.

To unsubscribe from this group, send an email to:
perl_official-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


---------------------------------




Regards,

Krish.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

[Non-text portions of this message have been removed]
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help