Skip to content

Instantly share code, notes, and snippets.

@thomasjpr
Created April 13, 2014 17:18
Show Gist options
  • Save thomasjpr/10593349 to your computer and use it in GitHub Desktop.
Save thomasjpr/10593349 to your computer and use it in GitHub Desktop.
pipe-to-tab.pl
#!/usr/bin/perl
use File::Basename qw(basename);
$me = basename ($0);
if ( $#ARGV < 0 )
{
print "Usage : $me <CSV File Name>\n";
exit;
}
my $IN_CSV = shift @ARGV;
my $OUT_PIPE = $IN_CSV;
$OUT_PIPE=~s/\.csv/\.txt/g;
open (OUTPUT, ">$OUT_PIPE") || die "Can not open $OUT_PIPE - $!" ;
open (INPUT, "<$IN_CSV") || die "Can not open $IN_CSV - $!" ;
while (<INPUT>)
{
$_=~ s/\|/\t/g;
print OUTPUT $_;
}
close INPUT;
close OUTPUT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment