in reply to Counting no of '>' symbol in a file
To elaborate a little as to what is going on here:
(1) The g modifier (the /g at the end of the regex ...) refer to global matching as described in this perldoc: perlre. These cause the regex to be applied repeatedly to the same string. (Also see perlretut, an excellent tutorial.)
(2) The while loops, as written, are using an implied variable ($_ ... see perlvar) which contains the most recent line read from the file. The regular expression, also, implicitly matches to that variable since no other variable was referred-to in the statement. By design, Perl allows you to say things with an economy of characters . . .
Although “TMTOWTDI = There’s More Than One Way To Do It,™” I also share the opinion that substitution isn’t necessary ... merely matching, and counting the number of matches found, as demonstrated above by choroba’s post.
HTH ...