Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Copy rows of file to new document

by phineas629 (Novice)
on Jan 25, 2013 at 03:33 UTC ( #1015260=note: print w/replies, xml ) Need Help??


in reply to Re: Copy rows of file to new document
in thread Copy rows of file to new document

My folder of files is 'c:\vehicles'. The file I want to write to is 'vehicles.txt' and located in 'c:\'. I tried the following code work for what you suggested. I know I've written it wrong. What should I do to correct it?

C:\vehicles $ ls -A | xargs head -qn 30 | perl -Mstrict -wne 'if( $ + +_ =~ /(make)|(model)|(year)/ ) { print "$_"; }' > vehicles.txt grep -rE "(make|model|year)" c:

Replies are listed 'Best First'.
Re^3: Copy rows of file to new document
by BrowserUk (Pope) on Jan 25, 2013 at 07:39 UTC

    What is $ +_? Do you mean $_?

    If so, then you can omit it and use just: 'if( /(make)|(model)|(year)/ ) { print "$_"; }'.

    Whether that fixes all your problems I doubt; but its one less to deal with.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: Copy rows of file to new document
by tmharish (Friar) on Jan 25, 2013 at 06:24 UTC

    Only works on Linux

      What if I have cygwin?

        Please don't change the title of a node/thread.

        If you must, add something to the title (at the end).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015260]
help
Chatterbox?
[Discipulus]: thanks i definetively must learn such stuff.. i must come out with a killing product and after i'll just do Perl elctronic and music.. ;=)
marto has a similar idea on the 'to do' list
[Discipulus]: 65-35 joint venture marto? ;=)
[choroba]: Fibonacci at 34!
[marto]: Discipulus, what did you have in mind?
[marto]: sort of related, have you seen sonic pi
[Discipulus]: choroba less than perl -le ' $==1,(1 x $_)=~/(^)(1|11\1 )*(?{$=++})^/, print $= for 0..10'?? congrats

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2017-10-17 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (225 votes). Check out past polls.

    Notices?