[11498] in Perl-Users-Digest
Perl-Users Digest, Issue: 5098 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 9 23:07:26 1999
Date: Tue, 9 Mar 99 20:00:17 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 9 Mar 1999 Volume: 8 Number: 5098
Today's topics:
Re: [HOW TO?] Strip all but certain characters from a s <Jason@InsideMedicine.com>
bug in Cookbook recipe 20.03?? (Peter Bismuti)
Can I turn a Perl program into an NT .exe? leonandrews@my-dejanews.com
can not use 'use std_lib_mod' <achalegu@shrike.depaul.edu>
Re: can not use 'use std_lib_mod' fxia@yahoo.com
Re: Can't kill Perl script with CTRL-C (Clinton Pierce)
Re: database search script - a modification needed <staffan@ngb.se>
Re: Days in Month array (Abigail)
Re: Days in Month array fxia@my-dejanews.com
FAQ 3.17: How can I make my Perl program take less memo <perlfaq-suggestions@perl.com>
FAQ 3.18: Is it unsafe to return a pointer to local dat <perlfaq-suggestions@perl.com>
Re: file extension .pl <ankadakia@hotmail.com>
Re: length of a string. <msholund@bigfoot.com>
Re: MS ACCESS database with perl leonandrews@my-dejanews.com
Open Source compiling Perl: *NIX & wintel ??? <mds-resource@mediaone.net>
Re: Perl & PostgreSQL <staffan@ngb.se>
Re: RTF=>HTML with extracted GIFs or JPEGs (Michael Smith)
SRC: {unix,mac,cpm}2{unix,mac,cpm} converters <tchrist@mox.perl.com>
Re: TECO *is* obfuscation (was does perl discourage obf <cassell@mail.cor.epa.gov>
Re: y2k and 4-digit dates (was Re: foreach and while) (Abigail)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 9 Mar 1999 20:12:09 -0500
From: "Jason Hatcher" <Jason@InsideMedicine.com>
Subject: Re: [HOW TO?] Strip all but certain characters from a string
Message-Id: <7c4gte$eek@enews2.newsguy.com>
Thank you all for the great responses .... I can always count on a helping
hand here!!!
Jason
------------------------------
Date: 10 Mar 1999 03:43:08 GMT
From: bismuti@cs.fsu.edu (Peter Bismuti)
Subject: bug in Cookbook recipe 20.03??
Message-Id: <7c4poc$b90$1@news.fsu.edu>
This is the script:
use LWP::Simple;
use HTML::LinkExtor;
$header = "http://";
$base_url = $header . $ARGV[0];
$parser = HTML::LinkExtor->new(undef,$base_url);
$parser -> parse(get($base_url))->eof;
@links = $parser->links; print "links = @links\n";
foreach $linkarray (@links){
my @element = @$linkarray; print "element = @element\n";
my $elt_type = shift @element;
while (@element){
my ($attr_name,$attr_value) = splice(@element,0,2);
$seen{$attr_value}++;
}
}
for (sort keys %seen){print $_, "\n"}
Now try it on:
http://www.cs.fsu.edu/~bismuti/FORTRAN/NONSPECIALISTS/CLASSNOTES/subroutines.html
http://www.cs.fsu.edu/~bismuti/FORTRAN/NONSPECIALISTS/CLASSNOTES/compilers.html
Niether case should return any links, however the second returns a link
to itself while the first returns nothing. I can't see any difference
between the two files. Anyone know what is going on???? Thanks.
_____________________________________________________________________
| |
| Pete Bismuti |
| Department of Computer Science |
| Florida State University |
| bismuti@cs.fsu.edu (850) 644-0516 |
|_____________________________________________________________________|
------------------------------
Date: Wed, 10 Mar 1999 00:03:29 GMT
From: leonandrews@my-dejanews.com
Subject: Can I turn a Perl program into an NT .exe?
Message-Id: <7c4csc$c1c$1@nnrp1.dejanews.com>
Hi,
Can anyone point me towards some documentation on compiling perl programs on
NT into standalone executables? I'm using ActivePerl 509 on NT4.
many thanks,
Leon.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 09 Mar 1999 18:13:32 -0600
From: achalegu <achalegu@shrike.depaul.edu>
Subject: can not use 'use std_lib_mod'
Message-Id: <36E5B92C.53D92DD@shrike.depaul.edu>
I have a general guest book web page to collect interesting info. The CGI
script takes advantage of CGI.pm to parse the variables. It worked for the
last two months.
However, it does not permit me use 'use CGI or whatever-modules' right now.
Offline executing the script is OK with 'use CGI' but it can not be online.
Without 'use std-mod', the script just works fine. But when I 'use
module-name', then the web server will generate the 'server error' message
which indicates it may be due to misconfiguration.
Please advise me if there is any relationship between Web server
configuration and Perl 'use module'?
What went wrong?
Thanks a lot.
Ray
------------------------------
Date: Wed, 10 Mar 1999 02:25:56 GMT
From: fxia@yahoo.com
Subject: Re: can not use 'use std_lib_mod'
Message-Id: <7c4l7b$j5m$1@nnrp1.dejanews.com>
Could it be that modules are installed not in standard dirs and
PERL5LIB environment not set in your web server configuration?
Fred Xia
In article <36E5B92C.53D92DD@shrike.depaul.edu>,
achalegu <achalegu@shrike.depaul.edu> wrote:
> I have a general guest book web page to collect interesting info. The CGI
> script takes advantage of CGI.pm to parse the variables. It worked for the
> last two months.
>
> However, it does not permit me use 'use CGI or whatever-modules' right now.
> Offline executing the script is OK with 'use CGI' but it can not be online.
> Without 'use std-mod', the script just works fine. But when I 'use
> module-name', then the web server will generate the 'server error' message
> which indicates it may be due to misconfiguration.
>
> Please advise me if there is any relationship between Web server
> configuration and Perl 'use module'?
> What went wrong?
>
> Thanks a lot.
>
> Ray
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 10 Mar 1999 03:39:20 GMT
From: clintp@geeksalad.org (Clinton Pierce)
Subject: Re: Can't kill Perl script with CTRL-C
Message-Id: <36e5e939.83694255@news.roalok1.mi.home.com>
On Tue, 09 Mar 1999 18:30:01 -0500, Alfred von Campe
<alfred@ascend.com> wrote:
> $status = system("cd $_; /usr/atria/bin/clearmake all");
>
>If I hit CTRL-C while my script is in the system() call, the clearmake
>does end right away, but the script doesn't die. The status returned
>from system() is almost always 0x8200 (and sometimes 0x8400). According
>to the Camel book, system() will return with the lower 8 bits set to
>something if the process recevied a signal. Any ideas what's going on?
Silly, silly question but are you sure that "clearmake" isn't doing
some signal-handling of its own?
--
"If you rush a Miracle Man, you get rotten miracles"
--Miracle Max, The Princess Bride
http://www.geeksalad.org
------------------------------
Date: Wed, 10 Mar 1999 02:54:38 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: database search script - a modification needed
Message-Id: <36E5D0DE.C3CE0423@ngb.se>
cathal coughlan wrote:
> I wonder if anyone could find the time to help me out with this
> script.
> #!/bin/perl
Maybe add a -w? Perhaps use strict too.
> print "Content-type: text/html\n\n";
Id suggest to use here-docs instead. It _might_ also be a good idea to
keep all the layout implemented in one place, for instance in the end of
the script, as a giant heredoc with variables in it. Or even have the
layout as a separate file. Intermixing layout and program makes the
program more difficult to maintain, and the layout _much_ harder to
update...
Now, before the while, add a @results containing the lines that match.
If the file isn't too large, I'd read the whole file into @results and
use grep. You read it into @results (record by record) by doing
{ local $/ = undef;
$file = <DATA>;
@results = split(/\n\s*\n/, $file);
}
If you know there will be no spaces on the lines between the recs, you
can do
{ local $/ = '';
@results = <DATA>;
}
And now you do something like this
while (($tag, $search) = each %searches){
@results = grep { /$tag:[^\n]*\b$search/i } @results;
}
%searches should look like this (create it from %in):
{ 'First Name' => 'John',
'Last Name' => 'Doe' }
So the above while statement goes through the records, and throw away
those that don't contain the first match. Then it goes through those
that are left, and throw away those that don't contain the second match.
Neat, huh?
I assume that your file looks like this:
First Name: John
Last Name: Doe
First Name: Foo
Last Name: Bar
HTH
Staffan
------------------------------
Date: 10 Mar 1999 01:26:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Days in Month array
Message-Id: <7c4hne$m1m$2@client2.news.psi.net>
Charles R. Thompson (design@raincloud-studios.com) wrote on MMXVI
September MCMXCIII in <URL:news:a3gF2.224$0l4.330@news.rdc1.tn.home.com>:
@@
@@ How does one calculate if a given year is a leap year?
By checking whether the day following Feb 28 is in February.
sub is_leap {
require Time::Local;
my $year = shift;
my $time = Time::Local::timelocal (0, 0, 12, 28, 1, $year);
my $date = localtime ($time + 24 * 60 * 60);
substr ($date, 4, 3) eq 'Feb';
}
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: Wed, 10 Mar 1999 02:18:38 GMT
From: fxia@my-dejanews.com
Subject: Re: Days in Month array
Message-Id: <7c4kpm$imo$1@nnrp1.dejanews.com>
You can just use Date::Calc package.
There is a function, among many more other very useful ones,
leap_year($year). It returns true if the year is a leap year.
Fred Xia
In article <36E5AC9A.D96C7F7A@giss.nasa.gov>,
jglascoe@giss.nasa.gov wrote:
> "David L. Cassell" wrote:
> >
> > Errm, didn't you forget to check whether years ending in '00' are
> > leap years? And please, let's not fork a child on 'whether the
> > year 2000 is a leap year'. <snip>
>
> hmph. Sorry, I think this is right:
>
> print "biz!\n" unless $year % 4 or not $year % 100 and $year % 400;
>
> Jay Glascoe
> --
> http://www.giss.nasa.gov/cgi-bin/csci/change.pl
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 9 Mar 1999 18:15:25 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 3.17: How can I make my Perl program take less memory?
Message-Id: <36e5c7ad@csnews>
(This excerpt from perlfaq3 - Programming Tools
($Revision: 1.33 $, $Date: 1998/12/29 20:12:12 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq3.html
if your negligent system adminstrator has been remiss in his duties.)
How can I make my Perl program take less memory?
When it comes to time-space tradeoffs, Perl nearly always prefers
to throw memory at a problem. Scalars in Perl use more memory
than strings in C, arrays take more than that, and hashes use
even more. While there's still a lot to be done, recent releases
have been addressing these issues. For example, as of 5.004,
duplicate hash keys are shared amongst all hashes using them, so
require no reallocation.
In some cases, using substr() or vec() to simulate arrays can be
highly beneficial. For example, an array of a thousand booleans
will take at least 20,000 bytes of space, but it can be turned
into one 125-byte bit vector for a considerable memory savings.
The standard Tie::SubstrHash module can also help for certain
types of data structure. If you're working with specialist data
structures (matrices, for instance) modules that implement these
in C may use less memory than equivalent Perl modules.
Another thing to try is learning whether your Perl was compiled
with the system malloc or with Perl's builtin malloc. Whichever
one it is, try using the other one and see whether this makes a
difference. Information about malloc is in the INSTALL file in
the source distribution. You can find out whether you are using
perl's malloc by typing `perl -V:usemymalloc'.
--
": fighting for peace is like fucking for virginity (ado@bigcomm.gun.de)
Yes, but I did manage to increase the amount of virginity in the world
by that method." --Larry Wall
------------------------------
Date: 9 Mar 1999 20:45:28 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 3.18: Is it unsafe to return a pointer to local data?
Message-Id: <36e5ead8@csnews>
(This excerpt from perlfaq3 - Programming Tools
($Revision: 1.33 $, $Date: 1998/12/29 20:12:12 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq3.html
if your negligent system adminstrator has been remiss in his duties.)
Is it unsafe to return a pointer to local data?
No, Perl's garbage collection system takes care of this.
sub makeone {
my @a = ( 1 .. 10 );
return \@a;
}
for $i ( 1 .. 10 ) {
push @many, makeone();
}
print $many[4][5], "\n";
print "@many\n";
--
"Sometimes I wonder if men and women really suit each other. Perhaps they
should live next door and just visit now and then."
--Katherine Hepburn
------------------------------
Date: Wed, 10 Mar 1999 00:08:59 GMT
From: ankadakia <ankadakia@hotmail.com>
Subject: Re: file extension .pl
Message-Id: <7c4d6k$c6p$1@nnrp1.dejanews.com>
Also in Explorer, you can add *.pl extension.
Open Explorer -> View -> Folder Options-> File Types -> New Type ->
1. Description of type : Perl File
2. Associated Extension:pl
Actions: -> New ..
Action:anything you want : open or edit or whatever
Application:notepad (make sure to give the full path)
You can also change the icon for the perl file.
and set this action as default (it is automatic if none others are there.)
This is a useful method, I have tried for many extesions.
In article <7bts0e$lu4$1@fox.comm.net>,
"Brent Cornwell, Pediatrics Computer Administrator"
<bcornwell@mail.peds.lsumc.edu> wrote:
> what i find works the best is to create a NotePad shortcut in my SendTo
> folder, to send the file to NotePad for a simple "rightclick, Send To,
> NotePad"
>
> Win95's SendTo folder is under the Windows folder
> WinNT's sendto folder is under the user's profile folder
>
> Brent Cornwell, Computer Support Administrator
> Pediatrics Department, LSU Medical
>
> deltabob wrote in message <36e2072d.8429686@news.telis.org>...
> > I have a file with a .PL extension. Can
> >anyone tell what I need to read this file? I am
> >using win95B.
> > Thanks for any help
> > deltabob
>
>
||Beautify|||||||||||||||
||||||||||Your|||||||||||
||||||||||||||Existance||
||ANK||||||||||||||||||||
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 09 Mar 1999 19:35:44 -0500
From: "Mark D. Sholund" <msholund@bigfoot.com>
To: steven@filipowicz.com
Subject: Re: length of a string.
Message-Id: <36E5BE5F.E5A72F40@bigfoot.com>
Taking the statement by itself ($fields[9] has never had anything in it)
I can execute this statment and print the contents of $fields[9] to show
that it contains "nocar.jpg"
Have you previous cleared this array element? If you've cleared it, are
you should you cleared it so that the length is 0?
if (length ($fields[9]) == 0) { $fields[9] = "nocar.jpg"};
print "$fields[9]\n";
$fields[9] = "";
if (length ($fields[9]) == 0) { $fields[9] = "car.jpg"};
print "$fields[9]\n";
I did this and it prints
nocar.jpg
car.jpg
--
in accordance with prophecy.
"Computer, install a recursive algorithm."
- Ensign Harry Kim
------------------------------
Date: Wed, 10 Mar 1999 02:29:02 GMT
From: leonandrews@my-dejanews.com
Subject: Re: MS ACCESS database with perl
Message-Id: <7c4ld4$j6p$1@nnrp1.dejanews.com>
It's easy, so long as you are reasonably proficient with Perl and can get to
grips with some documentation.
You need ActivePerl 509 from http://www.activestate.com
install DBD-ODBC and DBI using the ppm installer supplied with ActivePerl,
set up an ODBC system DSN in control panel, and away you go.
In fact, that's exactly what I did this morning, and it works very well. Give
me a shout if you want more help,
Leon.
In article <7c0k8o$rjc$1@xenon.inbe.net>,
"Nicolas Malfeyt" <nicolasm@luon.be> wrote:
> Is it possible and how hard would it be to send some kind of SQL query to an
> MS ACCESS database residing on your webserver with Perl, and then using the
> results in your web application?
>
> Thanks,
>
> Nicolas Malfeyt
> nicolasm@luon.com
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 09 Mar 1999 20:54:37 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Open Source compiling Perl: *NIX & wintel ???
Message-Id: <36E5DEED.3AFDAB80@mediaone.net>
I'm frustrated.
I'm developing for a large heterogenous environment: several *NIX (AIX,
HPUX, NCR, Solarix) *and* wintel (95, 98 & NT) platforms, with hundreds
of systems on each.
I'd hoped to take one (1) Perl source, compile it once for each
platform, controlling compile options and modules, and work with one (1)
known Perl all with an Open Source perspective. Of course, in the OSS
tradition, I want the compiler also to be OSS ;)
With *NIX, gcc comes to the rescue, and all is well.
Unfortunately, wintel is quite another story. My best Perl is compiled
with EGCS, and the core functions as expected, considering the obvious
differences between wintel and *NIX. However, with this EGCS compiled
Perl, I am *not* able to use CPAN. Nor am I able to `dmake' several
common modules, such as libnet nor libwin32.
Of course, many have chided me for not using the ActiveState binaries.
Yes, they work; but, it defeats my original intent of being in control
of Perl -- that is no longer truly OSS. Nor can I update to newer Perls
as I see fit.
How have others of you handled this? What are the alternatives to
ActiveState Perl on wintel -- without a proprietary compiler, such as VC
or BCC?
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: Wed, 10 Mar 1999 02:03:19 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Perl & PostgreSQL
Message-Id: <36E5C4D7.1417FE09@ngb.se>
Daniel Grisinger wrote:
>
> Staffan Liljas <staffan@ngb.se> writes:
>
> > Check out PG.pm at http://www.postgresql.org/docs/Pg.pm.shtml
>
> PG.pm is probably not the best solution for working with
> Postgres anymore. I'd highly recommend using DBI and
> DBD::Pg instead.
Ouupps.. Thanks for the info. I see it's easily found on CPAN. What are
the advantages? Is it mainly the fact that it's more or less independent
of PostgreSQL making it easier to switch database, or does it have
something else as well?
Staffan
------------------------------
Date: 10 Mar 1999 01:06:29 GMT
From: smith@io.com (Michael Smith)
Subject: Re: RTF=>HTML with extracted GIFs or JPEGs
Message-Id: <slrn7ebheb.kmh.smith@schultz-2.io.com>
On Tue, 9 Mar 1999 22:28:49 +0300, Michael Yevdokimov
<flanker@sonnet.ru> wrote:
>Does anyone know how to convert RTF (with pics inside) to HTML (with
>extracted pics) using normal Perl (not from ActiveState) and without
>using CGI.pm or any libs like this.
>
>Note that I can use only features of Perl package, cgi_lib.pl and
>scripts like cgi_lib.pl...
Can't you use RTFtoHTML? It's a great tool, and will run on just
about any platform. If you're not already familiar with it, you
should take a look: <http://www.sunpack.com/RTF/>.
--
Michael Smith Austin, Texas
smith@io.com
------------------------------
Date: 9 Mar 1999 19:05:36 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: {unix,mac,cpm}2{unix,mac,cpm} converters
Message-Id: <36e5d370@csnews>
#!/usr/bin/perl -w
# nlcvt - convert newline notations
# Tom Christiansen, 9 March 1999
# "The most brilliant decision in all of Unix was
# the choice of a *single* character for the
# newline sequence. --Mike O'Dell, only half jokingly
use strict;
END {
close STDOUT || die "$0: can't close stdout: $!\n";
$? = 1 if $? == 255; # from die
}
my(
$src, # input format style
$dst, # output format style
%format, # table of conversion
$errors, # file input errors
);
$errors = 0;
%format = (
# the good...
"unix" => "\cJ", # CANON
"plan9" => "\cJ",
"inferno" => "\cJ",
"linux" => "\cJ", # some people don't get it
"bsd" => "\cJ", # some people don't get it
"be" => "\cJ",
"beos" => "\cJ",
# the not so good, but still ok...
"mac" => "\cM", # CANON
"apple" => "\cM",
"macintosh" => "\cM",
# and the really unbelievably idiotic...
"cpm" => "\cM\cJ", # CANON
"cp/m" => "\cM\cJ", # could be in first arg
"dos" => "\cM\cJ",
"windows" => "\cM\cJ",
"microsoft" => "\cM\cJ",
"nt" => "\cM\cJ",
"win" => "\cM\cJ",
);
sub usage {
warn "$0: @_\n" if @_;
my @names = sort {
$format{$a} cmp $format{$b}
||
$a cmp $b
} keys %format;
my $fmts = "@names";
format STDERR =
$0 src2dst [file ...]
where both src and dst are each one of:
~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$fmts
.
write STDERR;
exit(1);
}
($src, $dst) = ($0 =~ /(\w+)2(\w+)/);
usage("insufficient args") unless @ARGV || ($src && $dst);
if (@ARGV && $ARGV[0] =~ /(\w+)2(\w+)/) {
($src, $dst) = ($1, $2);
shift @ARGV;
}
usage("no conversion specified") unless $src && $dst;
usage("unknown input format: $src") unless $/ = $format{lc $src};
usage("unknown output format: $dst") unless $\ = $format{lc $dst};
binmode(STDOUT);
unshift @ARGV, '-' unless @ARGV;
for my $infile (@ARGV) {
unless (open(INPUT, $infile)) {
warn "$0: cannot open $infile: $!\n";
$errors++;
next;
}
binmode(INPUT);
unless (-T INPUT) {
warn "$0: WARNING: $infile appears to be a binary file.\n";
$errors++;
}
while (<INPUT>) {
unles (chomp) {
$errors++;
warn "$0: WARNING: last line of $infile truncated, correcting\n";
}
print;
}
unless (close INPUT) {
warn "$0: cannot close $infile: $!\n";
$errors++;
next;
}
}
exit ($errors != 0);
__END__
=head1 NAME
nlcvt - convert foreign line terminators
=head1 SYNOPSIS
B<nlcvt> I<src>2I<dst> [I<file> ...]
B<unix2mac> [I<file> ...]
B<unix2cpm> [I<file> ...]
B<cpm2unix> [I<file> ...]
B<cpm2mac> [I<file> ...]
B<mac2unix> [I<file> ...]
B<mac2cpm> [I<file> ...]
et cetera.
=head1 DESCRIPTION
Mike O'Dell said, only half-jokingly, that "the most brilliant decision
in all of Unix was the choice of a I<single> character for the newline
sequence." But legacy systems live on past their days, and these programs
can help that. Note, however, that if you've downloaded a binary file in
"text" mode rather than "binary", your mileage may vary.
The B<nlcvt> program, or any of its many aliases, is a filter to convert
from one system's notion of proper line terminators to that of another.
This usually happens because you've downloaded or otherwise directly
transferred a text file in so-called "binary" rather than "text" mode.
Unix format considers a lone Control-J to be the end of line. Mac format
considers a lone Control-M to be the end of line. The archaic CP/M
format considers a Control-M and a Control-J to be the end of line.
This program expects its first argument to be of the form I<src>2I<dst>,
where I<src> and I<dst> are both one of B<unix>, B<mac>, or B<cpm>.
(That's speaking canonically--many aliases for those systems exist: call
B<nlcvt> without arguments to see what names are accepted.) The converted
data is written to the standard output. B<nlcvt> does I<not> do
destructive, in-place modification of its source files. Do this
instead:
cpm2unix < file.bad > file.good
mv file.good file.bad
This program can also be called by the name of the conversion itself.
Just create links to the B<nlcvt> program for each systems, and the
program use its own name to determine the conversion. For example:
#!/usr/bin/perl
# make nlcvt links
chomp($path = `which nlcvt`);
@systems = qw(unix mac cpm);
for $src (@systems) {
for $dst (@systems) {
next if $src eq $dst;
ln($path, "${src}2$dst") || die $!;
}
}
=head1 DIAGNOSTICS
Any of the following diagnostics cause B<nlcvt>
to exit non-zero.
=over
=item C<insufficient args>
You called the program by its canonical name,
and supplied no other arguments.
You must supply a conversion argument.
=item C<no conversion specified>
Neither the name of the program nor its
first argument were of the form I<src>2I<dst>.
=item C<unknown input format: %s>
The specified input format, C<%s>, was unknown.
Call B<nlcvt> without arguments for a list of
valid conversion formats.
=item C<unknown output format: %s>
The specified output format, C<%s>, was unknown.
Call B<nlcvt> without arguments for a list of
valid conversion formats.
=item C<cannot open %s: %m>
The input file C<%s> could not be opened for the reason
listed in C<%m>.
=item C<cannot close %s: %m>
The input file C<%s> could not be close for the reason
listed in C<%m>. This error is rare.
=item C<can't close stdout: %m>
The filter could not finish writing to its standard output for the
reason listed in C<%m>. This could be caused by a full or temporarily
unreachable file system.
=item C<WARNING: last line of %s truncated, correcting>
Text files contain zero or more variable-length, newline-terminated
records. Occasionally, the final record terminator is missing,
perhaps due to an incomplete transfer, perhaps due to an aberrant
I<emacs> user. A newline sequence appropriate to the destination
system is appended. This would be a valid use of a I<unix2unix>
conversion. And no, you can't call it as B<emacs2vi>.
=item C<WARNING: %s appears to be a binary file>
Perl's C<-T> operator did not think the input file was a text file.
The conversion is still performed, but is of dubious value. If
the file really was binary, the resulting output may be mangled.
Garbage in, garbage out.
=back
=head1 AUTHOR
Tom Christiansen, I<tchrist@perl.com>.
=head1 COPYRIGHT
This program is copyright (c) 1999 by Tom Christiansen.
This program is free and open software. You may use, copy, modify,
distribute, and sell this program (and any modified variants) in any
way you wish, provided you do not restrict others from doing the same.
=cut
--
It won't be covered in the book. The source code has to be useful for
something, after all... :-)
--Larry Wall in <10160@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Tue, 09 Mar 1999 16:45:57 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: TECO *is* obfuscation (was does perl discourage obfuscated code)
Message-Id: <36E5C0C5.43AF91E@mail.cor.epa.gov>
David Corcoran wrote:
>
> > On 28 Feb 1999 00:01:11 -0800, Russ Allbery <rra@stanford.edu> wrote:
> >
> > + Actually, among all of the languages that I know, the one that takes the
> > + prise for the most generally unreadable language (and it's not even
> > + *close*) is FORTRAN,
>
> Not by a long shot, the worst I've seen (actually used) is TECO:
>
> .uB 0j <:fshooey$louie$;> qBj
>
> or how bout vi macros :-)
Of the languages I know (that means I am not commenting on Forth), I
would vote for good ol' traditional APL. A great language for special
purposes, but a typical line cannot even be written in ASCII for
illustrative purposes. APL can be written out for clarity, but it
takes a lot of work. The /x flag would be fantastic for obfuscated APL
code.
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 10 Mar 1999 01:13:25 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: y2k and 4-digit dates (was Re: foreach and while)
Message-Id: <7c4gvl$m1m$1@client2.news.psi.net>
Abigail (abigail@fnx.com) wrote on MMXVI September MCMXCIII in
<URL:news:7c3fk8$8bm$2@client2.news.psi.net>:
==
== No it won't. You still have to display it to be useful. And 1/2/2000 will
== still be ambiguous, no matter how you store it internally. Most users
== have no idea what the ISO format is; and even if they know, "1/2/2000"
== doesn't indicate it's in ISO format. You would have to start writing
== down something like "20000201" and hope people realize it's a date in
== ISO format and not something triggered by a Y2K bug.
A co-worker said today "The good thing about 2001 is that we can write
2 digit years again". :)
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5098
**************************************