JasonDaly.name

PHP, Ruby, Symfony, Rails, Doctrine, MooTools. Web Development.

Posts tagged with "perl"

February 26, 2010

Parsing Email Addresses From a Log File

Recently I needed to parse all unique email addresses from a very large plaintext log file. A simple grep would not suffice because there were many cases where multiple email addresses appeared on the same line.

Realizing there are many solutions to this problem, here is the one I came across1 which I found most suitable for my needs.

perl -wne'while(/[\w\.\-]+@[\w\.\-]+\w+/g){print "$&\n"}' path/to/log_file | sort -u > parsed_unique_sorted_emails.txt

2 notes Tags: perl bash email parsing tips

February 25, 2009

Making AppleTV Encoded Video Files PlayStation 3 Compatible

Using Handbrake to rip DVDs, I use a slight customization of the default AppleTV encoding settings. I find the quality-to-filesize ratio is great for nearly zero setup time. But when trying to play the encoded .mp4 video files on my PlayStation 3, the video format was unrecognized.

Running this1 over a movie.mp4 AppleTV encoded movie fixes this issue, while still maintaining compatibility with AppleTV.

perl -pi.bak -e "s|(avcC.{3}).(.{7}).|1x292x29|" movie.mp4

In the case where I have ripped one of my DVDs of TV show episodes and am left with multiple .mp4 files requiring this fix, I run this script from within the folder

#!/usr/bin/bash

for file in `find . -type f -name *.mp4`;
do
    perl -pi.bak -e "s|(avcC.{3}).(.{7}).|1x292x29|" $file;
done;

  1. Here is the link to the original forum thread where I found this information. Thanks, Paul! 

Tags: appletv dvd encoding apple bash perl playstation ps3 code mp4 tv handbrake mac