Platinum Partner

Tidy Up Copy'n'paste Code Snippets From DZone

// remove the line numbers from DZone's copy'n'paste code snippets

#!/usr/bin/perl
#
#  usage :  dzone.pl copy_and_paste_file
#           copy_and_paste_file - file which contain the code snippet from DZone website

sub dzone_tidy {
  my ($infile) = @_;
  open(FILE, "< $infile") || die "ERROR: failed to open file: '$infile'";
  while (my $line = ) {
    $line =~ s/^[ ]*[0-9]*  //;
    print "$line";
  }
  close(FILE);
}

if ( $#ARGV ne 0 )
{
  print "ERROR: wrong number of parameters\n\n";
  exit(1);
}

my $infile = $ARGV[0];
dzone_tidy(${infile});
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}