Skip to content

Instantly share code, notes, and snippets.

@lsd
Created May 27, 2013 14:13
Show Gist options
  • Save lsd/5657282 to your computer and use it in GitHub Desktop.
Save lsd/5657282 to your computer and use it in GitHub Desktop.
mta
# one-liner example:
# perl -e '$r="1346518,CLOSED,04/09/2013 12:00:00 AM,136 EAST 27 STREET,1018152,555,,49,SPOPS,05/24/2013 12:00:00 AM,A8,05/22/2013 12:00:00 AM"; print "$r (orig)\n"; $rand=int(rand 5)+1; $r =~ s/(,[0-9]{7},)[0-9]+(,,..)/\1$rand\2/; print $r;'
# I broke it up into lines to make it easier to understand
$rand = int(rand 5) + 1;
$row = "1346518,CLOSED,04/09/2013 12:00:00 AM,136 EAST 27 STREET,1018152,555,,49,SPOPS,05/24/2013 12:00:00 AM,A8,05/22/2013 12:00:00 AM";
print "$row (old)\n";
$row =~ s/(,[0-9]{7},)[0-9]+(,,..)/\1$rand\2/;
print "$row (new)\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment