Repeat Perl Script

Wrote this 7 line simple perl script a while ago. I can’t believe how many times this has come in very handy. Simply create an ‘in.txt’ file and separate your variables with a newline. Adjust the print statement to reflect what you’ll want to do and pipe the output to a file. Perfect for creating other scripts.

#!/usr/bin/perl

#
# syntax: ./repeat >> out.txt
# create in.txt with a newline seperated list of variables
# output to a text file, use the print statement below to format
# your output.
#

$fname = “in.txt”;
open(FILE, $fname) || die(“Could not open $fname”);
while( <FILE> ) {
chomp($_);
print “Prepend Variable: $_ \n”;
}
close(FILE);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: