[12377] in Perl-Users-Digest
Perl-Users Digest, Issue: 5977 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 13 12:07:15 1999
Date: Sun, 13 Jun 99 09:00:21 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 13 Jun 1999 Volume: 8 Number: 5977
Today's topics:
Re: Alter name of an array? (Eric Bohlman)
Re: Alter name of an array? (Randal L. Schwartz)
Re: Alter name of an array? (Larry Rosler)
Re: better way? (Tad McClellan)
Re: better way? <rick.delaney@home.com>
Re: Debugger <gellyfish@gellyfish.com>
Re: Debugger <rootbeer@redcat.com>
Re: disalowing words (Larry Rosler)
Re: Does Perl have a future? <rootbeer@redcat.com>
Getting and using time (Twarren10)
Re: Getting and using time (Eric Bohlman)
Re: Getting and using time <tchrist@mox.perl.com>
Re: Getting and using time <rootbeer@redcat.com>
Re: help for newbie <gellyfish@gellyfish.com>
Re: help for newbie (Tad McClellan)
Re: Log file (Twarren10)
Re: MIcrosofts Attack on Perl (Wayne Allison)
Re: Need Help Anit-Back <dgris@moiraine.dimensional.com>
Perl and the serial port <marco.anstett@okay.net>
Re: Perl and the serial port <gellyfish@gellyfish.com>
Re: Perl error: carriage returns ??? <gellyfish@gellyfish.com>
Re: Perl error: carriage returns ??? (Tad McClellan)
Re: PLZ HELP <gellyfish@gellyfish.com>
Re: PLZ HELP <rootbeer@redcat.com>
Re: problem with BASE64 <gellyfish@gellyfish.com>
Re: problem with BASE64 (Eric Bohlman)
Re: Sort on mtime <gellyfish@gellyfish.com>
why didn't while(<$$_>) {} wrk? (Hugh Dixon)
Re: why didn't while(<$$_>) {} wrk? <gellyfish@gellyfish.com>
Re: why didn't while(<$$_>) {} wrk? (Ronald J Kimball)
win32: vba2perl shr28@my-deja.com
Re: win32: vba2perl <gellyfish@gellyfish.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 13 Jun 1999 13:21:55 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Alter name of an array?
Message-Id: <ebohlmanFD9p4J.A7B@netcom.com>
Tom Christiansen (tchrist@mox.perl.com) wrote:
: That's wrong. Use a real data structure. I have never heard a C
: programmer ask to do this. I have never heard a Pascal programmer ask
: to do this. I have never heard a Fortran programmer ask to do this.
: I have never heard a Java programmer ask to do this. What is it about
: Perl programmers that leads them to this urge?
My guess (it's just a guess) is that instructional material for all these
other languages tends to introduce multi-dimensional arrays right after
it introduces single-dimensional arrays, whereas Perl's documentation,
and most Perl books, defers multi-dimensional arrays until after
references are introduced (which is rational in terms of how
multi-dimensional arrays are implemented in Perl, but may not be the best
pedagogical strategy). Thus, the learning curves of most other languages
have a much narrower "window" during which someone learning the language
could think that "variable variable names" could serve some useful purpose.
Another possibility is that a whole bunch of people are trying to learn
Perl from references (probably on the Web) that were written for Perl 4
and never updated.
------------------------------
Date: 13 Jun 1999 07:32:33 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Alter name of an array?
Message-Id: <m1674sp3we.fsf@halfdome.holdit.com>
>>>>> "Eric" == Eric Bohlman <ebohlman@netcom.com> writes:
Eric> My guess (it's just a guess) is that instructional material for
Eric> all these other languages tends to introduce multi-dimensional
Eric> arrays right after it introduces single-dimensional arrays,
Eric> whereas Perl's documentation, and most Perl books, defers
Eric> multi-dimensional arrays until after references are introduced
Eric> (which is rational in terms of how multi-dimensional arrays are
Eric> implemented in Perl, but may not be the best pedagogical
Eric> strategy).
It's a fairly necessary strategy. Sure, you can look the other way
and pretend that $a[2][3] is an element of an array of arrays, but it
isn't. It's an array of arrayrefs, which becomes obvious when you try
to do anything with an entire row or an entire column, or ask
questions about its size.
There are *many* applications you can do knowing only basic
lists/arrays and hashes, without ever having to make that next major
leap into references. Thus, references are an advanced topic, best
taught when you have a basic understanding of other syntax.
Yes, I cringe when I start seeing code that tries to use symrefs for
what should be a simple array of arrayrefs, but that's merely a sign
that the asker was unaware of this whole new area called "references".
print map $$$$$$$$${\\\\\\\\\$_}, split //, "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Sun, 13 Jun 1999 07:49:09 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Alter name of an array?
Message-Id: <MPG.11cd64b43fe026c6989bd6@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37632c53@cs.colorado.edu> on 12 Jun 1999 21:58:11 -0700, Tom
Christiansen <tchrist@mox.perl.com> says...
,,,
> That's wrong. Use a real data structure. I have never heard a C
> programmer ask to do this. I have never heard a Pascal programmer ask
> to do this. I have never heard a Fortran programmer ask to do this.
> I have never heard a Java programmer ask to do this. What is it about
> Perl programmers that leads them to this urge?
My guess (it's just a guess) is that in those other languages you can't
do it. In Perl, you can.
Having learned Perl by reading the Camel, I have personal experience as
to how seductive it is to name variables dynamically. It comes across
as a language feature, not as a trap. This newsgroup straightened me
out, but it was long after I had implemented production code the Bad
Way.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 13 Jun 1999 05:25:49 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: better way?
Message-Id: <tetvj7.jea.ln@magna.metronet.com>
Filip M. Gieszczykiewicz (fmgst+@pitt.edu) wrote:
: I pass information back and forth between a processing script and some
: individual files using the last 4 lines of each file. Ie. the file
: contains INFO + 4 lines that nobody ever sees except my big script.
[snip]
: Now, other than playing with [hide and] seek, is there a better "simple"
: way of extracting JUST the last 4 lines into variables?
An "array slice" can pull out part of an array.
Here are two ways:
--------------
#!/usr/bin/perl -w
use strict;
my @tmpstack = qw(zero one two three four five six seven eight nine ten);
foreach ( @tmpstack[$#tmpstack-4 .. $#tmpstack] ) {
print "$_\n";
}
print "\n";
foreach ( @tmpstack[-5, -4, -3, -2, -1] ) {
print "$_\n";
}
--------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 13 Jun 1999 15:05:41 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: better way?
Message-Id: <3763C880.73FD4779@home.com>
Tad McClellan wrote:
>
> foreach ( @tmpstack[$#tmpstack-4 .. $#tmpstack] ) {
...
> foreach ( @tmpstack[-5, -4, -3, -2, -1] ) {
Also:
foreach ( @tmpstack[-5 .. -1] ) {
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 13 Jun 1999 12:14:02 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Debugger
Message-Id: <7k07aa$ha$1@gellyfish.btinternet.com>
On Sat, 12 Jun 1999 15:29:28 -0600 Tim wrote:
> Hello,
>
>
> I am looking some a program that will find type-o errors with my cgi
> script so I don't have to go crazy looking for them
perl -cw progname
You should always use the -w switch on your shebang line and possibly
also 'use strict' which will catch most typos and a percentage of brainos
as well.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 13 Jun 1999 08:18:42 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Debugger
Message-Id: <Pine.GSO.4.02A.9906130818130.6999-100000@user2.teleport.com>
On Sat, 12 Jun 1999, Tim wrote:
> I am looking some a program that will find type-o errors with my cgi
> script so I don't have to go crazy looking for them
Have you tried the -w and -c options to Perl? They're listed in the
perlrun manpage. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 13 Jun 1999 07:56:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: disalowing words
Message-Id: <MPG.11cd6656107e96d3989bd7@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7jvrup$a5t$1@mathserv.mps.ohio-state.edu> on 13 Jun 1999
09:00:09 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
> [A complimentary Cc of this posting was sent to Larry Rosler
> <lr@hpl.hp.com>],
> who wrote in article <MPG.11ccef17e970e0af989bd5@nntp.hpl.hp.com>:
> > timethese(1 << $n, {
> > FAQ0 => sub { @regexes = map qr/\b$_\b/i => @words },
>
> Why are you recompiling the things in the loop?
Because I want to see how long it takes to do the compilation, not to
amortize it over all the uses of the regexes. Similarly for the other
two approaches (hash lookup and single regex).
> > FAQ1 => sub { $line =~ /$_/ and ++$matches for @regexes },
>
> Why do not you shortcut?
If you mean why not break out of the loop as soon as a match is found,
it is because there may be several matches in a single line of data (as
in my test sample) and I want to report them all (i.e., print each one,
in a real program).
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 13 Jun 1999 08:01:51 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Does Perl have a future?
Message-Id: <Pine.GSO.4.02A.9906130727180.6999-100000@user2.teleport.com>
On Sun, 13 Jun 1999, Christian Ahkman wrote:
> Perl obviously "has a future" for many tasks, so let me be more
> specific. Does perl have a future on the web server?
Heck, some people are still trying to write BASIC programs to run on
webservers! Perl will be used on webservers for a long time, even long
after something better comes along. Which hasn't happened yet, and
probably won't - until Perl 6 is ready. :-)
> Of course, Sun claims that Perl/CGI is dead and that JavaBeans is the
> future of server side web development for UNIX.
Easy to claim, hard to prove. But what about non-Unix systems? Perl runs
on more machines than Java does. Of course, portability isn't the only
criterion. The best thing is to make a list of criteria that matter to you
and see how they compare for yourself.
It's easy to see that if you have a large budget for PR, you can make your
product look pretty appealing. (OTOH, Sun isn't spending as much on Java
PR as they spent when the hype engine was running at full steam. Here's an
experiment to try: Spend one-tenth as much on Perl PR as Sun spent on Java
PR and see whether Larry Wall becomes more famous than 'N Sync. :-)
> Are people seeing this happen?
Not I.
I recommend that, if you want to be sure to make the best choice about
Perl, Java, and other languages, you should learn and use them all. Then
you can always choose the best language for each task. Of course, that
will nearly always be Perl.
Even if something else took over the web entirely (which ain't happening)
a good Perl programmer still has more Perl-related jobs to choose from
than were available last year. And there were more that year than the year
before. And more that year than the one before that. I'm loath to predict
the future, but this may be a trend.
Ask again in five years, and we'll see how it's all doing. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 13 Jun 1999 11:05:44 GMT
From: twarren10@aol.com (Twarren10)
Subject: Getting and using time
Message-Id: <19990613070544.22854.00000954@ng-fu1.aol.com>
Here's another newbe question if you can help me out.
Can anyone tell me how I can get the time in perl and print it out in a log
file
so I can check it? Thanks,
------------------------------
Date: Sun, 13 Jun 1999 13:47:26 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Getting and using time
Message-Id: <ebohlmanFD9qB2.CB4@netcom.com>
Twarren10 (twarren10@aol.com) wrote:
: Here's another newbe question if you can help me out.
: Can anyone tell me how I can get the time in perl and print it out in a log
: file
: so I can check it? Thanks,
perldoc -f localtime
------------------------------
Date: 13 Jun 1999 09:08:02 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Getting and using time
Message-Id: <3763c952@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
ebohlman@netcom.com (Eric Bohlman) writes:
:: Can anyone tell me how I can get the time in perl and print it out in a log
:: file [MANGLED WRAP BY BROKEN NEWSREADER]
:: so I can check it? Thanks,
:
:perldoc -f localtime
I do not suggest logging times in anything but epoch seconds or GMT.
In the long run, you'll not be happy.
--tom "curshd be perldoc, abomination amongst tools" christiansen
--
"Grant me the serenity to accept the things I cannot change, the courage
to change the things I can, and the wisdom to hide the bodies of the
people that I had to kill because they pissed me off." --Anonymous
------------------------------
Date: Sun, 13 Jun 1999 08:22:04 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Getting and using time
Message-Id: <Pine.GSO.4.02A.9906130819460.6999-100000@user2.teleport.com>
On 13 Jun 1999, Twarren10 wrote:
> Can anyone tell me how I can get the time in perl
Have you searched for 'time' in the perlfunc manpage (or the index of your
favorite Perl book)?
> and print it out in a log file
The perlfunc manpage also has information on opening files and printing to
them. You use the same general techniques whether the file is a log file
or for another purpose.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 13 Jun 1999 12:19:51 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: help for newbie
Message-Id: <7k07l7$he$1@gellyfish.btinternet.com>
On Sat, 12 Jun 1999 20:45:43 -0500 DENNIS W HAUPT wrote:
> I'm learning perl now and I would like to test my scripts on my own computer
> before uploading them. I write the scripts and open the page in the web
> browser but it just opens the perl.exe in a dos box I don't know how to tell
> it to send the info to the browser. Have tried website 2 and other stuff
> all with the same result.
>
You can test programs using the module CGI.pm from the command line to see
if it works - if you want to test it in a real CGI environment you will
want to install an HTTP server on your PC - I would ask in the newsgroup
comp.infosystems.www.servers.ms-windows for recommendations - there are
plenty of free ones available. The documentation that comes with the
Activestate Perl distribution has instructions on how to set up a variety
of HTTP servers to work with Perl.
> Please email any help to visualbasic@programmer.net and I will help with
> any VB questions
>
But I dont use VB
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 13 Jun 1999 05:18:41 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help for newbie
Message-Id: <h1tvj7.jea.ln@magna.metronet.com>
DENNIS W HAUPT (DENHOP@prodigy.net) wrote:
: I'm learning perl now and I would like to test my scripts on my own computer
: before uploading them.
No problem.
: I write the scripts and open the page in the web
: browser
Oh.
Testing CGI programs is _more_ than "testing scripts".
Have you had a look at any of these sources of info, from
the Perl FAQ, part 3?
-----------------------
=head2 Where can I learn about CGI or Web programming in Perl?
For modules, get the CGI or LWP modules from CPAN. For textbooks,
see the two especially dedicated to web stuff in the question on
books. For problems and questions related to the web, like ``Why
do I get 500 Errors'' or ``Why doesn't it run from the browser right
when it runs fine on the command line'', see these sources:
WWW Security FAQ
http://www.w3.org/Security/Faq/
Web FAQ
http://www.boutell.com/faq/
CGI FAQ
http://www.webthing.com/page.cgi/cgifaq
HTTP Spec
http://www.w3.org/pub/WWW/Protocols/HTTP/
HTML Spec
http://www.w3.org/TR/REC-html40/
http://www.w3.org/pub/WWW/MarkUp/
CGI Spec
http://www.w3.org/CGI/
CGI Security FAQ
http://www.go2net.com/people/paulp/cgi-security/safe-cgi.txt
-----------------------
: but it just opens the perl.exe in a dos box I don't know how to tell
: it to send the info to the browser. Have tried website 2 and other stuff
: all with the same result.
You do not have a Perl question here.
You have a CGI question here.
You can do limited testing of CGI scripts at the command line if
you are using the CGI.pm module, but you need an HTTP server
installed if you want to test the CGI program as a CGI program.
Find an HTTP server program and install it on your local 'puter.
Newsgroups where your problem would be on-topic:
comp.infosystems.www.authoring.cgi
comp.infosystems.www.servers.mac
comp.infosystems.www.servers.misc
comp.infosystems.www.servers.ms-windows
comp.infosystems.www.servers.unix
: Please email any help to visualbasic@programmer.net
Please do not.
We prefer to not hoard answers. We like them posted to the
newsgroup where _everybody_ can benefit from them.
Ask it here, get the answer here.
: and I will help with
: any VB questions
No thanks :-(
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 13 Jun 1999 14:04:24 GMT
From: twarren10@aol.com (Twarren10)
Subject: Re: Log file
Message-Id: <19990613100424.22854.00000977@ng-fu1.aol.com>
>
>HTH
>
>Marcel
>
This has been a tremendous help and very much appreciated. Thanks much for your
assistance.
------------------------------
Date: Sun, 13 Jun 1999 15:16:06 +0200
From: wayne_allison@yahoo.com (Wayne Allison)
Subject: Re: MIcrosofts Attack on Perl
Message-Id: <1dtcf89.aiwhns1bh8xklN@inksplash.demon.co.uk>
Chris Nandor <pudge@pobox.com> wrote:
> In article <37604888.E297EA75@yahoo.com>, jgrain <jgrain@yahoo.com> wrote:
>
> ... if you are going to crosspost, crosspost. This same message was in
> clp.modules. Don't send it twice, send it once.
>
> In article <376048C5.AC18B48F@yahoo.com>, jgrain <jgrain@yahoo.com> wrote:
>
> # What is the current strategy of those at the very top, i.e. those who
> # understand, believe and promote open source, particularly in reference
> # to its influence on reducing the cost of computing and spreading the net
> # of those involved in "serious" computing after the announcement that
> # Microsoft will be "hijacking" Perls advantages, for their own commercial
> # benefit.
>
> There was not announcement of any hijacking. You are confused.
>
It would seem that many people would feel that Perl would be hijacked by
Microsoft in that they would improve it so that it would need to run on
WinTel platforms to use those new improved features.
A sort of feature entrapment, they seem to have done the same with Java,
totally different ball-game granted but sets the tone I think.
It'll not ruin or debase Perl on Unix, just that by the time the Master
Plan reaches fruition there'll be no Unix, to speak of just small
ghettos.
>
> # Are people aware of the "negative" consequences of such a move,
> # especially in relation to one of Perls core ojectives in relation to
> # maintaining the language as "portable"?
>
> Yes. Perl will in all liklihood become more portable as a result of this
> arrangement.
We'll see what features are added my MSs envolvement that enhance
"portability". I'd be surprised if it becomes more portable than just
being able to run on WinTel better, which when splitting hairs may be
the political point of Microsofts involvement.
Interesting time ahead don't we think.
>
> --
--
Wayne Allison
wayne_allison@yahoo.com
------------------------------
Date: 13 Jun 1999 09:50:49 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Need Help Anit-Back
Message-Id: <m31zfg5cbq.fsf@moiraine.dimensional.com>
Tim <bie@connect.ab.ca> writes:
> I am making a game & I want to be able to stop the user from simply
> pushing back on their browser and trying again. How can I do this?
Use a protocol with client implementations that do not provide
this functionality.
HTH
HAND
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Sun, 13 Jun 1999 15:13:54 +0200
From: Marco Anstett <marco.anstett@okay.net>
Subject: Perl and the serial port
Message-Id: <3763AE91.4826D745@okay.net>
Hi
I am thinking of using PERL in a CGI script that would access a serial
port and
communicate with an experimental device.
Is it possible in PERL running on a Linux-system?
Thanks for your help
Marco
------------------------------
Date: 13 Jun 1999 14:07:53 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl and the serial port
Message-Id: <7k0dvp$t1$1@gellyfish.btinternet.com>
On Sun, 13 Jun 1999 15:13:54 +0200 Marco Anstett wrote:
> Hi
>
> I am thinking of using PERL in a CGI script that would access a serial
> port and
> communicate with an experimental device.
>
> Is it possible in PERL running on a Linux-system?
>
read perlfaq8 :
=head2 How do I read and write the serial port?
You may have further questions but these are not necessarily specific to Perl.
You might find answers to programming for hardware devices under Linux in
one of the many Linux HWTO documents ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 13 Jun 1999 12:42:56 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl error: carriage returns ???
Message-Id: <7k090g$ie$1@gellyfish.btinternet.com>
On Sun, 13 Jun 1999 19:31:23 +1000 Ian B wrote:
> Hi,
>
> I'm using Perl to run CGI programs on a web server. A couple of scripts
> I am trying to setup are giving the following error:
>
> "Illegal character \015 (carriage return) at perlscript.cgi line x.
> (Maybe you didn't strip carriage returns after a network transfer?)"
>
The message is telling you everything.
You either need to transfer the files in ASCII mode from your Windows
system to your Unix system - if you are using a text based FTP client
then you can just type 'AS' before you start your transfer - if you are
using some gui FTP client then you will have to work it out yourself.
If you have shell access on your Unix system then you can also use some
utility there to strip the extraneous characters (dos2unix,dtox etc )
Tom Christiansen posted a program here called nlcnvt - which also will
do what you require.
I would recommend doing the transfer right in the first place
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 13 Jun 1999 05:32:23 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl error: carriage returns ???
Message-Id: <7rtvj7.jea.ln@magna.metronet.com>
Ian B (q9822210@mail.NOSPAMconnect.usq.edu.au) wrote:
: I'm using Perl to run CGI programs on a web server. A couple of scripts
: I am trying to setup are giving the following error:
: "Illegal character \015 (carriage return) at perlscript.cgi line x.
: (Maybe you didn't strip carriage returns after a network transfer?)"
All of the messages that perl might issue are documented in
the 'perldiag.pod' man page that comes with the perl
distribution. For your message it says:
-----------------------
=item Illegal character %s (carriage return)
(F) A carriage return character was found in the input. This is an
error, and not a warning, because carriage return characters can break
multi-line strings, including here documents (e.g., C<print E<lt>E<lt>EOF;>).
Under Unix, this error is usually caused by executing Perl code --
either the main program, a module, or an eval'd string -- that was
transferred over a network connection from a non-Unix system without
properly converting the text file format.
Under systems that use something other than '\n' to delimit lines of
text, this error can also be caused by reading Perl code from a file
handle that is in binary mode (as set by the C<binmode> operator).
In either case, the Perl code in question will probably need to be
converted with something like C<s/\x0D\x0A?/\n/g> before it can be
executed.
-----------------------
: The scripts come straight off the Internet in ZIP form into a Win95 then
: I transfer them over to Linux using FTP and uncompress them there.
They must have been zipped up on a M$ system then.
: Why are carriage returns causing a problem? How can I fix this without
: having to edit the file manually?
You can convert dos2unix line endings automatically with a handy
programming language known as Perl.
:-)
perl -p -i.withCR -e 'tr/\r//d' file_with_CRs
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 13 Jun 1999 12:12:29 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: PLZ HELP
Message-Id: <7k077d$h7$1@gellyfish.btinternet.com>
On Sat, 12 Jun 1999 15:28:47 -0600 Tim wrote:
> Hello,
>
> What is wrong with this?
>
>
> #!/usr/local/bin/perl
>
Missing -w on that .
and you should probably be using 'use strict;'
> require "subparseform.lib";
> &Parse_Form;
> print "Content-type: text/html\n\n";
>
>
> if ($ENV{'QUERY_STRING'} eq "new") {
> &newuser;
> }
>
This doesnt do what you appear to think it does - you probably want
something like :
if($formdata{'action'} eq 'new' )
{
&newuser;
}
Of course I dont know what is going on inside your subparseform.lib
and also dont know what your form looks like - so 'action' may not
be right but you can work it out - and no please dont post your form or
your library.
>
> sub newuser {
> $user = $formdata{'user'};
> $email = $formdata{'email'};
> $password = $formdata{'password'};
> $money = "100";
> $ufile = $user . ".txt";
>
> if (-e /members/$ufile) {
The file path there is a bare word you should enclose it in double quotes.
Here and in the other place you use the fullpath to a file then you need
to be sure that this is the actual path to the file as seen by your program.
If your URL is http://www.blah.com/ and you want the files created under
the document root in a directory called 'members' then it is unlikely that
the actual path is /members/file.txt - it is more likely to be something
for example : /usr/www/share/username/members/ - but you will have to ask
your ISP about that.
> print "Sorry, Someone already has registered the username :
> $user";
> }
> else {
> # CREATE NEW USER'S FILE
> OPEN (NEW,">>/members/$user.txt") || &Error;
Perl is case-sensitive - you want to use 'open' not OPEN
If you are creating a new file you only need one > .
> PRINT NEW "$user\n";
> PRINT NEW "$email\n";
> PRINT NEW "$password\n";
> PRINT NEW "$money\n";
> CLOSE (NEW);
> # SEND NEW USER A EMAIL MESSAGE
> OPEN (NEWMAIL, "|/usr/sbin/sendmail -t") || &Error;
Perl is case-sensitive - you want to use 'open' not OPEN
> print NEWMAIL "To: $email\nFrom: ADMIN\n";
> print NEWMAIL "Subject: Your new Account\n";
You are missing a '\n' between your header and the body of your message -
you will probably get an error from sendmail ...
> print NEWMAIL "Thanks for signing up";
> CLOSE (NEWMAIL);
... except you didnt check the return of this close so you dont know whether
sendmail has worked or not.
> print "You are in";
> }
> }
>
> sub Error {
> print "The Error is with the status of the files , or senmdmail";
> }
>
In both cases where you use this there is no point in going on - you
either have no filehandle to write to or no sendmail process to write
to you should think about how to terminate your program cleanly without
sending a confusing message to the user.
Also you output a 'text/html' but do not actuall print any HTML - although
that is a quibble.
You probably want to look at the CGI FAQ at :
<http://www.webthing.com/tutorials/cgifaq.html>
Any how here is my rendering of the program using the module CGI.pm and
fixing all of the above points and others:
#!/usr/bin/perl -w
use CGI qw(:standard);
use strict;
# these are local values for me
my $mail_prog = '/usr/lib/sendmail -t';
my $filepath = '/usr/local/apache/htdocs/members/';
my %dispatch = (
'new' => \&newuser
);
print header(),start_html("Your title here");
if ( my $action = param('action'))
{
if (exists $dispatch{$action} )
{
&{$dispatch{$action}};
}
else
{
print "Invalid action";
}
}
else
{
print "No action specified"
}
print end_html;
sub newuser
{
my $user = param('user');
my $email = param('email');
my $password = param('password');
my $money = 100;
my $ufile = $filepath . $user . '.txt';
if (-e $ufile )
{
print "Sorry, Someone already has registered the username : $user";
}
else
{
if( open (NEW,">$ufile") )
{
print NEW join "\n" => ($user,$email,$password,$money);
print NEW "\n";
close (NEW);
if( open (NEWMAIL, "|$mail_prog"))
{
print NEWMAIL <<EOMAIL;
To: $email
From: ADMIN
Subject: Your new Account
Dear $user,
Thanks for signing up
EOMAIL
close (NEWMAIL);
}
print "You are in";
}
else
{
print "An error has occurred please contact the administrator";
}
}
}
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 13 Jun 1999 08:17:00 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: PLZ HELP
Message-Id: <Pine.GSO.4.02A.9906130815430.6999-100000@user2.teleport.com>
On Sat, 12 Jun 1999, Tim wrote:
> Subject: PLZ HELP
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> What is wrong with this?
It isn't cut down to a minimal example showing what behavior of Perl
doesn't meet your expectations, for one thing. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 13 Jun 1999 13:29:27 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: problem with BASE64
Message-Id: <7k0bnn$o1$1@gellyfish.btinternet.com>
On Sun, 13 Jun 1999 10:20:36 GMT baga@gmx.de wrote:
> I found that nice program in my perl book to for reading a base64
> file:
>
> while (<>) {
> tr#A-Za-z0-9+/##cd;
> tr#A-Za-z0-9+/# -_#;
> $len = pack("c", 32 + 0.75*length);
> print unpack("u", $len . $_);
> }
>
> and it works great with linux but not with windows nt (only with text
> messages but not with more complicate files like graphics).
> Does someone know a solution or why that happens?
>
In a word - binmode().
In more than a few words - when you read from <> on Linux or any other
Unix like system that you would care to imagine it doesnt matter whether
the file is 'binary' or 'text' the distinction on these systems is only
based on what is in the data not on how the system deals with them.
However on the children of the damned^W^W CP/M the distinction does
extend into the way that files are handled. This means that you will
have to use the function binmode() on the filehandles.
Explicitly in the case you will want to do:
binmode(ARGV);
before you start reading from <>.
You dont need to worry about having this on systems where it isnt need
because it is essentially a no-op on those systems.
perldoc -f binmode
for more on this.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 13 Jun 1999 13:46:37 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: problem with BASE64
Message-Id: <ebohlmanFD9q9p.C99@netcom.com>
baga@gmx.de wrote:
: I found that nice program in my perl book to for reading a base64
: file:
:
: while (<>) {
: tr#A-Za-z0-9+/##cd;
: tr#A-Za-z0-9+/# -_#;
: $len = pack("c", 32 + 0.75*length);
: print unpack("u", $len . $_);
: }
:
: and it works great with linux but not with windows nt (only with text
: messages but not with more complicate files like graphics).
: Does someone know a solution or why that happens?
My guess is that the code you have *is* in fact working, but that you're
printing its results to a filehandle that hasn't been binmode'd, so the
data is undergoing line-end translation (which is not what you want for
images or similar binary files).
------------------------------
Date: 13 Jun 1999 12:33:04 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Sort on mtime
Message-Id: <7k08e0$ib$1@gellyfish.btinternet.com>
On Sat, 12 Jun 1999 21:20:26 -0500 AEF wrote:
> More help please. I've got the stat, and date format going on , but not able
> to make the hash work to sort the mtimes.
>
You will probably want to read the perlfaq4 entry:
=head2 How do I sort an array by (anything)?
However here is a snippet that will print out a list of files sorted by
stat()[9] :
#!/usr/bin/perl -w
use strict;
my $base_dir = shift;
my %filedate;
opendir(DIR, $base_dir) || die "Can't open $base_dir\n";
my @files = map { $base_dir . '/' . $_ } grep !/^.{1,2}$/, readdir(DIR);
closedir(DIR);
foreach my $file (@files)
{
my $mtime = (stat($file))[9];
$filedate{$file} = $mtime;
}
my @sorted = sort { $a->[1] <=> $b->[1] }
map { [ $_, $filedate{$_} ] }
keys %filedate;
foreach (@sorted)
{
print $_->[0],"\t",scalar localtime($_->[1]),"\n";
}
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 13 Jun 1999 12:17:53 GMT
From: glhjd@zeus.bris.ac.uk (Hugh Dixon)
Subject: why didn't while(<$$_>) {} wrk?
Message-Id: <FD9M5u.1JL@fsa.bris.ac.uk>
Basically, I'm opening a set of sockets using $$_ = IO::Socket->new over
elements of an array.
This works fine but I can't get direct interpolation to work when doing
[looping over same array]
while (<$$_>) {
print STDOUT;
}
??
I tried ${$_} and {$$_} but neither do it, $thissockh = $$_ followed by
while(<$thissockh>) {
does work however..
(hence I'm not too bothered...)
Huh
--
------------------------------
Date: 13 Jun 1999 13:39:45 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: why didn't while(<$$_>) {} wrk?
Message-Id: <7k0cb1$o8$1@gellyfish.btinternet.com>
On Sun, 13 Jun 1999 12:17:53 GMT Hugh Dixon wrote:
> Basically, I'm opening a set of sockets using $$_ = IO::Socket->new over
> elements of an array.
It appears that you are trying to use a variable as a variable name - this
is not really what you want to do though you might not realise it at the
moment.
You probably want to use a hash like:
$sock_hash{$_} = IO::Socket->new;
This has a great number of advantages among which -
A) and most importantly you are not using a symbolic reference
B) You can retrieve the names (keys) that you have used by using
keys() on the hash.
C) People will look at the other aspects of your code without banging
on about the symbolic references ;-}
I will leave the FAQ bashing to others.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 13 Jun 1999 11:53:31 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: why didn't while(<$$_>) {} wrk?
Message-Id: <1dtc67y.z3xu2wkd6244N@p124.tc1.metro.ma.tiac.com>
Hugh Dixon <glhjd@zeus.bris.ac.uk> wrote:
> Basically, I'm opening a set of sockets using $$_ = IO::Socket->new over
> elements of an array.
> This works fine but I can't get direct interpolation to work when doing
> [looping over same array]
> while (<$$_>) {
> print STDOUT;
> }
>
> ??
>
> I tried ${$_} and {$$_} but neither do it, $thissockh = $$_ followed by
> while(<$thissockh>) {
> does work however..
> (hence I'm not too bothered...)
>
> Huh
You're not reading input, you're globbing filenames.
perlop:
I/O Operators
[...]
If what's within the angle brackets is neither a filehandle nor a
simple scalar variable containing a filehandle name, typeglob, or
typeglob reference, it is interpreted as a filename pattern to be
globbed, and either a list of filenames or the next filename in the
list is returned, depending on context. This distinction is
determined on syntactic grounds alone. That means <$x> is always a
readline from an indirect handle, but <$hash{key}> is always a glob.
That's because $x is a simple scalar variable, but $hash{key} is
not--it's a hash element.
$$_ is not a simple scalar variable, so you get a glob instead. You've
already deduced the appropriate work-around.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 13 Jun 1999 13:40:40 GMT
From: shr28@my-deja.com
Subject: win32: vba2perl
Message-Id: <7k0ccn$gn$1@nnrp1.deja.com>
I would like to use perl to open an excel workbook which
has links to a DDE server. The VBA syntax is as follows:
Workbooks.Open FileName:="G:\shami\RBC\converts\CONVPX.xls",
UpdateLinks:=0
I'm not sure what the equivalent perl Open statement should be. I've
tried passing the UpdateLinks=0 as an optional parameter, but that
doesn't seem to be working. Does anyone have any ideas?
Thanks.
_Shami
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 13 Jun 1999 15:18:14 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: win32: vba2perl
Message-Id: <7k0i3m$1ov$1@gellyfish.btinternet.com>
On Sun, 13 Jun 1999 13:40:40 GMT shr28@my-deja.com wrote:
> I would like to use perl to open an excel workbook which
> has links to a DDE server. The VBA syntax is as follows:
>
> Workbooks.Open FileName:="G:\shami\RBC\converts\CONVPX.xls",
> UpdateLinks:=0
>
> I'm not sure what the equivalent perl Open statement should be. I've
> tried passing the UpdateLinks=0 as an optional parameter, but that
> doesn't seem to be working. Does anyone have any ideas?
>
If you have a recent Activestate Perl then there is a wealth of
documentation installed under the "Activeperl" link in your start menu.
There is a Win32 specific FAQ that has a number of examples of working
with OLE in general and Excel specifically.
If you go to the Activestate web site <http://www.activestate.com> then
you will be able to find information about several Win32 specific
mailing lists which apparently are a good forum for the exchange of
information about Win32 specific Perl issues.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
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 5977
**************************************