Skip to content

Instantly share code, notes, and snippets.

@Makistos
Created October 25, 2013 12:43
Show Gist options
  • Save Makistos/7154074 to your computer and use it in GitHub Desktop.
Save Makistos/7154074 to your computer and use it in GitHub Desktop.
This is an example on how the Perl formatter works. #perl-format #perl
#!/usr/bin/perl
# This script takes something like this as input:
# ID WorkId Date
# 1 2 12-10-2009
# 2 16 01-01-2008</pre>
# And prints out this:
#+-----+----------+---------------+
#|ID |WorkId |Date |
#+-----+----------+---------------+
#|1 |2 |12-10-2009 |
#+-----+----------+---------------+
#|2 |16 |01-01-2008 |
#+-----+----------+---------------+
my $id, $workid, $date;
print
"+-----+----------+---------------+\n" .
"|ID |WorkId |Date |\n" .
"+-----+----------+---------------+\n";
format STDOUT =
|@<<<<|@<<<<<<<<<|@<<<<<<<<<<<<<<| $id $workid $date +-----+----------+---------------+ . while(<>)
{
next if (m/^ID/);
($id,$workid,$date) = split(/\t/);
write;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment