[15999] in Perl-Users-Digest
Perl-Users Digest, Issue: 3411 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 18 03:21:03 2000
Date: Sun, 18 Jun 2000 00:20:34 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <961312834-v9-i3411@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 18 Jun 2000 Volume: 9 Number: 3411
Today's topics:
Re: Reintegrating win into CPAN (Was Re: What is the CP (Steve A. Taylor)
Re: Screen output from system command. duckjibe@my-deja.com
Server error with very simple perl script <shaimelz@dds.nl>
Re: Server error with very simple perl script (jason)
simple array question <ils@gil.com.au>
Re: simple array question (jason)
Re: Simple Question ~ How to perform a directory recurs (Neil Kandalgaonkar)
Re: Simple RegEx <grichards@flashcom.net>
Re: Simple RegEx (Tad McClellan)
Re: sorting algorithim (Tad McClellan)
Re: sorting an array <raphaelp@nr1webresource.com>
Re: sorting an array (Abigail)
Re: sorting an array <russ_jones@rac.ray.com>
Re: Taryag Perl <care227@attglobal.net>
Re: Text substitution problem <lr@hpl.hp.com>
Re: Text substitution problem <thomas@newtonlabs.org>
Re: Text substitution problem (Craig Berry)
Re: Text substitution problem <tina@streetmail.com>
Re: Ugh (jason)
Re: Ugh (jason)
Re: Where are the error logs? (David Wall)
Re: Yet Another Abigail Admirer (WAS Re: Crazy enough t (Clinton A. Pierce)
Re: Yet Another Abigail Admirer (WAS Re: Crazy enough t <mike@crusaders.no>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 18 Jun 2000 06:03:32 GMT
From: an400@freenet.carleton.ca (Steve A. Taylor)
Subject: Re: Reintegrating win into CPAN (Was Re: What is the CPAN module repository (url) name that can beused for PPM/VPM?)
Message-Id: <394c60ac.3385464@news.ncf.carleton.ca>
On 22 May 2000 19:04:17 -0500, Jeph <jeph@ucool.com> wrote:
>Thanks Jeff for clarifying my question. I did go to FAQ2 and looked
>at all the 5 or 6 repository links listed there. >.....<. I really hope the CPAN
>modules can be installed easily by using PPM/VPM. Thanks.
>
>Eric
>
>On Sat, 20 May 2000 12:40:59 -0700, Jeff Zucker <jeff@vpservices.com>
>>So it is acutally an interesting question. There is no equivalent of
>>CPAN for windoze .ppd files, or for that matter for linux .rpm files.
>>AS lists only their own .ppd files. Others have begun to make
>>repositories, for example, Simon Oliver has developed an excellent
>>repository specializing in database ppds at
>>http://www.bi.umist.ac.uk/packages. Simon's repository is listed on
>>www.perl.com, but not on CPAN, AFAIK. And if one uses cpan.search.org,
>>the .ppd files are, of course, not listed. So should CPAN itself
>>consider including .ppd files, allowing authors to upload them along
>>with the .gz files? Or even more radical -- should makeMaker or h2xs
>>or something be modified in such a way that one could create a
>>Makefile.PL that would accept a switch telling it whether it should run
>>in makefile mode or ppd mode and if the later to essentially run ppm
>>rather than creating a makefile.
>>
>>Sorry for the rambles, just some questions I have had in the back of my
>>mind about how to make the CPAN and installation process more similar
>>for all users. There are still a zillion readme files out there that
>>make no mention of ppm and therefore many newbies who go to CPAN and
>>then come here asking what the heck make is, or why it doesn't work for
>>them.
I hope someone with talent and skill is listening. Because many of
these Win32/Win95 problems are pure portability. Many knowledgeable
Perl hackers have written many useful programs...first for Unix, maybe
for Win32
The ppm avenue puts "module control" in the hands of ActiveState,
which needs to survive fiinancially as we try to update free modules.
The new CGI 'bundle' is not available (it seems) from AS.
CPAN tries to install it and does its job well many lines past
"Running make for L/LD/LDS/CGI.pm-2.68.tar.gz", to the crash:
"Openning [makefile] for read (success)
makefile: line 668: Error -- Expecting macro or rule defn,
found neither
Closing [makefile]
c:\batch\dmake.exe -p -v -- NOT OK
Running make test
Oops, make had returned bad status
Running make install
Oops, make had returned bad status
A skilled programmer (Unix, Perl, C) could look
at the makefile, and fix it.
Not the newbie "Windows" programmer who is talking.
The FAQs do not (yet) explain how to do it in Win32.
Rambling, I know;
But, how do we find the resources, the readable
perldocs to do this -- ALL -- the win32 modules
are suspect
- the binary arrives with fixed config
- perl itself doesn't compile and install
- cpan can't compile and install
- cpan can't fix Win32 bugs created by
a skilled Unix programmer
- go read, go read, go read
As noted elsewhere: If I
can't install it I can't read
Did I say Help!? :=|
Help because I _want_ perl.
One angle -- may exist -- the forum,
exchange of Win32 users who have
found answers
...
...tx
------------------------------
Date: Tue, 13 Jun 2000 15:39:31 -0400
From: duckjibe@my-deja.com
Subject: Re: Screen output from system command.
Message-Id: <642A954DD517D411B20C00508BCF23B001291B48@mail.sauder.com>
In article <8i5vpj$bk3$1@nnrp1.deja.com>,
Jean-Sebastien Morisset <jsmoriss@jsm-mv.dyndns.org> wrote:
> I'm having a little problem getting screen output from a system
command.
> The best I could do was:
>
> $output = `command`;
> print $output;
>
> If the command takes a long time, nothing is shown on the screen and
the
> user may abort the script. Are there any tricks to send system command
> output directly to the screen *while* the command is executing?
>
> Thanks,
> js.
> --
> Jean-Sebastien Morisset, Sr. UNIX Administrator
> <http://www.jsmoriss.dyndns.org/>;
> UNIX, the Internet, Homebrewing, Cigars, PCS, and other Fun Stuff...
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
how about something like
open(OUTPUT,"-|") || exec 'y.pl';
while ($X=<OUTPUT>){
print "$X";
}
where 'y.pl' is your command. If 'y.pl' does flush output the command
may still appear to 'hang'
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 14 Jun 2000 13:01:35 -0400
From: shaimelz <shaimelz@dds.nl>
Subject: Server error with very simple perl script
Message-Id: <642A954DD517D411B20C00508BCF23B001292D4F@mail.sauder.com>
Hi all,
I'm trying to run the underneath script on a unix machine with
apache....
- Permissions are set to 775
- Uploaded in ASCI format
- extension is .pl
- /usr/bin/perl is the executable for perl as said by my provider
What else do I need to do, to loose the server error's
#!/usr/bin/perl
# test.pl -- simpel test scriptje
print "Content-type: text/html\n\n";
print <<"EOF";
<HTML>
<HEAD>
<TITLE>Hello, world!</TITLE>
</HEAD>
<BODY>
<H1>Hello, world!</H1>
</BODY>
</HTML>
EOF
------------------------------
Date: Sun, 18 Jun 2000 05:59:17 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Server error with very simple perl script
Message-Id: <MPG.13b7026d178269ed989742@news>
shaimelz writes ..
>I'm trying to run the underneath script on a unix machine with
>apache....
>
>- Permissions are set to 775
>- Uploaded in ASCI format
>- extension is .pl
>- /usr/bin/perl is the executable for perl as said by my provider
>
>What else do I need to do, to loose the server error's
derr .. what server erro'r ?
and to preempt your answer - the problem is likely to be that you have
uncorrectly setup the .pl extension handler in your web server
configuration .. nothing to do with Perl - check your web server
documentation
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Wed, 14 Jun 2000 22:44:34 -0400
From: "Phil Sutcliffe" <ils@gil.com.au>
Subject: simple array question
Message-Id: <642A954DD517D411B20C00508BCF23B001292EFC@mail.sauder.com>
Hi,
Consider this.
@fields=("GBH","QLD","1234");
@names=("\$company","\$state","\$postcode");
Is there a way to get "GBH" into variable $company without using loops.
I realise I can do this
${$names[0]} = $fields[0];
What I'm looking for is something like
\@names = @fields; to get all the elements of @fields into the field names
contained in @names
Is there a simple one-liner to do this?
TIA,
Phil.
------------------------------
Date: Sun, 18 Jun 2000 06:23:19 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: simple array question
Message-Id: <MPG.13b708097b2ee70f989744@news>
Phil Sutcliffe writes ..
>Consider this.
>
>@fields=("GBH","QLD","1234");
>
>@names=("\$company","\$state","\$postcode");
>
>Is there a way to get "GBH" into variable $company without using loops.
>
>I realise I can do this
>
>${$names[0]} = $fields[0];
>
>What I'm looking for is something like
>
>\@names = @fields; to get all the elements of @fields into the field names
>contained in @names
>
>Is there a simple one-liner to do this?
there's a one liner .. but it's still a loop .. but the question that
your code really raises is - why aren't you using a hash ?
#!/usr/bin/perl -w
use strict;
my @fields = qw/GBH QLD 1234/;
my @names = qw/company state postcode/;
my %details = ();
@details{@names} = @fields;
print "$details{company} is in state $details{state} with postcode "
, "$details{postcode}\n";
__END__
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Mon, 12 Jun 2000 03:22:53 -0400
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: Simple Question ~ How to perform a directory recursive search ?
Message-Id: <642A954DD517D411B20C00508BCF23B00129186C@mail.sauder.com>
In article <yBZ05.11109$907.272697@newsread2.prod.itd.earthlink.net>,
Kenny Lim <kennylim@techie.com> wrote:
>(a) Is there a method to perform a directory recursive search (including
>subdirectories) "without having to use the File::Find standard module" ?
>(Snippets of my code is enclosed below)
Why would you not want to use File::Find?
Anyway, of course the answer is yes; you could simply reinvent what
File::Find does, perhaps in a less generalized way.
Or simply get the results of a 'find', if you are on unix.
>(b) Is there a method to only change the name of the file only when a
>criteria is met.
>
>Eg.
>
>Search for a matching strings called "old" and replace it with "new" in a
>file with
>*cpp *dsp *rc extension.
I got confused. Are you trying to change the filename or alter the contents?
Your code opened a second filehandle. I didn't understand the comments you
added after your code.
Anyway, perl has a rename().
Here's one way of modifying file *contents* which leans on shell tools
rather than File::Find. (n.b. this is GNU find 4.1)
$ find /my/dir -regex '.*\.\(cpp\|dsp\|rc\)' -print \
| xargs perl -pi.bak -e 's/search/replace/g'
This has the advantage of simplicity and safety. You'd have to do a lot
of wheel-reinventing to get something safe like perl -pi.bak; it makes
backups while modifying the file "in-place".
If you just wanted to rename it:
$ find /my/dir -regex '.*\.\(cpp\|dsp\|rc\)' -print \
| perl -wlne '(my $new = $_) =~ s/search/replace/; rename $_, $new'
See man find, and man perlrun for further explanation.
Or, find a good intro to unix shell scripting if everything here is
totally baffling to you.
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
Date: Tue, 13 Jun 2000 01:56:09 -0400
From: "Gabe" <grichards@flashcom.net>
Subject: Re: Simple RegEx
Message-Id: <642A954DD517D411B20C00508BCF23B001291A64@mail.sauder.com>
> >So basically, what's the expression to match and return all digits in a
> >string?
>
>
> my $result = $1 if $gettbldef->[$i]->[1] =~ /(\d*)/;
Thanks for the advice and help. But this still isn't working for me. My code
stands at:
$val = 'int(11)';
$fldnames[$i] = 'prosid';
$fldsize{$fldnames[$i]} = $1 if $val =~ /(\d*)/;
print $1; #$1 is empty!
Gabe
------------------------------
Date: Tue, 13 Jun 2000 00:46:25 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Simple RegEx
Message-Id: <642A954DD517D411B20C00508BCF23B001291A67@mail.sauder.com>
On Tue, 13 Jun 2000 00:15:42 -0400, Tad McClellan <tadmc@metronet.com> wrote:
>On Mon, 12 Jun 2000 21:14:05 -0700, Gabe <grichards@flashcom.net> wrote:
>
>>This is easy, I just don't know much about RegEx yet.
>>I was using:
>>
>> $fldsize{"$fldnames[$i]"} = ($tbldef->[$i]->[1] =~ /\d*/);
>>but that just sets the hash value to 1, not 15.
>Looks like you got a "true" for the result of your pattern match.
BTW, you will get a true for ANY value of $tbldef->[$i]->[1] !
You specified zero or more digit chars.
*Every* string has zero digit chars.
If you want to match digit chars, you should require at least
one digit char.
>>So basically, what's the expression to match and return all digits in a
>>string?
>
>
> my $result = $1 if $gettbldef->[$i]->[1] =~ /(\d*)/;
So make that:
my $result = $1 if $gettbldef->[$i]->[1] =~ /(\d+)/;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 13 Jun 2000 13:19:41 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: sorting algorithim
Message-Id: <642A954DD517D411B20C00508BCF23B001291B15@mail.sauder.com>
On Tue, 13 Jun 2000 09:04:45 -0500, Kefka_X <broberts@cbu.edu> wrote:
>
>I need help
Show us the code you have so far, and we will help you.
>creating a sorting algorithim in Perl that sorts data by Time
>of day.
Where does the "Time" come from?
What format is it?
>The time is chosen from a drop-down menu.
Perl does not have drop-down menus, so nobody knows what
you are talking about there.
You have not shown us the data.
You have not shown us the code.
We are good, but not so good that we can fix unseen stuff...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 13 Jun 2000 11:24:30 -0400
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: Re: sorting an array
Message-Id: <642A954DD517D411B20C00508BCF23B001291ADC@mail.sauder.com>
or maybe easter? But then again not everyone celebrates easter so not
everyone will get it for free! :-)
Marco Natoni <blah@nospam.com> wrote in message
news:39464FAC.89D33CB7@nospam.com...
> Eric,
>
> Eric Bohlman wrote:
> >> Ok stupid question time, what the heck is RTFM?
> > Read The Free Manual.
> ^^^^
> Is it just Christmas time again? :)
>
>
> Best regards,
> Marco
------------------------------
Date: Thu, 15 Jun 2000 15:50:13 -0400
From: abigail@delanet.com (Abigail)
Subject: Re: sorting an array
Message-Id: <642A954DD517D411B20C00508BCF23B0012930CD@mail.sauder.com>
Russ Jones (russ_jones@rac.ray.com) wrote on MMCDLXXX September MCMXCIII
in <URL:news:39492138.284C7DF7@rac.ray.com>:
\\
\\ Okay, the data base engine was Oracle 7.x and 8.x running on HP-UX and
\\ on Sequent. The databases were accessed locally and using SQL net. And
\\ a database that's indexed by employee name isn't pre-sorted by
\\ employee number or department number or etc. etc. etc.
So, if you have to run this program more than once, why don't you build
an index on whatever it is you want to sort on? Then you only need to
sort it once.
Abigail
--
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
|perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
|perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
|perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;
------------------------------
Date: Wed, 14 Jun 2000 17:47:38 -0400
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: sorting an array
Message-Id: <642A954DD517D411B20C00508BCF23B001292DD6@mail.sauder.com>
Tom Briles wrote:
>
> Larry Rosler wrote:
> >
> > Instead of using the SQL 'ORDER BY' capability -- which imposes the
> > computational burden on the database daemon (which may be on a separate
> > machine, and may be handling several requests simultaneously) -- I
> > prefer to sort in the application that requests the data. I know how to
> > do sorting in Perl efficiently (-:) and more flexibly than SQL can.
> >
> > I would be interested in other experiences with this kind of tradeoff
> > between the Perl program and the database server.
>
> I don't think that it's quantifiable in a general way.
>
I did a bunch of benchmarking of various sort methods, including
Perl's sort, the HP-UX and Sequent command line sort, SQL 'ORDER BY'
and SyncSort for Unix. We tried to take into account such factors as
number of records to sort, record length, sort key, collating sequence
(numeric, alpha, etc.), original "sortedness" of the data, network
traffic when the data was on another server from the sort program,
caches and buffers, etc. to make it a fair comparison of apples and
oranges as was possible.
Except for the most trivial sorts (under 100 eighty-byte records, if I
recall) SQL never was the fastest. On sorts of more than a gig of
records, Perl took maybe 95% of the time the system sort took, 30% of
SQL 'ORDER BY' (dammit Larry, you typed it in all caps so that must be
right and now *I* have to type it in all caps). The real speed demon
was SyncSort. It was typically twice as fast as any other sorting
method.
I did this testing at another company and I don't have a copy of the
results, but they were eye-opening. Oh yeah, the REAL real speed demon
was SyncSort/MVS running on a very well tuned IBM 3090. A sort that
took SyncSort/Unix three minutes took under a second on the mainframe.
--
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
When cryptography is outlawed, only outlaws will
A2bgg c4dc8 aji0i knS4E 7eFj8 22Rl1
ZdGg3 gu8i6 lu12N s6NoG gn3g3 q835n
------------------------------
Date: Thu, 15 Jun 2000 15:57:16 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Taryag Perl
Message-Id: <642A954DD517D411B20C00508BCF23B001293106@mail.sauder.com>
Micha Berger wrote:
>
> In soc.culture.jewish Tad McClellan <tadmc@metronet.com> wrote:
> :>> Is it just a coincidence that ActiveState's lastest
> :>> release is "build 613"? I think not.... :)
>
> : What is "Taryag"?
>
> The gematria system for Hebrew goes up to 400 -- the value of the last letter,
> taph. To get 600 you need to write taph-reish (400+200).
>
> To write 613, you write taph-reish-yud-gimel. But that lacks vowels, as they
> are indicated by special pointing, not be letters. Throwing in two patachs
> (the sound of a in father or o in alot) for the vowels, you get "Taryag".
Sorry for not noticing the cross post here either. BUT, now that
I know what the word means (kinda, I guess) can you explain the
relation to the Perl programming language? Is 613 an evil number,
or just the upper bound of the comandments?
OP... what were you trying to convey???
------------------------------
Date: Fri, 16 Jun 2000 17:35:22 -0400
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Text substitution problem
Message-Id: <642A954DD517D411B20C00508BCF23B00129342D@mail.sauder.com>
In article <8ie5rb$4mbdj$5@fu-berlin.de> on 16 Jun 2000 21:22:51 GMT,
Tina Mueller <tina@streetmail.com> says...
> Craig Berry <cberry@cinenet.net> wrote:
> > Johannes (gedichte@lycosmail.com) wrote:
> > : If $postinput is a multiline string you should use: $postinput =~
> > : s/=//mg;
>
> > The /m modifier only makes a difference if the match string contains ^ or
> > $, which this one does not.
>
> and if the pattern contains "."
No. That is irrelevant. You are thinking of /s.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 16 Jun 2000 13:04:58 -0400
From: "Thomas L. Newton" <thomas@newtonlabs.org>
Subject: Re: Text substitution problem
Message-Id: <642A954DD517D411B20C00508BCF23B001293346@mail.sauder.com>
When I can't figure out what is going on, I through it into an array
and look at the output.
@testArray = split (/\=/,$postinput);
print "@testArray\n";
-Thomas Newton
Johannes wrote:
>
> If $postinput is a multiline string you should use: $postinput =~
> s/=//mg;
>
> verio wrote:
>
> > Can anyone tell me how I can delete equal signs (=) from a text file?
> >
> > I have tried:
> > $postinput =~ s/=//g;
> > $postinput =~ s/\=//g;
> > $postinput =~ s/\W//g;
> > $postinput =~ s/\061//g;
> > $postinput =~ s/[=]//g;
> > and a lot of other variations that make even less sense.
> >
> > viciousdogs@zdnetmail.com
------------------------------
Date: Fri, 16 Jun 2000 17:17:27 -0400
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Text substitution problem
Message-Id: <642A954DD517D411B20C00508BCF23B0012933F1@mail.sauder.com>
Johannes (gedichte@lycosmail.com) wrote:
: If $postinput is a multiline string you should use: $postinput =~
: s/=//mg;
The /m modifier only makes a difference if the match string contains ^ or
$, which this one does not.
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Beauty and strength, leaping laughter and delicious
| languor, force and fire, are of us." - Liber AL II:20
------------------------------
Date: Fri, 16 Jun 2000 17:22:51 -0400
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Text substitution problem
Message-Id: <642A954DD517D411B20C00508BCF23B0012933FA@mail.sauder.com>
hi,
Craig Berry <cberry@cinenet.net> wrote:
> Johannes (gedichte@lycosmail.com) wrote:
> : If $postinput is a multiline string you should use: $postinput =~
> : s/=//mg;
> The /m modifier only makes a difference if the match string contains ^ or
> $, which this one does not.
and if the pattern contains "."
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Sat, 17 Jun 2000 08:41:07 -0400
From: elephant@squirrelgroup.com (jason)
Subject: Re: Ugh
Message-Id: <642A954DD517D411B20C00508BCF23B001293592@mail.sauder.com>
Bart Lateur writes ..
>jason wrote:
>
>>>Try this useful little script which I call
>>>macorpc2unix:
>>>
>>>#!/usr/bin/perl -w -i
>>>while (<>) {s/\r\n*/\n/g;}
>>>continue {print;}
>>
>>you should add that the above has to be done once over on UNIX otherwise
>>there will not be any "\r\n"s in the file as the filehandle was not
>>binmoded
>
>True, but if this was done on a PC, it wouldn't matter. Bare "\r"
>characters would still be there, and be replaced.
no they're not .. the filehandle is not binmoded - so the lines read in
with <> will not contain "\r\n" .. they will contain "\n" as their line
endings (once in Perl)
I might have caused some confusion by using the term "file" in my post
above when I meant "strings read from the file by Perl"
>But the bare linefeeds in the output would still be converted into CRLF
>pairs, unless you do binmode on the output handle.
you did read that we're going from Windows -> UNIX didn't you ?
>n.b. The meaning of "\r" and "\n" is platform dependent. On a Mac, "\n"
>is chr(13) (because that is what the Mac uses), and "\r" is "the other
>one", i.e. chr(10).
the meaning is only platform dependant when reading from or writing to a
non-binmoded filehandle
read from a text filehandle on Windows and all CRLF sequences are
converted to LFs .. and the reverse is done on a write
the 'meaning' inside the Perl code is the same - and platform
independent .. the only magic happens when writing to or from a non-
binmoded filehandle
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Sun, 18 Jun 2000 06:40:50 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Ugh
Message-Id: <MPG.13b70c22a611f38f989745@news>
Bart Lateur writes ..
>jason wrote:
>
>>>True, but if this was done on a PC, it wouldn't matter. Bare "\r"
>>>characters would still be there, and be replaced.
>>
>>no they're not .. the filehandle is not binmoded - so the lines read in
>>with <> will not contain "\r\n" .. they will contain "\n" as their line
>>endings (once in Perl)
>
>If the contents of a file was "Line one\015Line two\015\012", then,
>without binmode, the string read would be "Line one\015Line two\012".
>CRLF *pairs* are indeed turned into newlines, but a CR not followed by
>LF would remain a CR. Honestly.
that is completely irrelevant .. the originator was concerned with
turning Win32 line-endings into UNIX line-endings .. if you ran the
following code on a Win32 machine then it will not make any conversion
#!/usr/bin/perl -w -i
while (<>) {s/\r\n*/\n/g;}
continue {print;}
because the final print statement will turn ALL "\n" characters into
"\r\n" sequences on the write
SO .. the code will only work for Win32 -> UNIX line ending translation
IF run on the UNIX machine .. a valid point to be made if posting the
above code
what is done with "\r" when they're not followed by "\n"s is completely
irrelevant .. the originator wanted some code to convert Win32 line
endings to UNIX ones .. and the code sample provided by Helgi will ONLY
do that if run on the UNIX side of the transfer .. that's all I was
saying and it is completely accurate
>>>But the bare linefeeds in the output would still be converted into CRLF
>>>pairs, unless you do binmode on the output handle.
>>
>>you did read that we're going from Windows -> UNIX didn't you ?
>
>Yes, but you didn't say on what platform.
I didn't say on what platform -> eh ?????? .. here's the text from my
post
>you should add that the above has to be done once over on UNIX otherwise
>there will not be any "\r\n"s in the file as the filehandle was not
>binmoded
the originator said that they developed on Windows and transferred the
file to UNIX .. so the only two platforms that were being discussed were
Windows and UNIX .. my statement above says that the code needed to be
run on UNIX _otherwise_ there will not be any CRLFs...etc. .. implicit
within the 'otherwise' is that we're now talking Windows (seeing as they
were the only two operating systems being discussed in this thread)
> Since you complained about not
>using binmode when run on a PC, well, I tell you: if you carefully got
>rid of all the "\r" characters, and your printed to a file without
>binmode, they'd magically reappear in the output.
that was my whole point .. I said that the post from Helgi's containing
the code which 'carefully got rid of all the "\r" characters' should
also contain a caveat that the code needed to be run on UNIX
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Sat, 17 Jun 2000 11:49:07 -0400
From: darkon@one.net (David Wall)
Subject: Re: Where are the error logs?
Message-Id: <642A954DD517D411B20C00508BCF23B0012935C5@mail.sauder.com>
funny@aol.com (Johnny) wrote in
<wDf25.68336$nl3.245040@typhoon.ne.mediaone.net>:
>Hi,
>
>I'm using Perl on an NT IIS server and can't seem to find the error logs
>that I was hoping would help me debug my perl scripts.
>
>Any ideas where they are?
IIRC, they're in \Perl\bin\PerlIS-Err.log. My setup may be atypical, but I
don't recall altering the defaults, and I do recall looking for it myself.
--
David Wall
darkon@one.net
------------------------------
Date: Sat, 17 Jun 2000 11:42:10 -0400
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Yet Another Abigail Admirer (WAS Re: Crazy enough that it might just work...) :)
Message-Id: <642A954DD517D411B20C00508BCF23B0012935B3@mail.sauder.com>
[Posted and mailed]
In article <slrn8kmngd.44i.tjla@thislove.dyndns.org>,
tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:
> I was shocked! How could Abigail <abigail@delanet.com>
> say such a terrible thing:
>>Abigail
>>--
>>perl -Mstrict -we '$_ = "goto E.print chop;\n=rekcaH lreP rehtona tsuJ";E1:eval'
>
> I have looked at this and looked at this and I just cannot see how it
> works. Could someone please provide an explanation?
Sure, watch closely...
strict is here for show (showoff, Abigail!), as are warnings.
-e says "evaluate this:". Now the rest of it, ignore the newlines for the moment,
they're for clarity.
$_="
goto E.print chop;
\n=rekcaH lreP rehtona tsuJ";
E1:eval
So $_ is a set to "goto E.print chop;\n=rekcaH lreP rehtona tsuJ"
E1 is just a label, and is ignored for now.
eval (without an argument) will evaluate $_.
Now here's the tricky part:
Ignore the "goto E" part until we can get the return value
from print...which needs to run chop first..
chop takes that string $_ and removes the last character and you
get "J".
print prints the "J"
the return value from print is 1 (normally)
So we goto E1 (out of the eval block, back in the main code...)
E1 now runs the eval again, with $_ set to
goto E.print chop;\n=rekcaH lreP rehtona tsu
(the J is mising)
This continues until... until what?
As it turns out "\n=junk" will evaluate just fine. Don't ask me why, but
you can prove it to yourself with:
#!/usr/bin/perl
$foo="\n=junk";
eval $foo;
print $@;
("Perl is an empirical art. Don't ask us if something works"--purl on #perl)
And $@ (the error return from eval) will be empty, i.e. it worked.
However, "\n=" will NOT parse correctly. So eventually our "eval"
string eventually gets down to:
goto E.print chop;\n=
And the eval at the end fails. And since no "goto" was executed this
time, we don't try it again.
And that's how it works! Who says Perl is a write-only language? :) I
should use Abigail's JAPH's for interviewing recruits that claim to know
Perl on an expert level...
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Sat, 17 Jun 2000 12:20:41 -0400
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: Yet Another Abigail Admirer (WAS Re: Crazy enough that it might just work...) :)
Message-Id: <642A954DD517D411B20C00508BCF23B0012935BF@mail.sauder.com>
Gwyn Judd <tjla@guvfybir.qlaqaf.bet> skrev i
meldingsnyheter:slrn8kmngd.44i.tjla@thislove.dyndns.org...
> >perl -Mstrict -we '$_ = "goto E.print chop;\n=rekcaH lreP rehtona
tsuJ";E1:eval'
> I have looked at this and looked at this and I just cannot see how it
> works. Could someone please provide an explanation?
Well, I could always try :-)
I think this looks like a very nice and fancy variation of
perl -e '$_ = "rekcaH lreP rehtona tsuJ";print chop while $_;'
anyway.
first of all. Since $_ contains the real program that will be repeatedly
eval'ed Let's write $_ a little bit less tightly.
goto 'E' . print(chop $_);
=rekcaH lreP rehtona tsuJ
strict and -w doesn't complain about the second line because the = tells it
that the line is for POD
So - chop cuts the last letter from $_ and returns it to print that prints
it. print returns 1 which is appended to E, so we're left with.
goto E1;
and of course, at E1 there is only eval which evals $_ and so we just start
over again.
It took me a little bit of head-scratching to find out why it stops after
printing "Just another Perl Hacker", but then it occured to me. After
chopping and printing for a while, $_ is reduced to
goto 'E' . print(chop $_);
=
which won't compile, so the program just continues. Since eval was the last
part of the program we're finished.
--
Trond Michelsen
(hope I didn't miss anything :)
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 3411
**************************************