Re: Searching in a line



lerameur wrote:
On Aug 30, 4:39 pm, "Jürgen Exner" <jurge...@xxxxxxxxxxx> wrote:
lerameur wrote:
I wrote this now: If it finds the work beth in the line, then is
splits the line. otherwise print an error.
Now there is beth in the file ( i added it) but the program always
skips to the else statement, end prints it twice.
How should I modify the search if (/^beth/) ?
while ($data=<$fh>) {

Here you are reading each line into $data

if (/beth/) { #matches only if beth is in line

and here you are matching /beth/ against the default $_.

Is that what you meant to do?

jue

so you are saying this is no good:
$data=<$fh>

No. I am saying you should make up your mind if you want to use the default
$_ or your own $data. Either is ok, but not both.

should I putting this into an array then ?

Only if you insist on wasting memory.

jue


.



Relevant Pages

  • Re: Searching in a line
    ... splits the line. ... Now there is beth in the file but the program always ... so you are saying this is no good: ... should I putting this into an array then? ...
    (comp.lang.perl.misc)
  • Re: Searching in a line
    ... lerameur wrote: ... splits the line. ... Now there is beth in the file but the program always ...
    (comp.lang.perl.misc)
  • Re: Why so few 10ks?
    ... I am not saying that going out faster than the optimal even splits ... it is just that he's not fast enough to hold that pace. ... I don't say that a positive splits strategy necessarily produces slower times ...
    (rec.running)
  • Re: My honest thoughts on the Fallout 3 trailer...
    ... that it was all done in-engine (a subtle "what you could do in CGI we can do in real-time")? ... It's Beth way of saying that they recognize what the fanbase is after; not a complete rewrite of the universe, and not something completely different than what has come before. ...
    (comp.sys.ibm.pc.games.rpg)
  • Re: Cycling compulsory?
    ... Cardiff that splits up into two for a hundred yards or so. ... branches is no cycling, and has a sign saying that. ...
    (uk.rec.cycling)