Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: count number of lines with +

by Anonymous Monk
on Jul 22, 2014 at 09:39 UTC ( [id://1094606]=note: print w/replies, xml ) Need Help??


in reply to count number of lines with +

perl -lne '$i++ if /^+ /}{print $i' FILENAME

Replies are listed 'Best First'.
Re^2: count number of lines with +
by ladnjay (Initiate) on Jul 23, 2014 at 06:34 UTC
    thank you for the reply. but i could not got this to work.

      It's not a script meant to be saved to a file - it's a "one-liner", meaning a command that you enter on the command line (aka in your shell). That's the same place you would normally enter, for example, perl scriptfilename.pl

      String found where operator expected at 2.pl line 2, near "lne '$i++ if /^+ /}{print $i'" (Do you need to predeclare lne?) Number found where operator expected at 2.pl line 2, near "'$i++ if /^+ /}{print $i' 1" (Missing operator before 1?) syntax error at 2.pl line 2, near "lne '$i++ if /^+ /}{print $i'" Execution of 2.pl aborted due to compilation errors.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1094606]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 13:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found