From: poe@daimi.aau.dk (Peter Orbaek) Newsgroups: comp.lang.perl,alt.os.linux Subject: Perl 4.019 on Linux 0.12, problems with $&... Keywords: perl, $&, length Date: 4 Feb 92 16:00:24 GMT Organization: DAIMI: Computer Science Department, Aarhus University, Denmark I'm attempting to get perl up and running on my 386/33 running linux 0.12, using gcc 1.40 (the compiler that comes with linux). After getting through configure, and doing various small hacks in the makefile, I have got it to compile cleanly, except for minor warnings about return-types of getgrgid() and such. But problems arise when I run the test-suite. First I must say that floating point support on linux is fairly bad, so I get several failed tests because sprintf prints - for instance - 12 as 11.99999999997. This can be remedied by compiling with these options, in effect making an "integer-perl": -Ddouble=int -Datof=atoi -DINT_PERL and then doing some minor hacks in str.c and dolist.c to get proper conversions from ints to strings, and removing packing of floats and doubles. With these hacks I get fewer failed tests than with the original floatin-point perl. BUT , in both cases the produced perl fails on tests: op/pat 28,29,30 I seems that $& doesn't get set correctly. Why can this happen?? This problem also affects several other tests. At least in op/pat test #28 $& is set to the empty string or null... Another failure that seems to occur only with "integer-perl" is that the test: comp/< something...> fails, due to length('\\\\') not returning 2 or, more accurately: (length('\\\\') == 2) ==> false but $x = length('\\\\'); print $x; ==> prints 2 and print length('\\\\'); ==> prints 2 I have tried these things both with and without the perl-malloc if that matters. Suggestions anyone? Thanks in advance. - Peter (poe@daimi.aau.dk) -- Peter Orbaek ----------------- poe@daimi.aau.dk | /// Hasle Ringvej 122, DK-8200 Aarhus N, DENMARK | /// | \\\/// "Strong typing is for people with weak memories" | \XX/
From: poe@daimi.aau.dk (Peter Orbaek) Newsgroups: alt.os.linux Subject: od(1) in Perl Keywords: perl, od, linux commands Date: 11 Feb 92 12:28:49 GMT Organization: DAIMI: Computer Science Department, Aarhus University, Denmark Here is a small Perl script that implements the od(1) command. I admit that it suffers a bit from featuritis :-) - Peter (poe@daimi.aau.dk) --- snip snip --- #!/usr/local/bin/perl # od.pl - poe@daimi.aau.dk, do not copyright require 'getopt.pl'; &Getopt('w'); sub usage { print STDERR "Usage: $0 [-acdghox] [-w width] [file...]\n"; exit(1); } &usage if $opt_h; $w = $opt_w ? $opt_w : 16; if($opt_g) { $w = $w > 14 ? 14 : $w; $fmt = "%4x: " . ("%02x " x $w); $fmt2 = ("%1s" x $w) . "\n"; } elsif($opt_x) { $fmt = "%4x: " . ("%02x " x $w) . "\n"; } elsif($opt_d) { $fmt = "%4d: " . ("%3d " x $w) . "\n"; } else { $fmt = "%4x: " . ("%03o " x $w) . "\n"; } if($opt_a || $opt_c) { $fmt2 = " " . ("%1s " x $w) . "\n"; } if($#ARGV < 0) { $ARGV[0] = "<&STDIN"; } while($file = shift @ARGV) { open(FILE, $file) || next; print $file, ":\n"; $pos = 0; while(read(FILE, $buf, $w) > 0) { @bytes = unpack("C$w", $buf); @chars = (); for (@bytes) { if($_ < 32 || $_ > 126) { push(@chars, '.'); } else { push(@chars, pack("C", $_)); } } if($opt_a || $opt_c || $opt_g) { printf($fmt, $pos, @bytes); printf($fmt2, @chars); } else { printf($fmt, $pos, @bytes); } $pos += $w; } $| = 1; print ""; $| = 0; close FILE; } -- Peter Orbaek ----------------- poe@daimi.aau.dk | /// Hasle Ringvej 122, DK-8200 Aarhus N, DENMARK | /// | \\\/// "Strong typing is for people with weak memories" | \XX/