Re: [vox-tech] newbie regexp question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vox-tech] newbie regexp question
Micah,
Basic Perl question, in your example:
> #!/usr/bin/perl
> undef $/; # slurp the file into a scalar
> $contents = <>;
> $contents =~ /$exactSequence/;
> $beforeMatch = $`;
> $match = $&;
> $afterMatch = $';
Since you don't identify the file (I'm not sure where the "<>" will read), lets
say I had a file at /home/jstrauss/FileToBeRead.txt, how would I read an entire
file into the variable?
And what does "undef $/;" do?
Jay Strauss
jstrauss@bazillion.com
(h) 773.935.5326
(c) 312.617.0264
----- Original Message -----
From: "Micah Cowan" <micah@cowanbox.com>
To: <vox-tech@franz.mother.com>
Sent: Thursday, September 28, 2000 3:56 PM
Subject: Re: [vox-tech] newbie regexp question
> On Thu, Sep 28, 2000 at 01:31:18PM -0700, Ricardo Anguiano wrote:
> >
> > Eric Engelhard <ekengelhard@sagresdiscovery.com> writes:
> >
> > > Hi all,
> > >
> > > I am writing a perl script to process DNA sequences and want to use
> > > regular expressions to mark a site at known landmarks (exact sequence
> > > match) and cut the sequence both before AND after these landmarks. I
> > > promise to whip out the regexp O'Reilly book tonight, but I need a
> > > demo up in a couple hours. First correct answer scores a pint of hony
> > > beer (12% alcohol).
> > >
> > > -- Eric K. Engelhard
> >
> > Will this work? Keep the beer if it does.
> >
> > #!/usr/bin/perl
> > while (<>) {
> > chomp;
> > if (/(.*)(exactSequence)(.*)/) {
> > $beforematch = $1;
> > $match = $2;
> > $aftermatch = $3;
> > }
> >
> > -Ricardo
>
> Or:
>
> #!/usr/bin/perl
> undef $/; # slurp the file into a scalar
> $contents = <>;
> $contents =~ /$exactSequence/;
> $beforeMatch = $`;
> $match = $&;
> $afterMatch = $';
>
> - Micah
>
|