marco.shaw has asked for the wisdom of the Perl Monks concerning the following question:
Have googled around a bit. There's some solutions out there, but I want to understand what I'm trying to run.
What might I be missing below, because it doesn't seem to work on UNIX?
$ cat test1.pl #!/usr/bin/perl $string = 'test'; $inputs = 'test.txt'; open(TABLE, $inputs) or die "can't open $inputs.\n"; while ( $line = <TABLE> ) { if ( $_ =~ $string ) { print $_; } } close(IN); $ cat test.txt test tst $
In the end, I'm looking to match a string, but then have it return the 2nd portion. The file I'm searching will be of the form:
something:somethingelse
I want to search for "something", but have "somethingelse" returned (after the colon).
Edit: g0n - code tags & formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Searching through a file
by ikegami (Patriarch) on Sep 05, 2007 at 18:25 UTC | |
by mr_mischief (Monsignor) on Sep 05, 2007 at 18:33 UTC | |
|
Re: Searching through a file
by mr_mischief (Monsignor) on Sep 05, 2007 at 18:13 UTC | |
|
Re: Searching through a file
by dwm042 (Priest) on Sep 05, 2007 at 19:30 UTC | |
|
Re: Searching through a file
by FunkyMonk (Bishop) on Sep 05, 2007 at 21:31 UTC | |
|
Re: Searching through a file
by toolic (Bishop) on Sep 05, 2007 at 17:52 UTC | |
|
Re: Searching through a file
by klekker (Pilgrim) on Sep 06, 2007 at 10:39 UTC |