[29335] in Perl-Users-Digest
Perl-Users Digest, Issue: 579 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 26 14:10:22 2007
Date: Tue, 26 Jun 2007 11:09:29 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 26 Jun 2007 Volume: 11 Number: 579
Today's topics:
Re: ...gulp...ummm... is Perl6 deceased ? <thepoet_nospam@arcor.de>
Re: ...gulp...ummm... is Perl6 deceased ? <bik.mido@tiscalinet.it>
Re: ...gulp...ummm... is Perl6 deceased ? <bik.mido@tiscalinet.it>
Re: ...gulp...ummm... is Perl6 deceased ? <bik.mido@tiscalinet.it>
Re: Assigning another filehandle to STDOUT, using binmo <a24061@ducksburg.com>
Re: Assigning another filehandle to STDOUT, using binmo <hjp-usenet2@hjp.at>
Converting Diff Output to XML? <debajit1@gmail.com>
Re: Converting Diff Output to XML? <bik.mido@tiscalinet.it>
Re: Converting Diff Output to XML? <debajit1@gmail.com>
Correct newlines for Perl programs in subversion? <a24061@ducksburg.com>
executing bash comands with pipe <fbc1007@gmail.com>
Re: executing bash comands with pipe <mritty@gmail.com>
Re: executing bash comands with pipe <dummy@example.com>
Re: executing bash comands with pipe <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 26 Jun 2007 09:47:12 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: ...gulp...ummm... is Perl6 deceased ?
Message-Id: <4680c480$0$23146$9b4e6d93@newsspool1.arcor-online.net>
stuseven@hotmail.com wrote:
> + Since sometime two or three years ago, when the
> big rage was discussing Perl6... I've been looking at the
> Perl6 websites... and my question relates to this.
>
> On the dev.perl.org site, where the column, "This week in Perl"
> appears... there are no new postings listed since 16 months ago...
> this to me is a somewhat familiar site on Sourceforge, where new
> programs frequently stop development after an initial release...
> but I wouldnt expect this of Perl.
>
> ... is it so... could perl development have stopped ? Or this a
> misperception... perhaps it is the dev.perl.org site which is
> defunct,
> and not perl6 ?
>
> Hey... I am all for it... but perl5 is fine with me :-)
Perl 6 is alive and prospering, it's really just the "This week..."
part that's lagging. If you want to get an overview about what's
going on, have a look at the perl6-language mailing list archive.
www.parrotcode.org and www.pugscode.org also show that the
implementation bits of Perl6 are well on the way.
pugs -e "['reP',' 6l',' si','ooC','l'].map:{ $_.split('').reverse }.say"
-Chris
------------------------------
Date: Tue, 26 Jun 2007 10:38:07 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: ...gulp...ummm... is Perl6 deceased ?
Message-Id: <22k183hrf9kmf8qshvln1fg9g36ol4t0t0@4ax.com>
On Tue, 26 Jun 2007 09:47:12 +0200, Christian Winter
<thepoet_nospam@arcor.de> wrote:
>Perl 6 is alive and prospering, it's really just the "This week..."
>part that's lagging. If you want to get an overview about what's
>going on, have a look at the perl6-language mailing list archive.
>www.parrotcode.org and www.pugscode.org also show that the
>implementation bits of Perl6 are well on the way.
And then there's also the <http://planetsix.perl.org/> aggregator,
which may be interesting to the OP.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Tue, 26 Jun 2007 10:40:51 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: ...gulp...ummm... is Perl6 deceased ?
Message-Id: <o6k183lhdu40lnedggo10ipaolkaehlikm@4ax.com>
On Mon, 25 Jun 2007 16:24:04 -0700, "stuseven@hotmail.com"
<stuseven@hotmail.com> wrote:
> On the dev.perl.org site, where the column, "This week in Perl"
>appears... there are no new postings listed since 16 months ago...
>this to me is a somewhat familiar site on Sourceforge, where new
>programs frequently stop development after an initial release...
>but I wouldnt expect this of Perl.
Oh, and I forgot... the summaries of p6* ml's - along with other
interesting material, are regularly posted to <http://use.perl.org/>.
Sorry for the double posting,
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Tue, 26 Jun 2007 10:36:03 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: ...gulp...ummm... is Perl6 deceased ?
Message-Id: <glj1835j6bi9os7mev34tm57elg5i2i1bq@4ax.com>
On Mon, 25 Jun 2007 16:24:04 -0700, "stuseven@hotmail.com"
<stuseven@hotmail.com> wrote:
> ... is it so... could perl development have stopped ? Or this a
>misperception... perhaps it is the dev.perl.org site which is
>defunct,
>and not perl6 ?
Well, first of all let me point out that questions like yours tend to
arise quite frequently, often in the form of actual rants... and yes:
Perl 6 development has been somewhat slow and even seemingly sleeping
for some time, but it is now more active than ever on multiple fronts;
especially after the additional momentum it gained out of Audrey's
pugs.
See e.g. <http://perlmonks.org/?node_id=614624> for a thorough and
thoughtful discussion about what's *perceived* to be wrong with Perl 6
and counter arguments, including some precious interventions by $Larry
(in disguise).
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Tue, 26 Jun 2007 11:32:08 +0100
From: Adam Funk <a24061@ducksburg.com>
Subject: Re: Assigning another filehandle to STDOUT, using binmode.
Message-Id: <8i67l4-dcl.ln1@news.ducksburg.com>
On 2007-06-25, Peter J. Holzer wrote:
> No. By default it assumes (on Unix) binary input. You are reading and
> writing a stream of bytes, not a stream of characters.
I think I get it. String literals and variables just contain strings
of bytes, and encoding is a consideration only for input and output
--- or is that only for output?
Now I'm surprised that the following dippy little tag-stripping
program, which is XML-unaware and has no settings whatever relating to
encoding, works.
#!/usr/bin/perl
use strict;
use warnings;
my ($file, $line, $i);
while (@ARGV) {
$file = shift(@ARGV);
open(F, "<", $file);
$i = 0;
while ($line = <F>) {
$i++;
chomp($line);
$line =~ s!<[^>]+>!*!g;
print($file . " > " . $line . "\n");
last if ($i > 11);
}
close(F);
}
When I run this over my UTF-8 XML files, I get correct-looking, mixed
Cyrillic and Roman output, with no warnings --- why?
------------------------------
Date: Tue, 26 Jun 2007 15:28:25 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Assigning another filehandle to STDOUT, using binmode.
Message-Id: <slrnf8253p.9rb.hjp-usenet2@zeno.hjp.at>
On 2007-06-26 10:32, Adam Funk <a24061@ducksburg.com> wrote:
> On 2007-06-25, Peter J. Holzer wrote:
>
>> No. By default it assumes (on Unix) binary input. You are reading and
>> writing a stream of bytes, not a stream of characters.
>
> I think I get it. String literals and variables just contain strings
> of bytes,
No. Perl strings do not consist of bytes. Since there is no official
name for the thingies a perl string is made of, I'll just call them
"thingies".
On the most abstract level, about the only thing we know about these
thingies is that they are numbered: You get the number of the first
thingy in a string with ord() and you can create a string containing
only a single thingy with a specific number with chr(). The numbers
range from 0 .. 2**32-1.
What these thingies *mean* depends on your program. They might be
characters, they might be bytes of a graphics file, they might be
indexes, ... Perl mostly doesn't care.
Perl has two ways of storing strings: If all the thingies have numbers
below 256, the string can be stored as one thingy per byte. If this is
not the case, the thingies are encoded in UTF-8. Theoretically you
shouldn't know or care how perl stores a string.
In reality, Perl does assign some meaning to the type of the string. If
a string is utf8-encoded, Perl assumes that the thingies are really
Unicode-Codepoints. so "\x{FC}" matches /\w/ if it happens to be an
utf8-encoded string, but doesn't if it's a byte-encoded string (I'm
ignoring locales for now). For this reason the utf8-encoded strings are
often called "character strings" and the byte-encoded strings are called
"byte strings".
Since files consist of bytes, you can always only read bytes from a file
and write bytes to it. So when you read a file and want to treat it as a
series of characters instead of bytes, you have to "decode" it, and when
you have a character string which you want to write to a file, you have
to "encode" it. You can do that with the subs from the "Encode" module
or with I/O layers, and Modules written to deal with specific file
formats (like XML) do that automatically.
> Now I'm surprised that the following dippy little tag-stripping
> program, which is XML-unaware and has no settings whatever relating to
> encoding, works.
>
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my ($file, $line, $i);
>
> while (@ARGV) {
> $file = shift(@ARGV);
> open(F, "<", $file);
> $i = 0;
> while ($line = <F>) {
> $i++;
> chomp($line);
> $line =~ s!<[^>]+>!*!g;
> print($file . " > " . $line . "\n");
> last if ($i > 11);
> }
> close(F);
> }
>
>
> When I run this over my UTF-8 XML files, I get correct-looking, mixed
> Cyrillic and Roman output, with no warnings --- why?
Because UTF-8 is designed in such a way that this should work :-).
Your program reads and writes the files as a series of bytes. If your
file contains a cyrillic character, for example "Б", it will read and
write two bytes (0xD0 0x91) instead. Since that happens both on input
and on output, it doesn't matter. If you treat the individual bytes of a
multibyte character as characters, then your program will break. For
example, if you want to insert a blank before each character and put a
$line =~ s!(.)| $1|g;
in your program it won't work because it converts the byte sequence
0xD0 0x91 into the byte sequence 0x20 0xD0 0x20 0x91, which is not a
proper UTF-8 sequence. You must properly decode your input and encode
your output if you want to do this (or deal with the encoding in your
code).
hp
--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | hjp@hjp.at |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"
------------------------------
Date: Tue, 26 Jun 2007 14:57:25 -0000
From: Debajit Adhikary <debajit1@gmail.com>
Subject: Converting Diff Output to XML?
Message-Id: <1182869845.890352.138230@n60g2000hse.googlegroups.com>
What would be the best way to convert the regular (unix) diff output
into XML?
Are there any diff "libraries" available?
------------------------------
Date: Tue, 26 Jun 2007 18:15:49 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Converting Diff Output to XML?
Message-Id: <6ne2831ptoc1o13r6utqcndklm0c3vfdsu@4ax.com>
On Tue, 26 Jun 2007 14:57:25 -0000, Debajit Adhikary
<debajit1@gmail.com> wrote:
>What would be the best way to convert the regular (unix) diff output
>into XML?
>Are there any diff "libraries" available?
Searching CPAN for diff returns tons of things most of which are
probably *not* what you're looking after since the term is
unfortunately so generic... But hopefully instead of parsing the
output of diff you may generate diff information yourself e.g. with
Text::Diff and then produce your XML from there, with the aid of and
XML dedicated module. It all really depends on *how* you want the diff
output to be in "converted in XML".
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Tue, 26 Jun 2007 18:00:06 -0000
From: Debajit Adhikary <debajit1@gmail.com>
Subject: Re: Converting Diff Output to XML?
Message-Id: <1182880806.548326.306870@q69g2000hsb.googlegroups.com>
On Jun 26, 12:15 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On Tue, 26 Jun 2007 14:57:25 -0000, Debajit Adhikary
>
> <debaj...@gmail.com> wrote:
> >What would be the best way to convert the regular (unix) diff output
> >into XML?
> >Are there any diff "libraries" available?
>
> Searching CPAN for diff returns tons of things most of which are
> probably *not* what you're looking after since the term is
> unfortunately so generic... But hopefully instead of parsing the
> output of diff you may generate diff information yourself e.g. with
> Text::Diff and then produce your XML from there, with the aid of and
> XML dedicated module. It all really depends on *how* you want the diff
> output to be in "converted in XML".
>
> Michele
The problem is, i'm dealing with very large files here, 75+MB - 1GB+,
and the only utility that seems to be able to compare these is bdiff
(I'm on the Solaris platform).
Can Text::Diff handle very large files?
I'll try it out still. Thanks!
------------------------------
Date: Tue, 26 Jun 2007 15:21:03 +0100
From: Adam Funk <a24061@ducksburg.com>
Subject: Correct newlines for Perl programs in subversion?
Message-Id: <fvj7l4-ksq.ln1@news.ducksburg.com>
What is the correct svn:eol-style property to use for Perl programs in
subversion? I've seen both LF and native in use.
(I use Linux and occasionally Mac OS X, so either of those should work
for me, but some of my colleagues use Windows.)
------------------------------
Date: Tue, 26 Jun 2007 08:03:13 -0700
From: Fred <fbc1007@gmail.com>
Subject: executing bash comands with pipe
Message-Id: <1182870193.420063.31570@k79g2000hse.googlegroups.com>
Hi everybody,
I am trying to convert some bash scripts to perl. How can I execute
the bash sequence below:
vxdmpadm listctlr all | grep GENESIS | awk '/ENABLE/ {print $1}' |
sort -t c -k 2,3n | tr "\n" " "
This command give me the following result:
root@fj50in># vxdmpadm listctlr all | grep GENESIS | awk '/ENABLE/
{print $1}' | sort -t c -k 2,3n | tr "\n" " "
c4 c5
The vxdmpadm command result:
root@fj50in># vxdmpadm listctlr all
CTLR-NAME ENCLR-TYPE STATE ENCLR-NAME
=====================================================
c0 Disk ENABLED Disk
c3 EMC_CLARiiON ENABLED EMC_CLARiiON0
c2 EMC_CLARiiON ENABLED EMC_CLARiiON0
c5 GENESIS ENABLED GENESIS0
c4 GENESIS ENABLED GENESIS0
I tried using chop, but the "awk" command part appears not working:
chop (my $status = `(((vxdmpadm listctlr all) | grep GENESIS) | awk
'{print $1}')`);
print "\n\nmake exit status:\n$status\n";
Results:
make exit status:
c5 GENESIS ENABLED GENESIS0
c4 GENESIS ENABLED GENESIS0
TIA,
Fred
------------------------------
Date: Tue, 26 Jun 2007 09:12:11 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: executing bash comands with pipe
Message-Id: <1182874331.740952.205860@w5g2000hsg.googlegroups.com>
On Jun 26, 11:03 am, Fred <fbc1...@gmail.com> wrote:
> I tried using chop, but the "awk" command part appears not working:
>
> chop (my $status = `(((vxdmpadm listctlr all) | grep GENESIS) | awk
> '{print $1}')`);
> print "\n\nmake exit status:\n$status\n";
$1 is a Perl variable. You don't want to use the $1 Perl variable.
You want to pass the literal string '$1' to the awk part of your
command. You need to backslash the $ so Perl knows you're saying the
string dollarsign-one, rather than the variable $1.
Paul Lalli
------------------------------
Date: Tue, 26 Jun 2007 16:22:34 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: executing bash comands with pipe
Message-Id: <e3bgi.11340$tB5.5110@edtnps90>
Fred wrote:
>
> I am trying to convert some bash scripts to perl. How can I execute
> the bash sequence below:
>
> vxdmpadm listctlr all | grep GENESIS | awk '/ENABLE/ {print $1}' |
> sort -t c -k 2,3n | tr "\n" " "
>
> This command give me the following result:
>
> root@fj50in># vxdmpadm listctlr all | grep GENESIS | awk '/ENABLE/
> {print $1}' | sort -t c -k 2,3n | tr "\n" " "
> c4 c5
>
> The vxdmpadm command result:
>
> root@fj50in># vxdmpadm listctlr all
> CTLR-NAME ENCLR-TYPE STATE ENCLR-NAME
> =====================================================
> c0 Disk ENABLED Disk
> c3 EMC_CLARiiON ENABLED EMC_CLARiiON0
> c2 EMC_CLARiiON ENABLED EMC_CLARiiON0
> c5 GENESIS ENABLED GENESIS0
> c4 GENESIS ENABLED GENESIS0
>
> I tried using chop, but the "awk" command part appears not working:
>
> chop (my $status = `(((vxdmpadm listctlr all) | grep GENESIS) | awk
> '{print $1}')`);
> print "\n\nmake exit status:\n$status\n";
>
> Results:
>
> make exit status:
> c5 GENESIS ENABLED GENESIS0
> c4 GENESIS ENABLED GENESIS0
open my $fh, '-|', 'vxdmpadm', 'listctlr', 'all'
or die "Cannot open pipe from 'vxdmpadm' $!";
my @data;
while ( <$fh> ) {
next unless /GENESIS/ and /ENABLE/;
push @data, [ /^(\D+(\d+))/ ];
}
close $fh or warn $! ? "Error closing 'vxdmpadm' pipe: $!"
: "Exit status $? from 'vxdmpadm'";
print join( ' ',
map $_->[ 0 ],
sort { $a->[ 1 ] <=> $b->[ 1 ] }
@data ),
"\n";
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Tue, 26 Jun 2007 18:19:14 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: executing bash comands with pipe
Message-Id: <4ve28318rj78uv0d99p98446v3no13s013@4ax.com>
On Tue, 26 Jun 2007 08:03:13 -0700, Fred <fbc1007@gmail.com> wrote:
>I tried using chop, but the "awk" command part appears not working:
>
>chop (my $status = `(((vxdmpadm listctlr all) | grep GENESIS) | awk
>'{print $1}')`);
>print "\n\nmake exit status:\n$status\n";
You would still be using the perl interpreter as a shell which is not
that useful. You should instead
open my $cmd, '-|', qw/vxdmpadm listctlr all/ or die "D'Oh!\n";
and then do stuff while (<$fh>). What stuff to do depends on the rest,
but I don't know hawk so I can't help you. As far as the grep is
concerned, it can be just as simple as a
next unless /GENESIS/;
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 579
**************************************