DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Frank has posted 1 posts at DZone. You can read more from them at their website. View Full User Profile

Tidy Up Copy'n'paste Code Snippets From DZone

  • submit to reddit
        // remove the line numbers from DZone's copy'n'paste code snippets
#  usage : 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 = <FILE>) {
    $line =~ s/^[ ]*[0-9]*  //;
    print "$line";

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

my $infile = $ARGV[0];


Brian Tully replied on Tue, 2008/12/09 - 2:42pm

it's a real shame one has to run an external script to remove the line numbers. Why can't DZone add a simple function that allows us to download code snippet or hide line numbers?