#!/usr/bin/perl -w use strict; $_ = 'This is a string with newlines and blank lines'; my @arr = split /\n/; print map { "|$_|\n" } @arr;