toarray.pl 277 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/perl -w

my $FILENAME = $ARGV[0];

open FILE, $FILENAME or die "Cannot open $FILENAME";

my $ARRAYNAME = $ARGV[1];
print "static const char $ARRAYNAME\[\] =";
while (<FILE>) {
    s@\\@\\\\@g;
    s@"@\\"@g;
    chomp ($_);
    print "\n  \"$_\\n\"";
}
print ";\n";