Three Quick Perl Snippets

I need three very short perl scripts written for some miscellaneous file manipulation and sys admin work I am doing.

You must replace ^^^^ with the AT sign within this message. Scriptlance does now allow the AT sign within posts.

Perl Script 1. Find all email addresses that match domain within this file

I have a file that looks like this with thousands of lines…

21635702 10 125.224.79.116 22:36:58 –:–:– (now) Idle Ready aronshow1451^^^^DOMAIN.COM nita71214^^^^yahoo.com.tw show headers
21636502 8 125.224.74.10 22:34:28 –:–:– (now) Idle Ready gddj9047^^^^DOMAIN.COM a0926821072^^^^yahoo.com.tw show headers

Open file (allow me to define file name at top) and pattern match ^^^^DOMAIN.COM, and also select the data (username) before ^^^^DOMAIN.COM until the white space. Then print this email address within a text file (allow me to define file name at top) , 1 email address per line… Therefore, using the data above the text file will look like this:

aronshow1451^^^^DOMAIN.COM
gddj9047^^^^DOMAIN.COM

Perl Script 2. Find all email addresses that match domain within this file

I have a file that looks like this with thousands of lines…

niedr1o94go^^^^DOMAIN.COM 14% 717mb 5.0gb
br7zuchacz^^^^DOMAIN.COM 13% 701mb 5.0gb

Open file (allow me to define file name at top) and pattern match ^^^^DOMAIN.COM, and also select the data (username) before ^^^^DOMAIN.COM until beginning of line. Then print this email address within a text file (allow me to define file name at top), 1 email address per line… Therefore, using the data above the text file will look like this:

niedr1o94go^^^^DOMAIN.COM
br7zuchacz^^^^DOMAIN.COM

Perl Script 3. I need a different perl script to run a system command with data taken from a file line by line.

I have a file that looks like this with thousands of lines:

aronshow1451^^^^DOMAIN.COM
gddj9047^^^^DOMAIN.COM

Define the file name within the perl script at the top as data.txt

For each line within the data.txt file run this unix system command:

“blah $dataline”

I will replace “blah” with the real system command.

Leave a Reply

Your email address will not be published. Required fields are marked *