[22952] in Perl-Users-Digest
Perl-Users Digest, Issue: 5172 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 3 06:06:15 2003
Date: Thu, 3 Jul 2003 03:05:09 -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 Thu, 3 Jul 2003 Volume: 10 Number: 5172
Today's topics:
Re: "Word too long" ? And exactly WHAT word might that news@roaima.freeserve.co.uk
Re: Alternative to use vars <REMOVEsdnCAPS@comcast.net>
Re: Automatic page forwarding in cgi perl script <mbudash@sonic.net>
Re: Child signal behaviour on HPUX (Villy Kruse)
Re: doing 'ref' on blessed reference <ubl@schaffhausen.de>
Re: first.pl | second.pl with ARGV filehandle ? (Tad McClellan)
Re: funny printf behaviour in need of explanation (Dov Levenglick)
Re: Help with https and Paypal; <motiv8x{AT}top25web.com>
help with regular expressions (Jay)
How to put a filehandle into a hash array? (Vsevolod Afanassiev)
Re: How to put a filehandle into a hash array? <REMOVEsdnCAPS@comcast.net>
Re: Need help with Win32::GuiTest and Indigo perl <kalinabears@hdc.com.au>
Re: Need help with Win32::GuiTest and Indigo perl <awingnut@hotmail.com>
Re: Need help with Win32::GuiTest and Indigo perl <kalinabears@hdc.com.au>
Re: perl for Tru64 <BerndtJobst@noop.noop>
Re: Regular expressions (Peter Pentchev)
Re: script for unrestricted permutation (weberh)
Re: trying to parse XML from an email... news@roaima.freeserve.co.uk
Re: UTF16 and Control M's (Eileen)
Re: UTF16 and Control M's <flavell@mail.cern.ch>
what's these mean " =head1 SYNOPSIS" <heye@v2tech.com>
Re: what's these mean " =head1 SYNOPSIS" <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: what's these mean " =head1 SYNOPSIS" <simon.andrews@bbsrc.ac.uk>
Re: what's these mean " =head1 SYNOPSIS" <heye@v2tech.com>
Re: what's these mean " =head1 SYNOPSIS" <usenet@NOSPAM.matthewb.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 3 Jul 2003 10:40:07 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: "Word too long" ? And exactly WHAT word might that be? Curious
Message-Id: <n8adt-87b.ln1@moldev.cmagroup.co.uk>
Sara <genericax@hotmail.com> wrote:
> I have a script that runs fine, but on invocation in csh or bash or
> tcsh or ksh, the script reports:
> Word too long
> before a single line is executed
> What I mean is aside from the odd message, when I enter "c" at the
> DBG> prompt the script takes off and does just what it's supposed to
> do. So the only oddity is this message.
I can't reproduce this on Solaris 8 or GNU/Linux (bash, csh, ksh on
both platforms), variously with and without the execute bits set. What
OS platform are you running on?
However, my gut feeling is that this is a OS/shell issue. What I
suspect is happening is that your shell (csh, or whatever) is seeing the
#! line and trying to pass the file to the named interpreter (i.e. perl)
itself. At some point during this process the shell has read the entire
file and barfs on a line that it thinks is too long.
You can use perl itself to find and print long lines, on the basis that a
"long word" will probably be in a long line:
perl -ane 'print "$.\t$_" if length > 132' your_file.pl
It shouldn't be that much harder to find long words (I'll leave that to
you :-)
> The begining or the script is the usual fare:
> #!/usr/bin/perl -wd
This /is/ on the first line without any leading spaces, isn't it.
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: Thu, 03 Jul 2003 04:36:01 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Alternative to use vars
Message-Id: <Xns93AD38EEF9A1Dsdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
gbacon@hiwaay.net (Greg Bacon) wrote in news:vg5mmas61oi489
@corp.supernews.com:
> You can also declare the globals with our:
>
> our $scalar;
> our @array;
> our %hash;
>
> See the perlfunc documentation on our for details.
Maybe I'm dense.... I have yet to grasp the advantage of 'our' over 'use
vars'.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPwP472PeouIeTNHoEQIMhgCaA0q8GLANqUmBONt927YCbybDYpcAnjWA
lPjLquQFXdiUHQFscjdsle4i
=jZKd
-----END PGP SIGNATURE-----
------------------------------
Date: Thu, 03 Jul 2003 06:39:21 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Automatic page forwarding in cgi perl script
Message-Id: <mbudash-206D17.23392102072003@typhoon.sonic.net>
In article <3a9c1232.0307020544.c6c1635@posting.google.com>,
maximuszen@optonline.net (Max) wrote:
> "J黵gen Exner" <jurgenex@hotmail.com> wrote in message
> news:<NRqMa.68$C43.41@nwrddc04.gnilink.net>...
> > Max wrote:
> > > print ("Location:
> > > http://localhost/ElectronicMedicalRecord/OrderEntry/Orders.html\n\n");
> > >
> > > Why won't this work?
> >
> > Works just fine for me.
> > It prints the text
> > Location:
> > http://localhost/ElectronicMedicalRecord/OrderEntry/Orders.html
> >
> > to STDOUT. Did you expect it to do anything else?
> >
> > jue
>
> of course not... reading sometimes helps(like the subject line...) but
> i have to admit your wit is brillant. i wish i had it.
>
welcome to everyone's killfile...
--
Michael Budash
------------------------------
Date: 03 Jul 2003 07:41:50 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Child signal behaviour on HPUX
Message-Id: <slrnbg7nhu.2o4.vek@station02.ohout.pharmapartners.nl>
On 1 Jul 2003 05:38:57 -0700,
Jorge <jom_es@yahoo.es> wrote:
>All,
>
>I've got a process that creates some children and want to be alerted
>when they die. To do this, the SIGCHLD signal is registered in the
>process using sigaction to jump to a subprogram as soon as it's
>received.
>
On linux and unix there are only two posibilities, either a signal is
pending or not pending. You won't be able to tell how many times a signal
is posted while it is already pending. If you need to keep track of child
process you need to count the number of times the wait() returnes the
process id of a terminated child process.
Villy
------------------------------
Date: Thu, 03 Jul 2003 10:35:20 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: doing 'ref' on blessed reference
Message-Id: <be0t0f$s0m$1@news.dtag.de>
Abigail wrote:
> But this is convenient. Just consider everything part of the interface,
> and noone bothers about encapsulation anymore. Yeah. That will Java
> people get hooked on Perl.
That's what I was thinking about. Fortunately, we have AUTOLOAD methods
and Class::MethodMaker, so being lazy is no reason for not writing
accessor methods.
Public attributes was a bad idea that must have been invented before the
decorator pattern. Oh wait, it probably wasn't, which makes the idea
even worse.
malte
------------------------------
Date: Wed, 2 Jul 2003 23:14:42 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: first.pl | second.pl with ARGV filehandle ?
Message-Id: <slrnbg7bdi.299.tadmc@magna.augustmail.com>
stu7 <stuseven@hotmail.com> wrote:
> + perl first.pl | perl second.pl something, something ARGV fh ?
>
> This is what I've seen suggested... running the first
> perl script, piping it to the second perl script, and that
> the ARGV filehandle, or <> (?) will now automatically
> contain the file, or arguments from the first file for use in
> the second ?
A pipe connects the STDOUT from one program to the STDIN of
another program, there is nothing Perl-specific about that.
It will work regardless of what programming language it
was written in.
If first.pl print()s on STDOUT, and second.pl reads on STDIN
(perhaps using <>), then you've passed output from first to second.
> Sounds exciting... passing arguments between files... but how
> might it work ?
"arguments" and "output" are very different concepts.
Neither of the Perl programs above take any arguments at all.
> After trying for an hour or so, I didn't succeed at reading
> anything at all by printing <> from the second script...
We cannot troubleshoot code that we cannot see (hint).
> maybe,
> some module needs to be used here for this to work ?
No modules are needed. You don't even need Perl, any language will do.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 3 Jul 2003 01:16:07 -0700
From: stam_doar@hotmail.com (Dov Levenglick)
Subject: Re: funny printf behaviour in need of explanation
Message-Id: <8ebf3385.0307030016.6510e11f@posting.google.com>
> The DWIM (Do What I Mean) philosophy runs strong in perl, but that means
> using heuristics, which can sometimes produce surprising results. As
> mjd wrote, "Of course, this is a heuristic, which is a fancy way of
> saying that it doesn't work."
>
> Hope this helps,
> Greg
thanks a lot greg. i wasnt aware of the module that you used for
debugging, but you learn something new every day :)
------------------------------
Date: Wed, 02 Jul 2003 23:16:04 -0700
From: Joe Blower <motiv8x{AT}top25web.com>
Subject: Re: Help with https and Paypal;
Message-Id: <KNicnZXdq6y7V56iXTWJhg@comcast.com>
Boris wrote:
> I am trying to write a Perl subroutine to access Paypal's website, to
> checkout my shopping cart. When running on my PC, my PERL complains:
>
> Failed: Protocol scheme 'https' is not supported501 Protocol scheme
> 'https' is not supported
>
> When running on a Linux server, it doesn't seem to be using the https
> protocol and the Paypal shopping cart fails. Similar Javascript code
> works fine.
>
> Can anyone point out why PERL doesn't support https (according to
> Perldocs it does) or am I doing something else wrong?
>
> Here is my PERL code:
>
>
> sub callPaypal {
> my $self = shift;
> use URI;
> use LWP::UserAgent;
> use HTTP::Request::Common;
> my $ua = LWP::UserAgent->new;
> my $url = URI->new($self->{siteUrl});
> $url->query_form(
> cmd => $self->{cmd},
> add => $self->{add},
> display => $self->{display},
> business => $self->{business},
> quantity => $self->{quantity},
> item_name=> $self->{item},
> amount => $self->{amount},
> currency_code => $self->{currency},
> on0 => 'Op:',
> os0 => $self->{option1},
> on1 => 'Cust:',
> os1 => $self->{option2},
> image_url => $self->{image_url},
> return => $self->{return},
> cancel_return => $self->{cancel}
> );
>
> my $res = $ua->request(GET $url);
>
> #print "$url \n";;
> if ($res->is_success) {
> print $res->content;
> } else {
> print "Failed: ",$res->message,$res->status_line, " \n";
> }
>
> }
I struggled with https in perl for quite awhile, my task was to simply
login via https, and download a file. It may get you the basics of an
https query...
#!/usr/bin/perl -w
=head
Updated: 04/25/03
Notes: Logs in to a secure https server and
stores session ID in temporary cookie. Then grabs file
from the server, and saves it locally.
=cut
use strict;
use Data::Dumper;
use LWP::UserAgent;
#use HTTP::Request;
use HTTP::Cookies;
my $https_login = 'https://secureserver.com/login.cgi';
my $https_request = 'https://secureserver.com/';
my $https_file = 'dailyquotes.csv';
my $local_path = '/home/me/downloads';
my $https_user = 'user';
my $https_pass = 'pass';
&queryHTTPS();
sub queryHTTPS
{
#secure login
my $ua = LWP::UserAgent->new();
$ua->protocols_allowed( [ 'https'] );
$ua->cookie_jar(HTTP::Cookies->new(file => ".cookies.txt",
autosave => 1));
my $response = $ua->post($https_login, [ 'user' => "$https_user",
'password' => "$https_pass", 'switch' => 'Log In' ] );
#print Dumper($response);
if ($response->is_error()) {
printf " %s\n", $response->status_line;
print "https request error!\n";
} else {
my $content = $response->content();
#print "$content\n";
}
#get remote file
my $nav_url = $https_request . $https_file;
my $response2 = $ua->get($nav_url);
if ($response2->is_error()) {
printf " %s\n", $response2->status_line;
print "https request error!\n";
} else {
my $content = $response2->content();
#print "$content\n";
open(HTTPS_FILE, ">$local_path/$https_file") or die "couldn't open
$https_file: $!";
print HTTPS_FILE $content; #write daily nav file
close(HTTPS_FILE);
}
}
--
Motiv8x
Top25Web.com: Ranking Report & Search Engine Forums
http://www.top25web.com
------------------------------
Date: 3 Jul 2003 02:11:08 -0700
From: jranchordas@hotmail.com (Jay)
Subject: help with regular expressions
Message-Id: <15724ad0.0307030111.5642894c@posting.google.com>
Hello,
just getting grips with Perl and RE, but need your help.
I am trying to open a file, print its contents to a textbox, but
extract certain bits of information before outputing them to the
textbox. LAter I want to save the contents back to the same file with
the bits added back to the file. All this done without the user even
realising. The bits I want to take out (and put back) are always
located at the beginning and end of each file.
This is what I have come up with so far:
# places a specified file into the textarea to be edited
sub get_file
{
open(FILE, "< $selected_file") or die "Cannot open file\n";
while ()($thisrow = <FILE>))
{
$thisrow =~ s/\<\/textarea\>/\<\*textarea\>/;
if ($thisrow !~ m/<^TMPL_INCLUDE/)
# "<TMPL_INCLUDE" is the string to be removed
{
print $thisrow;
}
}
close FILE;
This obviously doesn't work and I was wondering if any of you guys
could shed some light to the darkness that I am experiencing.
Thanks so much!!
------------------------------
Date: 3 Jul 2003 00:59:59 -0700
From: vafanassiev@aapt.com.au (Vsevolod Afanassiev)
Subject: How to put a filehandle into a hash array?
Message-Id: <4f7d504c.0307022359.64f19424@posting.google.com>
I need to build an array of filehandles
so different records go into different output files
depending on a value. This is the code:
$dt = 20030701;
open ( "$FH{$dt}", ">output" . "." . $dt ) or die "$!";
print { "FH{$dt}" } "something ...\n";
close ( "$FH{$dt}" );
It works when run without "-w" but with "-w"
complains of use of uninitialized value.
What's the correct way of doing it?
Thanks
------------------------------
Date: Thu, 03 Jul 2003 04:50:36 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: How to put a filehandle into a hash array?
Message-Id: <Xns93AD3B67BF873sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
vafanassiev@aapt.com.au (Vsevolod Afanassiev) wrote in
news:4f7d504c.0307022359.64f19424@posting.google.com:
> I need to build an array of filehandles
> so different records go into different output files
> depending on a value. This is the code:
>
> $dt = 20030701;
>
> open ( "$FH{$dt}", ">output" . "." . $dt ) or die "$!";
>
> print { "FH{$dt}" } "something ...\n";
>
> close ( "$FH{$dt}" );
>
> It works when run without "-w" but with "-w"
> complains of use of uninitialized value.
> What's the correct way of doing it?
Why are you putting quotes around $FH{$dt} everywhere?
Lose the quotes and it should work.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPwP8WWPeouIeTNHoEQIXfQCgja/dLnvGJjnmeuEln0Yh3ekU3OgAoN9N
6RwEEc6oja0OwJnNLwO9B+AY
=6qa/
-----END PGP SIGNATURE-----
------------------------------
Date: Thu, 3 Jul 2003 14:02:13 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Need help with Win32::GuiTest and Indigo perl
Message-Id: <3f03ac04$0$22130@echo-01.iinet.net.au>
"gw1500se" <awingnut@hotmail.com> wrote in message
news:pe67gvccfu2h7k8c0k3g7nteed9m265i2q@4ax.com...
> On Thu, 3 Jul 2003 11:20:55 +1000, "Sisyphus" <kalinabears@hdc.com.au>
> wrote:
> >
> >The dll is being found ok but there's apparently some problem with that
dll
> >that prevents it from loading.
> >
> >You could also get the same error if GUITest.dll tried to load some other
> >"problem" dll. But I don't think GUITest.dll looks for any other dll.
> >
> >Could it be that you've installed a 5.6 version of Win32::GUITest on perl
> >5.8 (or vice-versa) ?
> >I'm not sure that would produce the error you get .... but it's all I can
> >think of :-)
> >
>
> Thats for the reply. Now the question becomes how do I tell? I'm
> running Indigo perl 5.8 and GuiTest 1.3. There is no mention, I can
> find, about compatability issues with different version of perl.
A dll built for perl 5.6 will not work on perl 5.8 and vice-versa.
I had a quick look at the website and couldn't find anything. I expect you
would have some documentation (somewhere in the download) about this.
ActiveState has separate repositories for perl 5.6 and perl 5.8 pre-compiled
packages. I imagine IndigoStar does the same. The webpage I went to
mentioned 'repositories' (plural). Perhaps your IPM is configured to access
the wrong repository.
'ipm help' should at least show you how to find out which repository has
been set ..... and hopefully you can find some documentation that will tell
you which repository *ought* to be set.
I can't think of any quick sure-fire method of determining whether you have,
in fact, installed a 5.6 package ...... but it's starting to sound more and
more likely :-)
We don't get many Indigo perl questions here. Does the website have a
mailing list for Indigo-specific matters ?
Cheers,
Rob
------------------------------
Date: Thu, 03 Jul 2003 00:31:01 -0400
From: gw1500se <awingnut@hotmail.com>
Subject: Re: Need help with Win32::GuiTest and Indigo perl
Message-Id: <9sb7gv8rtmkbse5fiv073cflu1vto0v5r7@4ax.com>
On Thu, 3 Jul 2003 14:02:13 +1000, "Sisyphus" <kalinabears@hdc.com.au>
wrote:
>
>A dll built for perl 5.6 will not work on perl 5.8 and vice-versa.
>
>I had a quick look at the website and couldn't find anything. I expect you
>would have some documentation (somewhere in the download) about this.
>ActiveState has separate repositories for perl 5.6 and perl 5.8 pre-compiled
>packages. I imagine IndigoStar does the same. The webpage I went to
>mentioned 'repositories' (plural). Perhaps your IPM is configured to access
>the wrong repository.
>'ipm help' should at least show you how to find out which repository has
>been set ..... and hopefully you can find some documentation that will tell
>you which repository *ought* to be set.
Thanks again for the reply. The repository is set for 5.8.
>
>I can't think of any quick sure-fire method of determining whether you have,
>in fact, installed a 5.6 package ...... but it's starting to sound more and
>more likely :-)
I have to agree but then it also could be wishful thinking. If it is
not then there is little hope of getting it to work and I don't what
to hit a deadend.
>
>We don't get many Indigo perl questions here. Does the website have a
>mailing list for Indigo-specific matters ?
>
Not that I can find but I have asked the Indigo support folks if they
know of a forum. I don't kniow how responsive they are. I also wrote
to the author of GuiTest but got no reply.
------------------------------
Date: Thu, 3 Jul 2003 15:05:52 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Need help with Win32::GuiTest and Indigo perl
Message-Id: <3f03baed$0$22122@echo-01.iinet.net.au>
"gw1500se" <awingnut@hotmail.com> wrote in message
>
> I have to agree but then it also could be wishful thinking. If it is
> not then there is little hope of getting it to work and I don't what
> to hit a deadend.
>
As a workaround solution go to:
http://ppm.activestate.com/PPMPackages/zips/8xx-builds-only/Windows/
and download Win32-GuiTest.zip.
Inside there's a 'Win32-GuiTest.tar.gz' that contains the files you want.
Just replace your existing '.pm' and '.dll' files with the ones it contains.
If you do this by extracting them, make sure you *don't* preserve the packed
directory structure or they'll end up in the wrong place. Might be best to
simply extract to a temp location then manually copy them across.
That will give you version 1.14. Hope that's satisfactory. Copy the other
files across, too, if you like .... though it shouldn't be necessary.
This should work at least as well as your current installation
:-)
Also see if you can install *any* modules that contain a dll and have them
work properly. It might help get to the source of your trouble.
Cheers,
Rob
------------------------------
Date: Thu, 03 Jul 2003 07:45:51 GMT
From: Berndt Jobst <BerndtJobst@noop.noop>
Subject: Re: perl for Tru64
Message-Id: <PaRMa.2168$ZT5.1224@news2.east.cox.net>
Peyton Bland wrote:
> Hi,
>
> Sorry if this is a lame question, but I'm having trouble finding a
> compiled perl for a Tru64 V5.x system. ...
>
> http://www.cpan.org/ports/ states:
> "Starting from Tru64 V5.0 Perl 5 ships standard with Tru64 as
> /usr/bin/perl, but the runtime support (modules and documentation) are
> in a separate optional subset. (As of Tru64 V5.0 5.004_04, but 5.005_03
> is on the supplementary freeware CD-ROM.) "
>
> I have the perl executable as stated above. But what is the best way
> to get the runtime support files?
>
> Thanks,
> Peyton Bland
Where have you looked? Talk to your sys admin.
Or look at the HP site for Tru64.
Or download and build your own.
then use CPAN module to install any module you'd like or
update the ones you have,
perl -MCPAN -e 'install (module::ineed)'
------------------------------
Date: 3 Jul 2003 00:32:40 -0700
From: roam@ringlet.net (Peter Pentchev)
Subject: Re: Regular expressions
Message-Id: <7d3fd083.0307022332.6f40b1b4@posting.google.com>
"mark" <mark_evans029@yahoo.com> wrote in message news:<F-SdnWyA54aWBmKjXTWJiw@www.bayou.com>...
> i am attempting to write a script using Net::Telnet. The script telnets to
> a machine
> logs in and issues a command to list the config. Tthe output of the command
> pauses
> about every screenfull and gives the user the prompt " --More-- ". The
> script
> contains the followin code to account fot the prompt.
>
> $telnet->waitfor('/-\-More\-\- $/i');
> $telnet->print('\s');
>
> the script does not proceed past the " --More-- " prompt. this problems
> seems to have stumpt me. does anyone have any suggestions for me?
There could be several problems here.
First, input buffering could pose a problem. The Net::Telnet documentation
explicitly states that all input is buffered; in my limited testing,
the waitfor() method does indeed return lines that do *not* end with an
end-of-line, but I am not sure that this will always be the case.
In other words, the problem could be Net::Telnet's waitfor() not returning
until a whole line has been read, and the --More-- prompt does not really
contain a CR/LF at the end.
Second, are you sure that the string you should be matching for is
the exact sequence of characters '-', '-', 'M', 'o', 'r', 'e', etc?
I mean, some pagers use the "backspace convention" (for lack of a better
name that I can think of right now) to indicate bold, underline and such:
for bold, the pager outputs 'M', backspace, 'M'; for underline, it prints
'_', backspace, 'M'. If the '--More-- ' prompt is bold for some reason,
then '--More-- ' will probably not match it.
Those are two reasons that I can think of offhand.
G'luck,
Peter
------------------------------
Date: 3 Jul 2003 02:16:48 -0700
From: weberh@zedat.fu-berlin.de (weberh)
Subject: Re: script for unrestricted permutation
Message-Id: <7003ec4a.0307030116.255fc352@posting.google.com>
Alright, but it is slow, no?
[Abacus3]~/perltest: time ./bdperm 10 a b c d > /dev/null
real 1m11.719s
user 1m11.583s
sys 0m0.053s
[Abacus3]~/perltest: time ./perm 10 a b c d > /dev/null
real 0m12.659s
user 0m12.600s
sys 0m0.029s
------------------------------
Date: Thu, 3 Jul 2003 10:47:12 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: trying to parse XML from an email...
Message-Id: <0madt-87b.ln1@moldev.cmagroup.co.uk>
rtl <rtl@trsolutions.net> wrote:
> I am retrieving an email with XML content. I strip off the email
> headings and save only the XML portion to a file. Subsequently I
> parse through the XML using XML::Simple.
> Most times the XML parses fine, but there are times when there is some
> extra encoding, such that all ='s (equal signs) are followed by '3D'.
> This seems to happen when certain characters such as TM or (R) or (c)
> are included in some of the data.
You need to handle the content encoding of the message correctly. Use an
email MIME parser (see MIME::Tools and its MIME::Parser) to deconstruct
the message and them pump the decoded XML into your XML parser.
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: 2 Jul 2003 22:09:48 -0700
From: ellona@u.washington.edu (Eileen)
Subject: Re: UTF16 and Control M's
Message-Id: <c630f334.0307022109.15ab32b@posting.google.com>
Sorry, I left out the first part of the script.there's the full
script:
#!/usr/local/bin/perl -w
use utf8;
$file = "kono.xml";
open (IN, $file) or die "cannot open $file\n";
while (<IN>) {
$_ =~ s/\cM$//gm;
print $_, "\n\n" if (/dublin/);
}
-------------
I didn't realize you could specify the encoding of a file in Perl.
that sounds like the first thing to try.
the \x{0x0D00} was identified by one of my Unicode editors,and was a
stab in the dark on my part :)
thanks much for the help!
"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message news:<Pine.LNX.4.53.0307022215570.19732@lxplus014.cern.ch>...
> On Wed, Jul 2, Eileen inscribed on the eternal scroll:
>
> > I have a text file with CTRL-M's. It is encoded as UTF16.
>
> Then you will need to tell Perl about that. You _are_ using
> at least Perl 5.8.0, yes? Take a look at perldoc perluniintro on your
> hard disk or at http://www.perldoc.com/perl5.8.0/pod/perluniintro.html
> and follow a few relevant links.
>
> Note that UTF-16 comes in two flavours, so don't omit to mention
> whether it's LE or BE.
>
> > When I try
> > to search for a string in this file, nothing is found.
>
> You've got to read the file first...
>
> > If I remove the
> > control-m's in vi, my search works. However, I cannot get the
> > control-m's to be removed using Perl. I've tried:
> >
> > my $file= "myfile.xml";
> > while (<IN>) {
>
> There's something important missing there ;-}
>
> Anyhow, be sure to tell Perl what it's supposed to be reading, or else
> it'll default to whatever it thinks the local I/O convention is (maybe
> iso-8859-1), which isn't likely to be useful.
>
> [...]
>
> > s/\x{0x0D00}//g;
>
> That's some weird Unicode character... well, actually no, it seems
> 0D00 and 0D01 are unassigned, the first assigned character in that
> group is 0D02 MALAYALAM SIGN ANUSVARA
>
> Anyway, joking apart, it looks as if you already know that your
> external data is utf-16LE, just that you omitted to say so...
>
> You've got to either read that stuff in the natural Perl 5.8 way, i.e
> with the right encoding layer, and then process the characters _as
> Unicode_; or you've got to read it in as binary and handle it as pairs
> of bytes. I don't recommend the latter approach, at least not with a
> current version of Perl.
>
> You seem to be stuck somewhere in the middle, trying to do partly one
> and partly the other, and that's not going to work.
>
> > Does anyone have any ideas on what to do?
>
> With Perl 5.8, as I say, I reckon your best bet is to open the file
> using ':encoding(utf-16LE)' and then you'll be set to handle the
> characters naturally in Perl. Assuming you want the results in
> utf-16LE again, don't omit to say so on the output filehandle too.
>
> > If I convert the file to
> > UTF8, the substitution and subsequent searches work. However, I have
> > several hundred files to deal with, and they are all encoded as UTF16.
>
> No need to "convert the file", Perl will deal with this for you.
>
> But I would recommend taking a moment to understand a little better
> how Perl's Unicode support is designed to work, and its relationship
> with external coding schemes. Each step is basically straightforward,
> but there's a semi-infinite number of ways of getting things wrong,
> and only a relatively small number of ways of doing it right, so it
> repays a bit of study. The Perl documentation isn't perfect yet, but
> it's at least as clear as I'd be able to explain it, usually better.
------------------------------
Date: Thu, 3 Jul 2003 11:27:23 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: UTF16 and Control M's
Message-Id: <Pine.LNX.4.53.0307031126160.16393@lxplus100.cern.ch>
On Wed, Jul 2, Michael P. Broida staggered uncertainly out onto Usenet
atop a fullquote:
> The Ctrl-M is a "carriage-return" which is \r in Perl.
Beware of Usenauts bearing TOFU.
------------------------------
Date: Thu, 3 Jul 2003 16:06:03 +0800
From: "Bob Heye" <heye@v2tech.com>
Subject: what's these mean " =head1 SYNOPSIS"
Message-Id: <be0o3p$hsi$1@mail.cn99.com>
Hi,All
In some perl script there are some sections like this:
//////////////////////////////////////////
=head1 NAME
...
=head1 SYNOPSIS
...
=item -b
...
=back
...
=head1 AUTHOR
...
=cut
#perl script here
//////////////////////////////////////////
The perl srcipt is put after the "=cut" line;
I want to know what the lines above it means.
Is there any documents for this?
I try to find one, but failed.
Regards,
BobH
------------------------------
Date: Thu, 3 Jul 2003 08:17:41 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: what's these mean " =head1 SYNOPSIS"
Message-Id: <Xns93AD684C2F84Eelhber1lidotechnet@62.89.127.66>
Bob Heye wrote:
> Hi,All
>
> In some perl script there are some sections like this:
>
> //////////////////////////////////////////
> =head1 NAME
> ...
> =head1 SYNOPSIS
> ...
> =item -b
> ...
> =back
> ...
> =head1 AUTHOR
> ...
>
> =cut
>
> #perl script here
> //////////////////////////////////////////
>
> The perl srcipt is put after the "=cut" line;
> I want to know what the lines above it means.
> Is there any documents for this?
> I try to find one, but failed.
perldoc perlpod
--
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Thu, 03 Jul 2003 09:18:03 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: what's these mean " =head1 SYNOPSIS"
Message-Id: <3F03E6BB.4070203@bbsrc.ac.uk>
Bob Heye wrote:
> Hi,All
>
> In some perl script there are some sections like this:
>
> //////////////////////////////////////////
> =head1 NAME
These are the elements of POD (plain old documentation);
embedded documentation which you can intersperse with
your Perl code, and which you can read with the perldoc
program.
See "perldoc perlpod" for all the details.
HTH
Simon.
------------------------------
Date: Thu, 3 Jul 2003 16:33:11 +0800
From: "Bob Heye" <heye@v2tech.com>
Subject: Re: what's these mean " =head1 SYNOPSIS"
Message-Id: <be0pn5$jii$1@mail.cn99.com>
I get it.
perlpodspec is the right one.
"Bob Heye" <heye@v2tech.com> 写入消息新闻:be0o3p$hsi$1@mail.cn99.com...
> Hi,All
>
> In some perl script there are some sections like this:
>
> //////////////////////////////////////////
> =head1 NAME
> ...
> =head1 SYNOPSIS
> ...
> =item -b
> ...
> =back
> ...
> =head1 AUTHOR
> ...
>
> =cut
>
> #perl script here
> //////////////////////////////////////////
>
> The perl srcipt is put after the "=cut" line;
> I want to know what the lines above it means.
> Is there any documents for this?
> I try to find one, but failed.
>
> Regards,
> BobH
>
>
>
>
>
------------------------------
Date: Thu, 03 Jul 2003 09:41:58 +0100
From: "Matthew Browning" <usenet@NOSPAM.matthewb.org>
Subject: Re: what's these mean " =head1 SYNOPSIS"
Message-Id: <pan.2003.07.03.08.41.57.881006@NOSPAM.matthewb.org>
On Thu, 03 Jul 2003 16:06:03 +0800, Bob Heye wrote:
> The perl srcipt is put after the "=cut" line; I want to know what the
> lines above it means. Is there any documents for this?
> I try to find one, but failed.
>
It is the program's documentation formatted for output by perldoc (or
anything else that might be produced to read it).
Find out more here:
$ perldoc perlpod
Matthew Browning
------------------------------
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.
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 V10 Issue 5172
***************************************