This should help you, the while will step through each line of the text
file, and you can do whatever you want using the magical $_ variable.
God I love perl.
open(F, "<fillename") || die "Can't open file: $!";
while(<F>) {
do something with $_;
}
close(F);
Brian Johnson
Partner/Systems Administrator/Programmer
Source1Hosting.tv, LLC (www.source1hosting.tv)
Source1Results.com, LLC (www.source1results.com)
I may be insane, but remember - The only
difference between an insane man and a
genius is his jacket.
> -----Original Message-----
> From: Rahul Garg [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 17, 2001 2:15 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: Parsing of a File and SEARCH ...........HELP!!!!!!!!!!!!!
>
>
>
>
> one more simple Q...
>
> After opening the file ,
> How to read a file line by line.......................sample code
>
>
> Thax in advance.............
> waiting for replies.........................
>
>
>
>
>
>
>
>
>
>
>
> ----- Original Message -----
> From: Jeff 'japhy' Pinyan <[EMAIL PROTECTED]>
> To: Rahul Garg <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Monday, July 16, 2001 6:10 PM
> Subject: Re: Parsing of a File and SEARCH ...........HELP!!!!!!!!!!!!!
>
>
> > On Jul 16, Rahul Garg said:
> >
> > >1)I want to look out for a particular string in a file.
> > > Actually there is only one strng in each line of a file.
> > > How to search for it.............sample code........as
> i am new to
> syntax of perl
> >
> > For just finding ONE string in ANOTHER string, the index()
> function is all
> > you need.
> >
> > my $pos = index("jeffrey", "fre"); # 3
> > my $pos = index("jeffrey", "jeff"); # 0
> > my $pos = index("jeffrey", "free"); # -1
> >
> > As you can see, the function returns -1 on failure. Please
> read the docs
> > for the function:
> >
> > perldoc -f index
> >
> > >2)I want to look out for a particular part(match) in a
> string in a file.
> > > Actually there is only one string in each line of a file.
> >
> > You need to open the file, and go through it, line by line,
> executing the
> > index function on the line.
> >
> > while (<FILE>) {
> > if (index($_, $word) > -1) {
> > # $word was found somewhere in $_
> > }
> > }
> >
> > Learn how to work with files:
> >
> > perldoc perlopentut
> > perldoc -f open
> >
> > --
> > Jeff "japhy" Pinyan [EMAIL PROTECTED]
> http://www.pobox.com/~japhy/
> > I am Marillion, the wielder of
> Ringril, known as Hesinaur, the Winter-Sun.
> > Are you a Monk? http://www.perlmonks.com/
> http://forums.perlguru.com/
> > Perl Programmer at RiskMetrics
> Group, Inc. http://www.riskmetrics.com/
> > Acacia Fraternity, Rensselaer Chapter. Brother #734
> > ** Manning Publications, Co, is publishing my Perl
> Regex book **
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]