[11499] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5099 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 10 03:07:55 1999

Date: Wed, 10 Mar 99 00:00:18 -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           Wed, 10 Mar 1999     Volume: 8 Number: 5099

Today's topics:
        Accessing MSACCESS Database on NT from UNIX. <omkumar@deshaw.com>
    Re: chmod query (Tad McClellan)
    Re: cobol line seq. file - one very long line - (Ronald J Kimball)
    Re: Days in Month array <partha@mihy.mot.com>
        Does someone know the pretectual calendar formula?? <B8402007@mail.ntust.edu.tw>
        Encrypt/decrypting form input data held in a flatfile d <me@me.com>
        FAQ 3.19: How can I free an array or hash so my program <perlfaq-suggestions@perl.com>
    Re: flock / sysopen / open confusion (Tad McClellan)
    Re: flock / sysopen / open confusion (Ronald J Kimball)
    Re: foreach question (Ronald J Kimball)
    Re: Help: lstat() and -l problems (Ronald J Kimball)
    Re: How to check whether data is ready on a socket? (Ronald J Kimball)
    Re: Missing CGI Environment Variables (Ronald J Kimball)
    Re: Newbie needs help!! (Ronald J Kimball)
    Re: Perl & PostgreSQL <dgris@moiraine.dimensional.com>
    Re: perl form and Netscape 4.5 problem? <webmaster@lovergirl.com>
        SRC: {unix,mac,cpm}2{unix,mac,cpm} converters <tchrist@mox.perl.com>
    Re: Using Multiple Servers <support@onlineauctions.co.uk>
    Re: Write to a file <webmaster@lovergirl.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 10 Mar 1999 12:36:18 +0530
From: omkumar <omkumar@deshaw.com>
Subject: Accessing MSACCESS Database on NT from UNIX.
Message-Id: <36E619EA.E44E1F1A@deshaw.com>

 I need to access an MSACCESS database on an NT machines from a Solaris
system using PERL. Can anyone suggest the best way to do this? Can I use
DBD::DBI modules for that? It would be great if someone gives more
details about this.

Thanks in advance
Omkumar




------------------------------

Date: Tue, 9 Mar 1999 16:32:24 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: chmod query
Message-Id: <8144c7.v12.ln@magna.metronet.com>

lbrown2@uswest.net wrote:
: Your permissions should be all decimal numbers (0700, NOT uppercase o, 07OO),
                                 ^^^^^^^^^^^^^^^

   Eh?


: for one. Try that.


   s/decimal/octal/;

   s/numbers/digits/;



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 9 Mar 1999 23:50:57 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: cobol line seq. file - one very long line -
Message-Id: <1dof8zv.1bynfqe1f0ylc0N@bay2-453.quincy.ziplink.net>

Dale Phillips <dphi@ix.netcom.com> wrote:

> Do happen to know how to Zero pad a $var? 
> 
> printf "%10s",$var;
> 
> where var is only 3 digits but needs to be 10 with leading zeros?

Well, you know the function, now you just need to find the
documentation.


perlfunc:

  sprintf FORMAT, LIST

  [...]

  Perl permits the following universally-known flags between the C<%>
  and the conversion letter:

     [...]
     0       use zeros, not spaces, to right-justify
     [...]


In other words, printf "%010", $var;


-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
perl -e'$_="\012534`!./4(%2`\cp%2,`(!#+%2j";s/./"\"\\c$&\""/gees;print'


------------------------------

Date: Wed, 10 Mar 1999 09:32:59 +0530
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
To: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Days in Month array
Message-Id: <36E5EEF3.9540193A@mihy.mot.com>

Charles R. Thompson wrote:

> I'm trying to build a timeline of days and dates when given a
> year. Leap years are messin with my code.
>
> How does one calculate if a given year is a leap year?
>
> CT

Hi

if($year % 4 == 0) {
    if($year%100 != 0) { # divisible by 4 and not by 100
        print "$year is a leap year";
    } elsif($year % 400 == 0) { # divisible by 4, 100, and 400
        print "$year is a leap year\n";
    } else {
        print "$year is not a leap year";
    }
}

HTH
-Partha



------------------------------

Date: Wed, 10 Mar 1999 12:08:39 +0800
From: "6@+O5?" <B8402007@mail.ntust.edu.tw>
Subject: Does someone know the pretectual calendar formula??
Message-Id: <7c4r44$afm$1@news.ntust.edu.tw>

Hi, all:

Does someone know the pretectual caleandar formula??
If yes, tell me please.  thanks a lot!!

P.S: The word "Pretctual Calendar" may be spell wrong.  I hope you can read
my mind.
--
NTUST in Taiwan
Department of Electronic Engineering
Senior
Kevin Huang




------------------------------

Date: Wed, 10 Mar 1999 06:07:13 -0000
From: "Steve" <me@me.com>
Subject: Encrypt/decrypting form input data held in a flatfile database.
Message-Id: <921046052.13429.0.nnrp-10.c2de6f9d@news.demon.co.uk>

Hi,

I'm creating a website which users can create their own accounts on. All the
accounts will be held in a flatfile database, and I want some of the fields
to be encrypted for security (passwords and other fields). This'll be on a
secure server so transmissions are secure.

What I want to do is implement a subroutine in my perl script which will
encrypt one or more form input fields and return it as a value (eg.
"$encryptedpass") for writing to a database. I have all the database stuff
done but I can't find any help on encryption, even on looking at other
people's scripts as none of them do what I want. I also need a subroutine
for decrypting the data in the same way, for returning the data to a web
page.

The strength of encryption doesn't need to be industrial-strength, but if
someone where to get hold of the database file I don't want them to be able
to figure out what the information is.

Any help would be appreciated.

Thanks.

Steve.





------------------------------

Date: 9 Mar 1999 23:15:33 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 3.19: How can I free an array or hash so my program shrinks?  
Message-Id: <36e60e05@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 free an array or hash so my program shrinks?

    You can't. On most operating systems, memory allocated to a
    program can never be returned to the system. That's why long-
    running programs sometimes re-exec themselves. Some operating
    systems (notably, FreeBSD and Linux) allegedly reclaim large
    chunks of memory that is no longer used, but it doesn't appear to
    happen with Perl (yet). The Mac appears to be the only platform
    that will reliably (albeit, slowly) return memory to the OS.

    We've had reports that on Linux (Redhat 5.1) on Intel, `undef
    $scalar' will return memory to the system, while on Solaris 2.6
    it won't. In general, try it yourself and see.

    However, judicious use of my() on your variables will help make
    sure that they go out of scope so that Perl can free up their
    storage for use in other parts of your program. A global
    variable, of course, never goes out of scope, so you can't get
    its space automatically reclaimed, although undef()ing and/or
    delete()ing it will achieve the same effect. In general, memory
    allocation and de-allocation isn't something you can or should be
    worrying about much in Perl, but even this capability
    (preallocation of data types) is in the works.

-- 
Travel important today; Internal Revenue men arrive tomorrow.


------------------------------

Date: Tue, 9 Mar 1999 16:54:01 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: flock / sysopen / open confusion
Message-Id: <p954c7.v12.ln@magna.metronet.com>

JPAH-FLA (mymail@nospam.com) wrote:
: I'm confused. In a recent post by Tom Christiansen he said that another
: Perl group poster had "closed the barndoor after the horses has escaped"
: [1]. The person had done something like
                           ^^^^^^^^^^^^^^

   We need the real stuff to comment intelligently.

   Go find the code that he was talking about and include it
   in your post. I expect he was talking about some code further
   down that you have not included, but I don't want to explain
   that because I'm not sure what you are talking about.

   If he claimed broken code and you don't believe it, you cannot
   possibly hope to get support for your view without including
   the code that is to be discussed...


: EXAMPLE:

:   open F,$myfile;
:   flock F,$LOCK_EX;
:   (do file I/O)

: At any rate, the real concern is:

: (a) does the EXAMPLE above really present a security concern? 


   Uhh.  Issues of file locking never present (or prevent)
   any security concerns.

   File locking is not about security.

   File locking is about data integrity.

   Lock or don't lock, it isn't going to affect a cracker in the least.

   (because file locking is advisory (on Unix) and cracker's
    don't take advice well...
   )


: Is there a
: risk that after between OPEN and FLOCK that the file was changed?


   Yes. (but you must have really already known this, it says so
         in a comment in the Camel example that you cite...)

   That is why the seek() to be beginning is done after getting the lock.


: (b) If so, why does sysopen() solve that problem


   If you seek to the beginning, then it is no longer a problem  :-)


: , (Tom refereces THAT
: post in the one I cite)
          ^^^^^^^^^^^^^^

   You must either provide a reference so that we can see what you
   are citing, or don't make the citation.


: (c) Assuming sysopen() does solve it, should Perl users ALWAYS use
: sysopen() instead of open on shared aps? Is sysopen() better?


   What's an aps?

   Do you mean apps as in applications?

   I don't see any code with and without sysopen()s to evaluate,
   so I can't say... (hint hint)


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 9 Mar 1999 23:50:59 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: flock / sysopen / open confusion
Message-Id: <1dof9k4.h4z98gq5cxisN@bay2-453.quincy.ziplink.net>

JPAH-FLA <mymail@nospam.com> wrote:

> I'm confused. In a recent post by Tom Christiansen he said that another
> Perl group poster had "closed the barndoor after the horses has escaped"
> [1]. The person had done something like
                      ^^^^^^^^^^^^^^^^^^^

> EXAMPLE:
> 
>   open F,$myfile;
>   flock F,$LOCK_EX;
>   (do file I/O)


They may have done something "like" that.  But Tom's comment was not in
response to something "like" what they did.  In was in response to what
they did, which was the following:

open(FH, ">$filename") || die "Cannot open $filename for write: $!";
flock(FH, 2);


The file is opened with a ">" mode, clobbering the contents of the file.
Then the file is locked.

It's too late to lock the file if you've already changed the file
contents.  Instead, you need to open the file with a mode of "+>", which
does not clobber the file contents.


-- 
chipmunk (Ronald J Kimball) <rjk@linguist.dartmouth.edu>
perl -e 'print map chop, sort split shift, reverse shift
' 'j_' 'e._jP;_jr/_je=_jk{_jn*_j &_j :_j @_jr}_ja)_js$_j
~_jh]_jt,_jo+_jJ"_jr>_ju#_jt%_jl?_ja^_jc`_jh-_je|' -rjk-


------------------------------

Date: Tue, 9 Mar 1999 23:51:00 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: foreach question
Message-Id: <1dof9qc.jc8ru11ifg9pfN@bay2-453.quincy.ziplink.net>

Aaron Walker <amwalker@gate.net> wrote:

> $ls = `ls`;
> @ls_output = $ls;
> 
> foreach $file (@ls_output)

@ls_output will never have more than one element.  You can't assign a
scalar to an array and expect to get multiple elements.

    @ls_output = `ls`;

Although I'd probably use opendir()/readdir().

-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
    perl -e'for(sort keys%main::){print if $$_ eq 1}
        ' -s  -- -' Just' -' another ' -'Perl ' -'hacker 
' http://www.ziplink.net/~rjk/  [rjk@linguist.dartmouth.edu]


------------------------------

Date: Tue, 9 Mar 1999 23:51:01 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Help: lstat() and -l problems
Message-Id: <1dof9vq.rc6ftb8rpz24N@bay2-453.quincy.ziplink.net>

George Lindholm <lindholm@ucs.ubc.ca> wrote:

> I'm getting a strange error message when I try to combine lstat() and
> -l with perl5.005.02/solaris.


> The stat preceding -l _ wasn't an lstat at /tmp/b.pl line 5.


Does your system implement symbolic links?

lstat EXPR

   [...] (If symbolic links are unimplemented on your system, a normal
   stat is done instead.)


That's the only thing I can think of.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
           perl -le 'print "Just another \u$^X hacker"'


------------------------------

Date: Tue, 9 Mar 1999 23:51:02 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: How to check whether data is ready on a socket?
Message-Id: <1dof9yo.15bs3kt1q6bx7bN@bay2-453.quincy.ziplink.net>

Thurgood Stubbs <stubbs@say.wut> wrote:

> I'm a Perl newbie on Solaris 5.5.1, trying to do some socket I/O.  I
> need to be able to query whtehr there's some input available on a given
> socket, without blocking.  Is there a way to do this?

Look into the four argument select() function and the IO::Select module.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
perl -e 'for(@ARGV){require $_;print "$_\n  $INC{$_}\n"}' IO/Select.pm


------------------------------

Date: Tue, 9 Mar 1999 23:51:03 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Missing CGI Environment Variables
Message-Id: <1dofa9v.rfp2jt1bhd7n8N@bay2-453.quincy.ziplink.net>

John Casey <jcasey@workingventures.ca> wrote:

> I later tried using the same script with Omnicron HTTPd/Perl5.
> PATH_INFO and HTTP_REFERER do not work, but others do. Almost all of
> my path type information does not work. 
> 
> Could this be because I am on an intranet (I dunno), an Omnicron HTTPd
> limitation (doubt it) or something I did wrong(more than likely)?

It's possible you did something wrong in your Perl code.  I might even
have been able to point it out to you, if only you had included an
example of the code that is not working for you.

If your code is written properly, then it's one of the other things, and
not specifically related to this newsgroup.

-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
    perl -s -e'print sort grep { /\s/ } keys %main::
        ' -- -is -' Just' -' another ' -'Perl ' -'hacker 
' http://www.ziplink.net/~rjk/ [rjk@linguist.dartmouth.edu]


------------------------------

Date: Tue, 9 Mar 1999 23:51:04 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Newbie needs help!!
Message-Id: <1dofag3.1qnjht9w4o4hlN@bay2-453.quincy.ziplink.net>

Dev <hr5aa@herts.ac.uk> wrote:

> The error I get when I compile it 
> is "Missing comma after first argument to open function at comments.cgi
> line 49, near "$fname)". Here is a sample of the code:
> 
> $fname = ">>", $COMMENT_FILE;  
> open(OUT $fname);

You appear to be missing a comma after the first argument to the open()
function, near "$fname)".


[And the comma you have on the previous line should be a period.]


> This was an example taken from a book, and I copied it verbatim

Either that's a very poor book, or you need to double-check your
re-typing of the code.


HTH!


-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: 09 Mar 1999 23:45:49 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Perl & PostgreSQL
Message-Id: <m3u2vt3krm.fsf@moiraine.dimensional.com>

Staffan Liljas <staffan@ngb.se> writes:

<snip DBD::Pg is preferable to Pg>

> 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?

The portability to different databases is a big advantage, but
the biggest is the portability to different programmers.  Using
DBI you make it far more likely that the next programmer that
works with the code will be working in an environment that he is
familiar with.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


------------------------------

Date: Thu, 04 Mar 1999 22:26:42 +0800
From: Yule Show <webmaster@lovergirl.com>
To: Clay Irving <clay@panix.com>
Subject: Re: perl form and Netscape 4.5 problem?
Message-Id: <36DE9822.9F9F32E5@lovergirl.com>

Try convert first three line to:
print (".....\n\n");
I tryed, it is ok.
yours Yule Show


Clay Irving wrote:

> On Tue, 23 Feb 1999 18:50:56 -0800, Bill Bukowski <cbwhb@ttacs.ttu.edu> wrote:
> >Thanks for the reply...I'm beginning to realize that I'm probably posting in
> >the
> >wrong group and perhaps should be in comp.infosystems.www.authoring.cgi
> >as it *is* a cgi script I'm working with.
> >
> >The problem isn't with the script, though; that much works.  My browser just
> >won't show the output.  The code that starts the output looks like this:
> >
> ># Redirection Option
> >sub no_redirection {
> >
> >   # Print Beginning of HTML
> >   print "Content-Type: text/html";
> >   print "\n";
> >   print "\n";
> >   print "<html><head><title>Thank You</title></head>\n";
> >   print "<body><h1>Thank You For Your Comments</h1>\n";
> >[and so on]
> >
> >So it's got the content-type and 2 line breaks called for in, uh, one of the
> >cgi
> >faqs.  And it works in older browsers.  Just not new ones.  And obviously
> >I'm an idiot on this subject--I'm just (still) stumped on the precise nature
> >of my
> >idiocy...
>
> Recommended reading:
>
>    Idiot's Guide to Solving Perl/CGI Problems
>    http://language.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
>
> --
> Clay Irving <clay@panix.com>
> 'I must've seen it in a USENET posting;' that's sort of like hearsay
> evidence from Richard Nixon...
> - Blair Houghton



------------------------------

Date: 10 Mar 1999 00:31:12 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: {unix,mac,cpm}2{unix,mac,cpm} converters
Message-Id: <36e61fc0@csnews>

Skip to the pod for the manpage.  

#!/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";
    print STDERR "usage: $0 src2dst [file ...]\n";
    format STDERR = 
    where src and dst are both 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>) {
	unless (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> ...]

=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; # unless you want unix2unix
	    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.
-- 
    That means I'll have to use $ans to suppress newlines now.  
    Life is ridiculous. 
        --Larry Wall in Configure from the perl distribution


------------------------------

Date: Wed, 10 Mar 1999 04:43:20 +0000
From: On Line Auctions UK <support@onlineauctions.co.uk>
Subject: Re: Using Multiple Servers
Message-Id: <36E5F868.34E353A@onlineauctions.co.uk>


--------------6568839AA5653930B6241D43
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Thanks for the message but after looking at that file i'm still no wiser. Isn't
there a simple command to do this or do I have to work out all this socket stuff??

any ideas

gary

Abigail wrote:

> On Line Auctions UK (support@onlineauctions.co.uk) wrote on MMXVI
> September MCMXCIII in <URL:news:36E49950.4FBE2EEE@onlineauctions.co.uk>:
> {} I have got two servers one with the main script on it and another that i
> {} want to pass data to. I need to post two variables like
> {} http://host.com/cgi-bin/script.cgi?var1=thing&var2=thing2 to the script
> {} on the other server. But how do actually code this in Perl.
>
> man perlipc
>
> Abigail
> --
> perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
> 0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
> =>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
> !$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'

--------------6568839AA5653930B6241D43
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Thanks for the message but after looking at that file i'm still no wiser.
Isn't there a simple command to do this or do I have to work out all this
socket stuff??
<p>any ideas
<p>gary
<p>Abigail wrote:
<blockquote TYPE=CITE>On Line Auctions UK (support@onlineauctions.co.uk)
wrote on MMXVI
<br>September MCMXCIII in &lt;URL:<a href="news:36E49950.4FBE2EEE@onlineauctions.co.uk">news:36E49950.4FBE2EEE@onlineauctions.co.uk</a>>:
<br>{} I have got two servers one with the main script on it and another
that i
<br>{} want to pass data to. I need to post two variables like
<br>{} <a href="http://host.com/cgi-bin/script.cgi?var1=thing&var2=thing2">http://host.com/cgi-bin/script.cgi?var1=thing&amp;var2=thing2</a>
to the script
<br>{} on the other server. But how do actually code this in Perl.
<p>man perlipc
<p>Abigail
<br>--
<br>perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
<br>0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
<br>=>I=>$r=-2449231+gm_julian_day+time);do{until($r&lt;$#r){$_.=$r[$#r];$r-=$#r}for(;
<br>!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'</blockquote>
</html>

--------------6568839AA5653930B6241D43--



------------------------------

Date: Thu, 04 Mar 1999 22:15:54 +0800
From: Yule Show <webmaster@lovergirl.com>
Subject: Re: Write to a file
Message-Id: <36DE9599.F3A5403C@lovergirl.com>

I think you can.
1. Open the file in read mode.
2. Read from this file put into an array or an associated array ( I
think it is very easy).
3. Close the file
4. Re-open the file in write mode.
5. Write the first line you want into the filevar.
6. Put the array which stores your original file into the filevar.
7. Close the file.

yours Yule Show

Frank de Bot wrote:

> How can I write something to the first line of a file. Nomally perl
> writes with this to the last line: open(FILE, ">>file.txt");



------------------------------

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 5099
**************************************

home help back first fref pref prev next nref lref last post