[13674] in Perl-Users-Digest
Perl-Users Digest, Issue: 1084 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 15 16:27:58 1999
Date: Fri, 15 Oct 1999 13:27:42 -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: <940019261-v9-i1084@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 15 Oct 1999 Volume: 9 Number: 1084
Today's topics:
Whoa! scalar(split()) clobbers @_? <mark.reed@cnn.com>
Re: Whoa! scalar(split()) clobbers @_? <rootbeer@redcat.com>
Re: Whoa! scalar(split()) clobbers @_? (M.J.T. Guy)
Win32: Communicate w/ printer dirk_ruediger@my-deja.com
Re: Win32: Communicate w/ printer <dchristensen@california.com>
Re: Win32: Communicate w/ printer <gellyfish@gellyfish.com>
Win32::NetAdmin (Michael F. Loll)
Win95 / WinNT Question <uhuenemoerder@hotmail.com>
Re: Win95 / WinNT Question (Brett W. McCoy)
Re: Win95 / WinNT Question <dchristensen@california.com>
Re: Win95 / WinNT Question <steve@iboats.com>
Re: Win95 / WinNT Question <carvdawg@patriot.net>
Re: Win95 / WinNT Question (Brett W. McCoy)
Re: Win95 / WinNT Question <msalter@bestweb.net>
Re: Win95 / WinNT Question (Brett W. McCoy)
Re: Win95 / WinNT Question rwentwor@advent.com
Re: working perl -pie workaround (Pythagoras Watson)
Re: working perl -pie workaround <dan@tuatha.sidhe.org>
Re: working perl -pie workaround <rootbeer@redcat.com>
Re: working perl -pie workaround (Charles DeRykus)
Re: working perl -pie workaround (Ken Pizzini)
Re: working perl -pie workaround (Ilya Zakharevich)
Re: working perl -pie workaround (Charles DeRykus)
Re: working perl -pie workaround (Charles DeRykus)
Re: working perl -pie workaround mike808@mo.net
Writing an IMAP Client <howitgolook@my-deja.com>
XML::Parser, Entities and Attributes <kevin.lund@iname.com>
Re: XML::Parser, Entities and Attributes <ken@bitsko.slc.ut.us>
Re: XML::Parser, Entities and Attributes <kevin.lund@iname.com>
Re: XML::Parser, Entities and Attributes <kevin.lund@iname.com>
Re: Y2K update for ctime.pl (Abigail)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 13 Oct 1999 17:11:38 -0400
From: "Mark J. Reed" <mark.reed@cnn.com>
Subject: Whoa! scalar(split()) clobbers @_?
Message-Id: <3804F58A.27EF03B3@cnn.com>
I just ran across an unexpected behavior of split() - namely, that if
called in scalar context, it splits into the @_ array. My customary
perl -cw pass warned me about this "deprecated" usage, which wasn't even
my intent; I was calling it in a scalar context because it seemed like a
quick and dirty way to count occurrances of the delimeter. I didn't
need - or want - the actual array to go anywhere, certainly not into @_
. . .
I note that this behavior is not mentioned anywhere in the Blue Camel
(although it is in perldoc -f split, and it might have been mentioned in
the Pink Camel, but I don't have that with me here).
And it's relatively easy to work around this, once you know it's there.
One way is to use a dummy array:
my $count = scalar(my @dummy = split(...));
But since Perl doesn't usually have nasty surprises like this (No, I'm
not kidding - at least once you get your head around the Perl mindset),
I was wondering if anyone could provide some historical background on
the design? Perl is full of implicit defaults, but they're usually
inputs; implicit modification of global variables is downright, well,
scary. Logical, perhaps, at least in the case where you just call
'split;' and let the defaults do their magic - but even then, it would
seem to make more sense to do it in void context rather than scalar.
And how "deprecated" is "deprecated"? Official deprecation means it's
fair game for elimination in Perl 6, right? So will this go away in
Topaz?
------------------------------
Date: Wed, 13 Oct 1999 19:34:42 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Whoa! scalar(split()) clobbers @_?
Message-Id: <Pine.GSO.4.10.9910131918420.25558-100000@user2.teleport.com>
On Wed, 13 Oct 1999, Mark J. Reed wrote:
> I was calling it in a scalar context because it seemed like a
> quick and dirty way to count occurrances of the delimeter.
Or, maybe the number of fields, rather than their separators. :-)
> But since Perl doesn't usually have nasty surprises like this (No, I'm
> not kidding - at least once you get your head around the Perl mindset),
Yes, Perl is completely intuitive, once you install Larry's brain.
> I was wondering if anyone could provide some historical background on
> the design?
As I understand it, "it seemed like a good idea at the time". Much like
Jar Jar Binks.
> And how "deprecated" is "deprecated"? Official deprecation means it's
> fair game for elimination in Perl 6, right? So will this go away in
> Topaz?
First of all, Topaz isn't Perl 6, and Perl 6 isn't Topaz. That's why they
have different names. :-) It may be that, someday, when and if Topaz is
finished, and it works, and it works at least as well as existing Perl
does, _then_ it may become Perl 6. Or maybe Perl 7, or 8, or 42 by that
time.
But as far as deprecation goes, Larry's rule has generally seemed to be
that we shall break no code before its time. That is, unless there's a
pressing reason to remove a feature that was in more-or-less heavy use in
old code, we may as well keep it around.
Of course, if Chip doesn't implement scalar split in Topaz, Larry probably
won't insist on putting it in....
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 14 Oct 1999 18:25:41 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Whoa! scalar(split()) clobbers @_?
Message-Id: <7u5775$nnk$1@pegasus.csx.cam.ac.uk>
In article <3804F58A.27EF03B3@cnn.com>, Mark J. Reed <mark.reed@cnn.com> wrote:
>
>And it's relatively easy to work around this, once you know it's there.
>One way is to use a dummy array:
>
> my $count = scalar(my @dummy = split(...));
Don't even need a dummy array. The standard idiom, which gets posted
here quite often, is
my $count = () = split(/re/, $str, -1);
Mike Guy
------------------------------
Date: Thu, 14 Oct 1999 17:11:05 GMT
From: dirk_ruediger@my-deja.com
Subject: Win32: Communicate w/ printer
Message-Id: <7u52qq$tci$1@nnrp1.deja.com>
Hi,
Currently I programming in perl and the program
has to work on different platforms (Linux, AIX,
Win32).
In Win32 I want to communicate with a
(local/Workgroup-) printer (get his
charactristics, state of print spool) and transfer
data to it to print it.
How can I do that (OLE, Ports, Special Files,
...)?
Thanks in advance!
Ciao for now, Dirk
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 14 Oct 1999 12:36:03 -0700
From: "David Christensen" <dchristensen@california.com>
Subject: Re: Win32: Communicate w/ printer
Message-Id: <38062d80_3@news5.newsfeeds.com>
Dirk:
I have been thinking about how to pretty print forms-based reports
(fonts, tables, graphics, etc.) in a platform independent way from
a Perl console or Perl/Tk app. No answers yet, just some ideas:
1) Perl/Tk graphics viewer and a postscript or LaserJet PCL
back-end (how to submit?);
2) postscript generator and a viewer (ghostscript) (how to
automate?);
3) HTML generator (Perl/Cgi) and a browser (how to automate?).
As for querying printer/ queue status, I dunno. Sounds like a
platform-independent abstraction (Perl API) and
architecture-specific modules are needed (?).
Does anybody else have ideas or experience trying a solution?
--
David Christensen
dchristensen@california.com
dirk_ruediger@my-deja.com wrote in message
<7u52qq$tci$1@nnrp1.deja.com>...
>Hi,
>
>Currently I programming in perl and the program
>has to work on different platforms (Linux, AIX,
>Win32).
>In Win32 I want to communicate with a
>(local/Workgroup-) printer (get his
>charactristics, state of print spool) and transfer
>data to it to print it.
>How can I do that (OLE, Ports, Special Files,
>...)?
>
>Thanks in advance!
>
>Ciao for now, Dirk
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 15 Oct 1999 09:33:44 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Win32: Communicate w/ printer
Message-Id: <3806e6e8_1@newsread3.dircon.co.uk>
dirk_ruediger@my-deja.com wrote:
> Hi,
>
> Currently I programming in perl and the program
> has to work on different platforms (Linux, AIX,
> Win32).
> In Win32 I want to communicate with a
> (local/Workgroup-) printer (get his
> charactristics, state of print spool) and transfer
> data to it to print it.
#!/usr/bin/perl -w
use strict;
open(PRINTER,">>//cheshire/creslex") or die "$!\n";
print PRINTER <<EOBB;
yahs
klslkdlk
ld;s;s
EOBB
close PRINTER;
/J\
--
"The most frightening thing on television since Anthea Turner revealed
she had a sister" - Suggs
------------------------------
Date: 15 Oct 1999 13:36:48 GMT
From: mloll@wam.umd.edu (Michael F. Loll)
Subject: Win32::NetAdmin
Message-Id: <7u7alg$mac$1@dailyplanet.wam.umd.edu>
Hi, I'm trying to use the Win32::NetAdmin module to create users on an NT
server, via the UserCreate() function. However, I keep getting an error:
' No such file oor directory at create.pl line 71 '
Line 71 is, obviously, the line where the UserCreate function is executed.
Now, the definition of the UserCreate function is as follows:
UserCreate(server, username, password, password age, privilege, home
directory, comment, flags, script path)
And my code looks like:
die "Could not create account: $!" if !( UserCreate( $server, $userName,
$password, $passwordAge, $privilege, $homeDir, $comment, $flags,
$scriptPath) );
( please ignore the word wrap, it is all on one line )
Now, $server, $userName, $password, $privilege, $comment, $flags are set
correctly I believe, but $passwordAge = "" because I do not want the
apssword to expire, and $homeDir is set to c:\\winnt\\profiles\\ and
$scriptPath is set to "" ebcause there is no login script.
Now, does anyone know what is going on? Are there any good tutorials on
how to effectively use the Win32::NetAdmin module? The pod docs are not
that well elaborated on the usage, they just give the functions
definitions.
Thanks.
Oh, if you respond could you please CC a copy to mloll@wam.umd.edu.
Thanks.
--
Mike Loll mloll@wam.umd.edu
"Opportunities multiply as they are seized."
-- Sun Tzu, The Art of War
------------------------------
Date: Thu, 14 Oct 1999 21:39:54 +0100
From: "Ulrich Huenemoerder" <uhuenemoerder@hotmail.com>
Subject: Win95 / WinNT Question
Message-Id: <7u5cgg$82p$1@bnews.gigabell.net>
Hello all,
I'm afraid this a simple one, but I have no ídea.
I'm running perl script under Win95. I attached the extension .pl to the
perl-interpreter and double clicking .pl-files in the explorer executes
them. But running those scripts from the command line does not work without
executing the perl.exe explicitly.
> perl hello.pl
works.
> hello.pl
does not, wheras it does under WinNT.
Is this a limitation of the Win95 shell?
Thanks (especially for your patience),
Ulrich.
------------------------------
Date: Thu, 14 Oct 1999 20:13:30 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Win95 / WinNT Question
Message-Id: <slrn80cejb.ng.bmccoy@moebius.foiservices.com>
Also Sprach Ulrich Huenemoerder <uhuenemoerder@hotmail.com>:
>I'm afraid this a simple one, but I have no ídea.
>
>I'm running perl script under Win95. I attached the extension .pl to the
>perl-interpreter and double clicking .pl-files in the explorer executes
>them. But running those scripts from the command line does not work without
>executing the perl.exe explicitly.
>
>> perl hello.pl
>
>works.
>
>> hello.pl
>
>does not, wheras it does under WinNT.
>
>Is this a limitation of the Win95 shell?
Yep. Read the ActiveState documentation. You can use the perl2bat
utility to embed your perl program in a batch file and execute it that
way.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Thu, 14 Oct 1999 13:53:49 -0700
From: "David Christensen" <dchristensen@california.com>
Subject: Re: Win95 / WinNT Question
Message-Id: <38063f79_7@news5.newsfeeds.com>
Ulrich:
>> perl hello.pl
>
>works.
>
>> hello.pl
>
>does not, wheras it does under WinNT.
>
>Is this a limitation of the Win95 shell?
Yup. Same on Win98 and Win98/2.
Buy this: http://www.fsf.org/order/windows.html, run Bash, rename
your script 'hello' (strictly speaking, '.pl' is for Perl
libraries), put in the shebang line, and type 'hello' at the
command prompt (or shell scripts, or Perl scripts, etc.). In
addition to Bash, you also get DJGPP and ports of Perl 5.004 and a
whole bunch of Un*x utilities (awk, sed, grep, less, man, etc.).
See http://www.dnai.com/~dchrist/HOWTO/ for how to glue it all
together with ActivePerl and vim.
--
David Christensen
dchristensen@california.com
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Thu, 14 Oct 1999 15:16:22 -0600
From: Steve Wolfe <steve@iboats.com>
Subject: Re: Win95 / WinNT Question
Message-Id: <38064826.C7D23A97@iboats.com>
> > perl hello.pl
>
> works.
>
> > hello.pl
>
> does not, wheras it does under WinNT.
>
> Is this a limitation of the Win95 shell?
Yes. You could also use "start hello.pl", but that doesn't help too
much.
steve
------------------------------
Date: Fri, 15 Oct 1999 06:10:37 -0400
From: "Harlan Carvey, CISSP" <carvdawg@patriot.net>
Subject: Re: Win95 / WinNT Question
Message-Id: <3806FD9D.B62E22AF@patriot.net>
> I'm running perl script under Win95. I attached the extension .pl to the
> perl-interpreter and double clicking .pl-files in the explorer executes
> them. But running those scripts from the command line does not work without
> executing the perl.exe explicitly.
It's a path issue. Here's two things you can do:
1. Make the very first line in the script point to the perl.exe...
#! c:\perl\bin\perl.exe
2. In your environment, modify the PATHEXT environment variable to
include .pl...so it should look something like:
PATHEXT=.com;.bat;.sys;.exe;.pl
------------------------------
Date: Fri, 15 Oct 1999 13:54:50 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Win95 / WinNT Question
Message-Id: <slrn80ecpd.4oc.bmccoy@moebius.foiservices.com>
Also Sprach Harlan Carvey, CISSP <carvdawg@patriot.net>:
>> I'm running perl script under Win95. I attached the extension .pl to the
>> perl-interpreter and double clicking .pl-files in the explorer executes
>> them. But running those scripts from the command line does not work without
>> executing the perl.exe explicitly.
>
>It's a path issue. Here's two things you can do:
>
>1. Make the very first line in the script point to the perl.exe...
>
> #! c:\perl\bin\perl.exe
Are you sure this works under Windows 95? It doesn't even work under
Windows 98, unless one is using CygWin.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Fri, 15 Oct 1999 14:11:15 GMT
From: Mike Salter <msalter@bestweb.net>
Subject: Re: Win95 / WinNT Question
Message-Id: <Pine.BSF.4.05.9910151005460.5719-100000@monet.bestweb.net>
On Fri, 15 Oct 1999, Harlan Carvey, CISSP wrote:
HCC>Date: Fri, 15 Oct 1999 06:10:37 -0400
HCC>From: "Harlan Carvey, CISSP" <carvdawg@patriot.net>
HCC>Newsgroups: comp.lang.perl.misc
HCC>Subject: Re: Win95 / WinNT Question
HCC>
HCC>> I'm running perl script under Win95. I attached the extension .pl to the
HCC>> perl-interpreter and double clicking .pl-files in the explorer executes
HCC>> them. But running those scripts from the command line does not work without
HCC>> executing the perl.exe explicitly.
HCC>
HCC>It's a path issue. Here's two things you can do:
HCC>
HCC>1. Make the very first line in the script point to the perl.exe...
HCC>
HCC> #! c:\perl\bin\perl.exe
HCC>
HCC>2. In your environment, modify the PATHEXT environment variable to
HCC> include .pl...so it should look something like:
HCC>
HCC> PATHEXT=.com;.bat;.sys;.exe;.pl
HCC>
Actually, I looked at my Win95 machine last nite, in \perl\bin\ and found
perldoc.bat. It is a combination DOS BAT file and perl script. A similar
technique is described on page 12 of the Camel book for unix. Take a look
at any BAT files in this directory, as I think this is what you're looking
for.
Mike
------------------------------
Date: Fri, 15 Oct 1999 14:48:46 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Win95 / WinNT Question
Message-Id: <slrn80efuh.59d.bmccoy@moebius.foiservices.com>
Also Sprach Mike Salter <msalter@bestweb.net>:
>Actually, I looked at my Win95 machine last nite, in \perl\bin\ and found
>perldoc.bat. It is a combination DOS BAT file and perl script. A similar
>technique is described on page 12 of the Camel book for unix. Take a look
>at any BAT files in this directory, as I think this is what you're looking
>for.
They are built with the pl2bat.bat file, which batchfileizes your Perl
script so they can be run without explicitly starting the perl
interpreter.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Fri, 15 Oct 1999 16:45:07 GMT
From: rwentwor@advent.com
Subject: Re: Win95 / WinNT Question
Message-Id: <7u7lme$puo$1@nnrp1.deja.com>
I highly recommend you install 4DOS, available at
http://www.jpsoft.com/. It's a complete replacement for COMMAND.COM.
You can then add the following to your environment and have the proper
association:
set .pl=c:\perl\bin\perl.exe
You won't even need to include the extension when you type on the
command line unless there's a possibility of a conflich, e.g. you have
both test.exe and test.pl on the path.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 12 Oct 1999 19:49:57 GMT
From: py@ecst.csuchico.edu (Pythagoras Watson)
Subject: Re: working perl -pie workaround
Message-Id: <7u03d5$7lq$1@hubble.csuchico.edu>
According to David L. Nicol <david@kasey.umkc.edu>:
:Is there a reason
: perl -pie 's/oldstring/newstring/g' target-file
:cannot work as I expect it to?
The "e" in "-pie" is being taken as the backup extension by the "i" switch.
Then, since you do not have the "e" switch, then perl code is taken as a
filename to open. Try:
perl -pi -e 's/oldstring/newstring/g' target-file
--
Py (Amateur Radio: KF6WFP) -- 3.141592653589793238462643383...
Pythagoras Watson -- "Live long and may all your kernels pop."
=== py@csuchico.edu ==== http://www.ecst.csuchico.edu/~py/ ===
------------------------------
Date: Tue, 12 Oct 1999 21:18:03 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: working perl -pie workaround
Message-Id: <fANM3.485$IZ5.14208@news.rdc1.ct.home.com>
In comp.lang.perl.misc David L. Nicol <david@kasey.umkc.edu> wrote:
> Is there a reason
> perl -pie 's/oldstring/newstring/g' target-file
> cannot work as I expect it to?
It works exactly as you'd expect it to. The -i switch takes an
optional string to tack on the original file's filename so you've
got a backup. What you've done is told perl you want to back up
target-file to target-filee.
You can use the -e switch just fine with -i--you just need to
specify it separately. (-pi -e)
Dan
------------------------------
Date: Tue, 12 Oct 1999 13:30:35 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: working perl -pie workaround
Message-Id: <Pine.GSO.4.10.9910121311370.19155-100000@user2.teleport.com>
On Tue, 12 Oct 1999, David L. Nicol wrote:
> Can't use both inline editing switch (-i) and
> script-as-command-line-arg switch (-e) at the same time.
Sure you can. But any switch which can take an argument must not be
followed by another switch that looks like its argument.
That is, it's no problem to combine some switches like -c -w -l and -p to
make -cwlp. Even though -l takes an argument, the argument must be an
octal number, so perl recognizes that -p must be a separate option.
But -ie is the -i switch with the argument 'e', asking perl to do in-place
editing with that extension for backup. Meanwhile, -ei is the -e switch
with the argument 'i', asking perl to execute that string as code.
Since the extensions used for backup generally start with a dot or a
tilde, it would not be inconceivable for a future version of perl to
require the extension to begin with a non-alphabetic character, thus
making -pie useful (but dangerous, since no backup file would be created).
Be sure to submit the patch when you have it ready. :-)
> is this a problem which is going to be repaired in Perl 6?
Who can say? No one even knows whether there will ever _be_ a Perl 6. I
certainly won't be surprised if there is never such a thing. [*]
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
* Okay, I'm making a joke here. If there's no Perl 6, that's probably
because some combination of Y2K, global warming, biowarfare, or Britney
Spears has caused the end of the world and no one is left to continue Perl
development. In that case, none of us will even be here to be surprised,
right? :-)
------------------------------
Date: Wed, 13 Oct 1999 00:47:31 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: working perl -pie workaround
Message-Id: <FJInJ7.JGn@news.boeing.com>
In article <38037FFB.720D6C30@kasey.umkc.edu>,
David L. Nicol <david@kasey.umkc.edu> wrote:
>
>
> ...
>A working workaround appears as the sig of this message,
>but is this a problem which is going to be repaired in
>Perl 6?
>
>Is there a reason
>
>perl -pie 's/oldstring/newstring/g' target-file
>
Reasons have already been noted, but just for the sake
of another silly workaround:
perl -pi" "e 's/foo/bar/g' target-file
(costs an extra keystroke though)
--
Charles DeRykus
------------------------------
Date: 13 Oct 1999 02:47:41 GMT
From: ken@halcyon.com (Ken Pizzini)
Subject: Re: working perl -pie workaround
Message-Id: <slrn807smm.4qq.ken@pulsar.halcyon.com>
On Wed, 13 Oct 1999 00:47:31 GMT,
Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>Reasons have already been noted, but just for the sake
>of another silly workaround:
>
>perl -pi" "e 's/foo/bar/g' target-file
>
>(costs an extra keystroke though)
Also doesn't work --- it asks perl to use <space><e> as the
backup suffix, and 's/foo/bar/g' as the name of the script file.
If it _did_ work, then you could have avoided the extra
keystroke with:
perl -pi\ e 's/foo/bar/g' target-file
--Ken Pizzini
------------------------------
Date: 13 Oct 1999 04:50:33 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: working perl -pie workaround
Message-Id: <7u132p$in$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Charles DeRykus
<ced@bcstec.ca.boeing.com>],
who wrote in article <FJInJ7.JGn@news.boeing.com>:
> Reasons have already been noted, but just for the sake
> of another silly workaround:
>
> perl -pi" "e 's/foo/bar/g' target-file
>
> (costs an extra keystroke though)
Wow! What are you abusing here, workaround against silly #!-processors?
I would say that this is a bug. It should use $^I = " e".
Ilya
------------------------------
Date: Wed, 13 Oct 1999 19:59:13 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: working perl -pie workaround
Message-Id: <FJK4up.Ju@news.boeing.com>
In article <slrn807smm.4qq.ken@pulsar.halcyon.com>,
Ken Pizzini <ken@halcyon.com> wrote:
>On Wed, 13 Oct 1999 00:47:31 GMT,
>Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>>Reasons have already been noted, but just for the sake
>>of another silly workaround:
>>
>>perl -pi" "e 's/foo/bar/g' target-file
>>
>>(costs an extra keystroke though)
>
>Also doesn't work --- it asks perl to use <space><e> as the
>backup suffix, and 's/foo/bar/g' as the name of the script file.
>
>If it _did_ work, then you could have avoided the extra
>keystroke with:
> perl -pi\ e 's/foo/bar/g' target-file
I suspected the idea was a dayDWIM (after posting of course) and
looked for a no-name file.
Now, interestingly, there appear to be shell/OS differences.
Or, I'm still confused.
--
Charles DeRykus
ksh/Solaris 2.6, perl 5.005_03 built for sun4-solaris-thread:
(same for AIX 4.3, IRIX 6.5)
----------------------------
# mkdir test; cd test
# echo foobar >foo
# ls -abl
total 14
drwxr-x--- 2 root other 512 Oct 13 12:01 .
drwxr-xr-x 26 ced staff 4608 Oct 13 12:01 ..
-rw-r----- 1 root other 7 Oct 13 12:01 foo
# perl -pi\ e 's/foo/bar/' foo
# ls -abl
total 14
drwxr-x--- 2 root other 512 Oct 13 12:01 .
drwxr-xr-x 26 ced staff 4608 Oct 13 12:01 ..
-rw-r----- 1 root other 7 Oct 13 12:01 foo
# cat foo
barbar
ksh: HPUX-10/l1:
---------------
...
perl -pi\ e 's/foo/bar' foo
Can't open perl script "s/foo/bar": No such file or directory
--
Charles DeRykus
------------------------------
Date: Thu, 14 Oct 1999 02:48:11 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: working perl -pie workaround
Message-Id: <FJKnsB.H1v@news.boeing.com>
In article <FJK4up.Ju@news.boeing.com>,
Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>...
>perl -pi\ e 's/foo/bar' foo
>Can't open perl script "s/foo/bar": No such file or directory
^
/
Actually, modulo the typo, HP/UX 10/11 works the same
as Solaris 2.6, i.e., there's no backup whose name is
a space.
--
Charles DeRykus
------------------------------
Date: Thu, 14 Oct 1999 14:52:52 GMT
From: mike808@mo.net
Subject: Re: working perl -pie workaround
Message-Id: <7u4qnu$mnd$1@nnrp1.deja.com>
> In article <FJK4up.Ju@news.boeing.com>,
> Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
> >perl -pi\ e 's/foo/bar' foo
> >Can't open perl script "s/foo/bar": No such file or directory
Personally, I find the whole thing a pain trying to do something useful
like:
"desired" contents of tounx.pl
perl -p -i -e 's/\r$//g'
and
"desired" contents of perl todos.pl
perl -p -i -e 's/$/\r/'
Should be pretty straightforward stuff, right? Drag a file and drop it
on one of these and you should "convert" the file, right? Nope. Besides
the brain-dead CMD.EXE from Redmond with obscure, non-documented and
irrational quoting behavior, it seems to have problems with in-place
substitution, and results in clearing your file. Yuk. I hate having to
telnet to execute this stuff on the remote *nix box.
But I rant off-topic....
Mike.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 15 Oct 1999 16:56:18 GMT
From: howitgolook <howitgolook@my-deja.com>
Subject: Writing an IMAP Client
Message-Id: <7u7mba$qdt$1@nnrp1.deja.com>
Hi all,
I wish to write an IMAP (Webmail) client a-la-Hotmail, using Perl.
I will be communicating with a Cyrus IMAP server.
Is there anywhere I can get perl code to get me started?
What modules will I need?
Any advice for this sort of project?
TIA,
how.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 13 Oct 1999 07:33:36 -0500
From: "Kevin Lund" <kevin.lund@iname.com>
Subject: XML::Parser, Entities and Attributes
Message-Id: <38047c21@wwwproxy3.westgroup.com>
I'm having a frustrating little problem with XML::Parser. There are so many
references to 'entity', 'attribute' and 'XML' on Deja and the ActiveState
sites that I can't find anything relevant, so I thought I'd actually post to
the newsgroup.
Basically, I want to know if there is a way to get entity references within
attributes passed to my script. If I have this data:
<headnote ID="123" number="1" classifications="285&key;2(11)">
and then pass it through my script, I get this for output:
<headnote ID="123" number="1" classifications="2852(11)"/>
Hey! Where's my &key; ???
Here's my declaration of the parser:
my $parser = new XML::Parser( NoExpand => 1,
ErrorContext => 1,
Handlers => { Start => \&my_start_tag,
End => \&my_end_tag,
Default => \&my_default,
Doctype => \&my_doctype,
Comment => \&my_comment,
XMLDecl => \&my_xmldecl,
Char => \&my_cdata },
);
And the &key; is gone by the time the print in my_start_tag is hit:
sub my_start_tag {
my $this = shift;
my $tag = shift;
print "@_" if $tag eq 'headnote';
Is there a way around this that I just can't figure out?
Thanks!
Kevin
------------------------------
Date: Wed, 13 Oct 1999 18:50:46 GMT
From: Ken MacLeod <ken@bitsko.slc.ut.us>
Subject: Re: XML::Parser, Entities and Attributes
Message-Id: <m39057drzj.fsf@biff.bitsko.slc.ut.us>
"Kevin Lund" <kevin.lund@iname.com> writes:
> Basically, I want to know if there is a way to get entity references within
> attributes passed to my script. If I have this data:
>
> <headnote ID="123" number="1" classifications="285&key;2(11)">
>
> and then pass it through my script, I get this for output:
>
> <headnote ID="123" number="1" classifications="2852(11)"/>
>
> Hey! Where's my &key; ???
Are you looking for the entity to be replaced with it's value, or do
you want the unexpanded entity?
If you want the entity replaced with it's value, you need to make sure
that the entity `key' is defined, and that XML::Parser (expat) is
reading that definition. It will either be defined in the prolog of
your XML instance or in a DTD that it references. To get XML::Parser
to read an external DTD, you need to use the `ParseParamEnt' option.
If you want the unexpanded entity, I don't think XML::Parser or expat
provide that. I just tried using the Default handler and it doesn't
seem to generate an event for an entity within an attribute. Even if
it did, it'd be hard to figure out where that entity came from within
the attribute.
XML::ESISParser in libxml-perl uses the nsgmls parser, which does
provide entity references in attributes. Unfortunately, I haven't
decided yet the best way to handle them (as events) so it just passes
the nsgmls attribute string through. Entity references in attributes
are surrounded by `\|' strings (per <http://jclark.com/sp/sgmlsout.htm>).
XML::ESISParser is significantly slower than XML::Parser, if that's an
issue.
You should mention this on the perl-xml mailing list or to Clark
Cooper, the author of XML::Parser. Join the mailing list at
<http://www.activestate.com/support/mailing_lists.htm>.
--
Ken MacLeod
ken@bitsko.slc.ut.us
------------------------------
Date: Wed, 13 Oct 1999 16:02:51 -0500
From: "Kevin Lund" <kevin.lund@iname.com>
Subject: Re: XML::Parser, Entities and Attributes
Message-Id: <3804f37c@wwwproxy3.westgroup.com>
Ken MacLeod wrote in message ...
>"Kevin Lund" <kevin.lund@iname.com> writes:
>
>> Basically, I want to know if there is a way to get entity references
within
>> attributes passed to my script. If I have this data:
>>
>> <headnote ID="123" number="1" classifications="285&key;2(11)">
>>
>> and then pass it through my script, I get this for output:
>>
>> <headnote ID="123" number="1" classifications="2852(11)"/>
>>
>> Hey! Where's my &key; ???
>
>Are you looking for the entity to be replaced with it's value, or do
>you want the unexpanded entity?
The latter.
>If you want the unexpanded entity, I don't think XML::Parser or expat
>provide that. I just tried using the Default handler and it doesn't
>seem to generate an event for an entity within an attribute. Even if
>it did, it'd be hard to figure out where that entity came from within
>the attribute.
>
>XML::ESISParser in libxml-perl uses the nsgmls parser, which does
>provide entity references in attributes. Unfortunately, I haven't
>decided yet the best way to handle them (as events) so it just passes
>the nsgmls attribute string through. Entity references in attributes
>are surrounded by `\|' strings (per <http://jclark.com/sp/sgmlsout.htm>).
>
>XML::ESISParser is significantly slower than XML::Parser, if that's an
>issue.
Well, getting the entities is a much more important factor than speed.
XML::ESISParser sounds like a definite possibility. I have a few questions,
though:
* Can it tell the difference between an empty element and an element which
happens to be empty? Or, like XML::Parser, would "<a/>" and "<a></a>" be
treated identically?
* Looking at the doc on CPAN, it seems that in a start_element, the
attributes get passed in an array. Is there any way to reassemble the
attributes in the order they were in the input file?
* Is there a handler for comments?
In the meantime I'll try installing it and see if I can answer any of these
questions myself.
>You should mention this on the perl-xml mailing list or to Clark
>Cooper, the author of XML::Parser. Join the mailing list at
><http://www.activestate.com/support/mailing_lists.htm>.
I will do that.
Thanks for your help,
Kevin
------------------------------
Date: Thu, 14 Oct 1999 10:35:32 -0500
From: "Kevin Lund" <kevin.lund@iname.com>
Subject: Re: XML::Parser, Entities and Attributes
Message-Id: <3805f846@wwwproxy3.westgroup.com>
I whined:
>I'm having a frustrating little problem with XML::Parser. There are so many
>references to 'entity', 'attribute' and 'XML' on Deja and the ActiveState
>sites that I can't find anything relevant.
>
>Basically, I want to know if there is a way to get entity references within
>attributes passed to my script. If I have this data:
>
><headnote ID="123" number="1" classifications="285&key;2(11)">
>
>and then pass it through my script, I get this for output:
>
><headnote ID="123" number="1" classifications="2852(11)"/>
>
>Hey! Where's my &key; ???
Found it!
All you need is to have XML::Parser version 2.19 or later. There's this
funky little XML::Parser::Expat option called "original_string". Can anybody
guess what that returns? Here is a way to pass a tag from input to output
with all entities remaining as is:
sub my_start_tag {
my $this = shift;
my $string = $this->original_string;
print OUTFILE $string;
}
It also helps with another XML::Parser headache I had -- <a></a> and <a/>
being treated identically. original_string even allows me to fix that
problem.
Faithfully recorded for posterity,
Kevin
------------------------------
Date: 13 Oct 1999 00:16:54 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Y2K update for ctime.pl
Message-Id: <slrn8085dn.nk2.abigail@alexandra.delanet.com>
Matt King (mattking@techie.com) wrote on MMCCXXXIII September MCMXCIII in
<URL:news:7tvelq$ems$1@news.uk.ibm.com>:
'' Hi, I have seen several small items where people have either mentioned or
'' asked about Y2K issues with PERL scripts. This got me wondering if I might
'' be using a non-Y2K date script. After checking my scripts, I beleive that
'' I'm using a non-Y2K date script. The script is included in the Active Perl
'' installation in the lib dir called ctime.pl (line 46 ($year += 1900) . Is
'' there an update to this script somewhere that makes it Y2K? Or does someone
'' have a better solution as that this one is rather large. I'd like to solve
'' this before the real problems start. =)
I would first figure out what the problem really is, before making
problems out of thin air.
How about reading the documentation of localtime?
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
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 1084
**************************************