Skip to content
Browse files

cleaned up Perl code.

  • Loading branch information...
1 parent 5b98407 commit 9c1ab02490455afdadd8a8fe6cb412da93f1dba3 @akrennmair committed Sep 14, 2010
Showing with 30 additions and 22 deletions.
  1. +5 −3 doc/gen-example-config.pl
  2. +8 −6 doc/generate.pl
  3. +8 −6 doc/generate2.pl
  4. +9 −7 txt2h.pl
View
8 doc/gen-example-config.pl
@@ -1,11 +1,13 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
+
+use strict;
print "####################################\n";
print "# newsbeuter example configuration #\n";
print "####################################\n\n";
-while ($line = <STDIN>) {
- ($option,$syntax,$defaultparam,$desc,$example) = split(/\|/, $line);
+while (my $line = <STDIN>) {
+ my ($option,$syntax,$defaultparam,$desc,$example) = split(/\|/, $line);
if ($defaultparam ne "n/a") {
print "## configuration option: " . $option . "\n";
if ($desc =~ /limitation in AsciiDoc/) {
View
14 doc/generate.pl
@@ -1,16 +1,18 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
-if ($#ARGV != 0) {
+use strict;
+
+if (scalar(@ARGV) != 0) {
print STDOUT "usage: $0 <dsv-file>\n";
exit(1);
}
-open(FILE,$ARGV[0]) or die "couldn't open $ARGV[0]: $!\n";
+open(my $fh, '<', $ARGV[0]) or die "couldn't open $ARGV[0]: $!\n";
-while ($line = <FILE>) {
+while (my $line = <$fh>) {
chomp($line);
- @fields = split(/\|/, $line);
+ my @fields = split(/\|/, $line);
print "'$fields[0]' (parameters: $fields[1]; default value: '$fields[2]')::\n $fields[3] (example: $fields[4])\n\n";
}
-close(FILE);
+close($fh);
View
14 doc/generate2.pl
@@ -1,16 +1,18 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
-if ($#ARGV != 0) {
+use strict;
+
+if (scalar(@ARGV) != 0) {
print STDOUT "usage: $0 <dsv-file>\n";
exit(1);
}
-open(FILE,$ARGV[0]) or die "couldn't open $ARGV[0]: $!\n";
+open(my $fh, '<', $ARGV[0]) or die "couldn't open $ARGV[0]: $!\n";
-while ($line = <FILE>) {
+while (my $line = <$fh>) {
chomp($line);
- @fields = split(/:/, $line, 3);
+ my @fields = split(/:/, $line, 3);
print "'$fields[0]' (default key: '$fields[1]')::\n $fields[2]\n\n";
}
-close(FILE);
+close($fh);
View
16 txt2h.pl
@@ -1,29 +1,31 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
+
+use strict;
+use File::Basename;
if (length(@ARGV) < 1) {
print STDOUT "usage: $0 <stflfile> [<extension>]\n";
exit(1);
}
-$filename = $ARGV[0];
-$extension = $ARGV[1];
-$id = `basename $filename $extension`;
+my ($filename, $extension) = @ARGV;
+my $id = basename($filename, $extension);
chomp($id);
-open(FILE,$ARGV[0]) or die "couldn't open $ARGV[0]: $!\n";
+open(my $fh, '<', $filename) or die "couldn't open $filename: $!\n";
print "#ifndef ${id}__h_included\n";
print "#define ${id}__h_included\n";
print "\n";
print "static char ${id}_str[] = \"\" ";
-while ($line = <FILE>) {
+while (my $line = <$fh>) {
$line =~ s/"/\\"/g;
chomp($line);
print "\"$line\\n\"\n";
}
-close(FILE);
+close($fh);
print ";\n";

0 comments on commit 9c1ab02

Please sign in to comment.
Something went wrong with that request. Please try again.