Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Using grep to pick out lines in a text file

by balakrishnan (Monk)
on Dec 19, 2008 at 09:14 UTC ( #731489=note: print w/replies, xml ) Need Help??


in reply to Using grep to pick out lines in a text file

This could be a useful if you are wondering the solution with minimal number of lines.
open( INPUTFILE, "<WordNet.txt" ) or die "$!"; open( OUTPUTFILE, ">>WordNetTest2.txt" ) or die "$!"; grep { /adj:/ and print OUTPUTFILE $prev,$_;$prev=$_ } (<INPUTFILE>) +;

Replies are listed 'Best First'.
Re^2: Using grep to pick out lines in a text file
by lostjimmy (Chaplain) on Dec 19, 2008 at 16:28 UTC

    I disagree that this is at all helpful for someone who is just picking up the language (and programming at that!).

    Also, isn't grep going to read in the entire contents of the file? That is completely unnecessary for this task.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://731489]
help
Chatterbox?
shmem doesn't have mp3info, but mp3info2 - which is a perl script ;-)
[marioroy]: my @music_times = qx(find \$HOME/Music/ Albums/ -type f -iname '*.mp3' -exec mp3info -p "%S\\\n" {} \\;);
[marioroy]: might need 2 or 3 backslash for \n. Also \\;
[Lady_Aleena]: shmem, there is MP3::Info/
[Discipulus]: too much complex qx when you know perl are better to avoid
[marioroy]: might need to backslash \'*.mp3\'
[marioroy]: It's a quoting issue inside qx. It's File::Find or qx. LA chooses qx. Almost there.
[marioroy]: Also \"%S\\\n\" oh my, not fun.
[Discipulus]: good night folks
[marioroy]: I will make a mp3info script that takes the -p "%S\n" args and test qx. I'm on the road, so will come back.

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2017-04-23 21:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.