Search the web
Sign In
New User? Sign Up
Perl_Official · Perl . CGI . Shell script
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
I found an answer to BackReference, your input?   Message List  
Reply | Forward Message #2044 of 2062 |
RE: [Perl] How to search particular words in a file

Hello Avinash,

yes u can easily find the word and its line through regx. here i have
just given a simple example to your reference.
im also preparing the perl and working in small tasks. keep in touch
regarding any perl related discussion.


#usr/bin/perl
use warnings;
open(my $sen, "<", "input.txt") or die "cant open input.txt";
my @list = <$sen>;
my $txt;
close $sen;
foreach (@list) {
if ($_ =~ /gmail/) {
open($txt, ">> utxt.txt") or die "Can't open input.txt:";
print $txt $_;
close $txt;
}
}

Thanks,
K. Senthil Kumar



-----Original Message-----
From: Perl_Official@yahoogroups.com
[mailto:Perl_Official@yahoogroups.com]On Behalf Of avinash k
Sent: Wednesday, September 05, 2007 4:56 PM
To: Perl_Official@yahoogroups.com
Subject: [Perl] How to search particular words in a file


hi,

I am trying to find particular words in text files(i.e. *.txt files)

Should i use regular expressions in doing?

Thanks in advance
Avinash


---------------------------------
Get the freedom to save as many mails as you wish. Click here to know how.

[Non-text portions of this message have been removed]






[Non-text portions of this message have been removed]




Sat Sep 8, 2007 2:44 am

senmal2003
Offline Offline
Send Email Send Email

Forward
Message #2044 of 2062 |
Expand Messages Author Sort by Date

#!/usr/bin/perl use strict ; my @Name; my $Name; my $X = 1; my $Y = 2; my $Data=":2-Lou-14:4-Bobby:3-Tine13:1-jack 23:"; my $Info = ($Data =~ /:$Y-(.*?):/); ...
Lou Hernsen
luinrandir
Offline Send Email
Aug 31, 2007
5:00 pm

hi, I am trying to find particular words in text files(i.e. *.txt files) Should i use regular expressions in doing? Thanks in advance Avinash ... Get the...
avinash k
avik1612
Offline Send Email
Sep 7, 2007
12:03 am

Hello Avinash, yes u can easily find the word and its line through regx. here i have just given a simple example to your reference. im also preparing the perl...
K. Senthil Kumar
senmal2003
Offline Send Email
Sep 9, 2007
2:53 am

Avinash, Here's one solution. Darren ==== #!/bin/perl/bin ### ### title: pgrep ### author: darren miller ### ### perl alternative to UNIX grep command, ###...
millerdw2003
Offline Send Email
Sep 9, 2007
3:03 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help