#!/usr/bin/perl use warnings; use strict; my $string="Hello"; { local @ARGV = ("$ARGV[0]"); local $^I = '.bac'; while(<>){ if ($. == 1) { # if line no is 1 print "$string$/"; print; # Also print the current line } else { print; } } }