#!/usr/bin/perl use strict; use warnings; my ($o, $c) = 0, 0; while(<>) { /\{/ and $o++; /\}/ and $c++; } print 'opening curled brackets: ' . $o . "\n"; print 'closing curled brackets: ' . $c . "\n";