Skip to content

Instantly share code, notes, and snippets.

@MrTrick
Created August 11, 2011 03:03
Show Gist options
  • Save MrTrick/1138828 to your computer and use it in GitHub Desktop.
Save MrTrick/1138828 to your computer and use it in GitHub Desktop.
<?
//Given MSA files, report for each the semesters.
array_shift($argv);
if (!$argv) $argv = array('php://stdin');
foreach ($argv as $file) {
$in = new SplFileObject($file, 'r');
$semesters = array();
foreach($in as $l)
if (preg_match('/\d{5}_([^_]+)_.*\|(\d{4})$/',$l,$m))
$semesters[$m[2].'_'.$m[1]] = true;
ksort($semesters);
echo $file.': '.implode(" ",array_keys($semesters))."\n";
unset($in);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment