#!/usr/bin/env perl use strict; use warnings; my $char = shift || die $!; my $file = $0; open( my $fh, "<", $file ) || die $!; while (<$fh>) { print if /^o/; # your part goes here } close $fh; __END__