Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: for loop to get the 3rd index

by cbro (Pilgrim)
on Jun 06, 2003 at 14:02 UTC ( #263671=note: print w/replies, xml ) Need Help??


in reply to Re: for loop to get the 3rd index
in thread for loop to get the 3rd index

There are some problems with your solution.
1. To get your match into $1, it should be m/(matchingStuff)/. That is, there needs to be parens.

2. Your 'if' statement should be if ($match_count == 3). This is a numerical comparison.
Try this:
my @matches; open (F,"files.txt") || die ("Couldn't open file: $!\n"); while(<F>) { chomp; if (/matchingstffHere/) { push(@matches, $_); } } close(F); if (scalar(@matches) >= 3) { print "Needed = $matches[2].\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://263671]
help
Chatterbox?
[Corion]: Whee! Germanys Grand Central Airport (for Berlin, re-scheduled for the thrid or fourth time, to open now in 2018) has just fired their technical lead
[ambrus]: Corion: Is their budget estimate four times the initial estimate yet? Was the construction late by six months already three months after they started?
[marto]: I'll believe it when I see it. That's been due for many years now :P
[marto]: oddly the last time I was there I saw a zeppelin in flight for the first time
[Corion]: ambrus: I don't know how far the budget estimate has been overrun yet

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2017-02-23 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (345 votes). Check out past polls.