#!/usr/bin/perl -w use strict; my @file_contents; $file_contents[0] = 'My name is $name.'; $file_contents[1] = 'I live in the city of $city.'; $file_contents[2] = '$city is in the state of $state.'; my $file_contents = join("\n", @file_contents); my %stuff_to_parse = ( name => 'Gryphon', city => 'Seattle', state => 'Washington' ); foreach (keys %stuff_to_parse) { $file_contents =~ s/\$$_\b/$stuff_to_parse{$_}/g; } @file_contents = split(/\n/, $file_contents); foreach (@file_contents) { print $_, "\n"; }