[26227] in Perl-Users-Digest
Perl-Users Digest, Issue: 8412 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 13 14:05:32 2005
Date: Tue, 13 Sep 2005 11:05:05 -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, 13 Sep 2005 Volume: 10 Number: 8412
Today's topics:
File::Copy works, File::NCopy doesn't <ataru@nospam.cyberspace.org>
How to stop DBM/Perl crashing servers? <speediercoREMOVE_THIS@yahoo.com>
Re: How to stop DBM/Perl crashing servers? xhoster@gmail.com
Re: IPC::Shareable Problem with multidimentional hash xhoster@gmail.com
making a meal out of hashing <zen72261@NOSPAMzen.co.uk>
Problem with Win32::OLE MicrosoftWord and Printout <pharrendorf@am-soft.de>
qx and awk for array <everythingelse@bobotheclown.org>
Simple question for you's...... <unmailable@duetospam.com>
Re: Simple question for you's...... <josef.moellers@fujitsu-siemens.com>
Re: Simple question for you's...... (Anno Siegel)
Re: Simple question for you's...... <unmailable@duetospam.com>
Re: Simple question for you's...... <nobull@mail.com>
XML-Parser to XML-Parser communication (encoding issues <arnevt@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 13 Sep 2005 13:56:14 +0000 (UTC)
From: Christopher Benson-Manica <ataru@nospam.cyberspace.org>
Subject: File::Copy works, File::NCopy doesn't
Message-Id: <dg6lpu$oh$1@chessie.cirr.com>
I have a situation where I invoke File::Copy and File::NCopy with
identical arguments - I am attempting to copy a file from one network
path to another, something like
copy( "\\\\$somepath\\foo\\bar.txt", "\\\\$someotherpath\\foo\\bar.txt" );
File::Copy works fine, but File::NCopy says "No such file or
directory". Can NCopy's copy not handle network paths? (This is
ActiveState Perl 5.8.7 for WinXP).
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
------------------------------
Date: Tue, 13 Sep 2005 12:40:37 -0400
From: "OttawaTrade" <speediercoREMOVE_THIS@yahoo.com>
Subject: How to stop DBM/Perl crashing servers?
Message-Id: <a66dnSS3PuWXnLreRVn-pA@rogers.com>
Why a DBM made by Perl can crash a server? It is reported by many people an
unprivileged perl script can load the memory and crash the server. How do I
fix this, since many working on the project can not fix. I hope I can find
more perl experts here.
http://www.absolutefreebies.com/phpBB2/viewtopic.php?t=7960371
Does anyone know why turning on Cache will cause the crash every too often?
Yep - the process of causing the crash is pretty well understood. The cache
uses a 'technology' called DBM within Perl, which uses a single file as a
database. The DBM 'technology' uses a rather basic file locking mechanism
which is susceptible to corruption when multiple instances of the script try
writing to the DB at the same time.
http://www.absolutefreebies.com/phpBB2/viewtopic.php?t=7959851&highlight=cache
------------------------------
Date: 13 Sep 2005 17:38:10 GMT
From: xhoster@gmail.com
Subject: Re: How to stop DBM/Perl crashing servers?
Message-Id: <20050913133810.808$h6@newsreader.com>
"OttawaTrade" <speediercoREMOVE_THIS@yahoo.com> wrote:
> Why a DBM made by Perl can crash a server?
A search for "DBM" on search.cpan.org yields 374 hits. Perhaps you could
be so kind as to tell us exactly what DBM module you are talking about.
There are thousands of different kinds of servers. Please tell us what
server you are talking about.
> It is reported by many people
> an unprivileged perl script can load the memory and crash the server. How
> do I fix this, since many working on the project can not fix. I hope I
> can find more perl experts here.
>
> http://www.absolutefreebies.com/phpBB2/viewtopic.php?t=7960371
>
> Does anyone know why turning on Cache will cause the crash every too
> often?
A search on "Cache" in search.cpan.org yields 2228 hits. What precisely
are you talking about?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 13 Sep 2005 16:05:09 GMT
From: xhoster@gmail.com
Subject: Re: IPC::Shareable Problem with multidimentional hash
Message-Id: <20050913120509.770$ac@newsreader.com>
Sébastien_Cottalorda <scottalordaNOSPAM@libello.com> wrote:
> I need to share datas for some cooperatives programs.
> I'm developping a car park access control based on internet reservation.
> My customers reserves their car park, and then comes and see me.
> In the share memory, I need to share all informations concerning the
> customers reservations, but i need too to share the equipments status,
> the real time counters (how free are all of my car parks , ect ...) ect
> ... I plan to use the shared memory because the access is faster than on
> a flat file (I think).
You should almost certainly use a database (like MySQL, for example).
> Certains API screens (the main one in fact) contain the real time
> counters and last equipments errors => I need to display them very fast.
>
> That's why I plan to use shared memory.
Using a database will be easier, less buggy, and will most likely be
faster, too, because of the finer granularity of the semaphores.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 13 Sep 2005 15:14:04 +0100
From: "Mark D Smith" <zen72261@NOSPAMzen.co.uk>
Subject: making a meal out of hashing
Message-Id: <4326dedd$0$24315$db0fefd9@news.zen.co.uk>
Hi
I have to pass some data to an API as a hash. ok i know the data sent is ok
but i cannot seem to decode the reply
$menuitems
{
'oranges' => {},
}
my $result = $shop->stockstatus( $menuitems );
response is a hash in this format (or that's what the API readme says.
$menuitems
{
'oranges' =>
{
'result' => 'NOT AVAILABLE',
'message' => 'Out of Season'
}
}
How do i access 'result' or 'message', and is there an easy way for
debugging to print the hash.
Mark
------------------------------
Date: Tue, 13 Sep 2005 07:07:41 -0400
From: "Pit" <pharrendorf@am-soft.de>
Subject: Problem with Win32::OLE MicrosoftWord and Printout
Message-Id: <61c927fc8eb22b33e93a095e2a41af2d@localhost.talkaboutprogramming.com>
Hi Folks,
I'm using Win32::OLE Micrsoft Word and the ActiveDocument->PrintOut-method
to print a textfile generated by a perlscript. the textfile contains
utf8-characters.
How can i set the codepage for MS-Word to 'Windows' (standard) using
Win32::OLE ??
Thanks Pit
------------------------------
Date: Tue, 13 Sep 2005 15:21:05 GMT
From: Rocky Allen <everythingelse@bobotheclown.org>
Subject: qx and awk for array
Message-Id: <pan.2005.09.13.15.22.36.36939@bobotheclown.org>
Hi Y'all,
Having trouble with this command when placed in a perl script:
cat /tmp/filesontape | awk '{print $9}'
on the command line output is as follows:
/etc/LGTOuscsi/sjirdtag
/etc/LGTOuscsi/sjirelem
/etc/LGTOuscsi/sjirjc
output from script is as follows:
-rwxr-xr-x 1 root root 550592 Feb 12 2002 /etc/LGTOuscsi/sjirdtag
-rwxr-xr-x 1 root root 550816 Feb 12 2002 /etc/LGTOuscsi/sjirelem
-rwxr-xr-x 1 root root 550544 Feb 12 2002 /etc/LGTOuscsi/sjirjc
I read perldoc perlop for qx and it claims that it honors pipes, and
wildcards etc. any thoughts?
here is the script:
#!/usr/bin/perl
my $cpioin = '/tmp/cpioin';
my $putontape = '/tmp/filesontape';
open(FH3, "$cpioin") or die "cant get FH3 $cpioin:$!";
my @pretape = <FH3>;
close FH3;
my @posttape = qx/cat $putontape | awk '{print $9}'/;
print "@posttape";
Thanks in advance,
Rocky
------------------------------
Date: Tue, 13 Sep 2005 15:18:07 +0100
From: "Slow Learner" <unmailable@duetospam.com>
Subject: Simple question for you's......
Message-Id: <dg6n3b$mo2$1$8302bc10@news.demon.co.uk>
Hey gurus,
If, say, I have a URL (or any "path" type string come to think of it), how
can I truncate it if it's greater than a certain length? Note: I don't want
to use it as a path, I just want to truncate it from display purposes. For
example:
http://www.mysite.com/beta/content/english/misc/publications/papers/index.html
.... and I want to restrict it to no more than 50 characters, but I want the
result to look something like this:
.../english/misc/publications/papers/index.html
In other words, I want the left-most part of a path string replaced with
".../" for those bits of the path that make it go over 50 characters.
How can I do this in Perl?
Thanks
------------------------------
Date: Tue, 13 Sep 2005 16:47:04 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Simple question for you's......
Message-Id: <dg6ogp$h41$1@nntp.fujitsu-siemens.com>
Slow Learner wrote:
> Hey gurus,
>=20
>=20
> If, say, I have a URL (or any "path" type string come to think of it), =
how=20
> can I truncate it if it's greater than a certain length? Note: I don't=
want=20
> to use it as a path, I just want to truncate it from display purposes. =
For=20
> example:
>=20
>=20
> http://www.mysite.com/beta/content/english/misc/publications/papers/ind=
ex.html
>=20
>=20
> .... and I want to restrict it to no more than 50 characters, but I wan=
t the=20
> result to look something like this:
>=20
>=20
> .../english/misc/publications/papers/index.html
>=20
>=20
> In other words, I want the left-most part of a path string replaced wit=
h=20
> ".../" for those bits of the path that make it go over 50 characters.
>=20
>=20
>=20
> How can I do this in Perl?
The usual answer: What have you tried so far and where have you failed?
I'd try split and length, but then TMTOWTDI,
Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: 13 Sep 2005 15:08:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Simple question for you's......
Message-Id: <dg6q0n$54j$1@mamenchi.zrz.TU-Berlin.DE>
Slow Learner <unmailable@duetospam.com> wrote in comp.lang.perl.misc:
> Hey gurus,
>
>
> If, say, I have a URL (or any "path" type string come to think of it), how
> can I truncate it if it's greater than a certain length? Note: I don't want
> to use it as a path, I just want to truncate it from display purposes. For
> example:
>
>
> http://www.mysite.com/beta/content/english/misc/publications/papers/index.html
>
>
> .... and I want to restrict it to no more than 50 characters, but I want the
> result to look something like this:
>
>
> .../english/misc/publications/papers/index.html
>
>
> In other words, I want the left-most part of a path string replaced with
> ".../" for those bits of the path that make it go over 50 characters.
>
>
>
> How can I do this in Perl?
Lots of ways, for sure.
You can split it up in parts, then put them together again, watching
the length. Prepend three dots if anything is missing from the original:
my $str = 'http://www.mysite.com/beta/content/english/misc/' .
'publications/papers/index.html';
my $max = 50;
my ( $trunc, @parts) = reverse split m{/}, $str;
for ( @parts ) {
last if length( $trunc) + length >= $max - 4; # four dots and a slash
$trunc = "$_/$trunc";
}
$trunc = ".../$trunc" unless $trunc eq $str;
print "$trunc\n";
print length( $trunc), "\n";
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Tue, 13 Sep 2005 16:21:55 +0100
From: "Slow Learner" <unmailable@duetospam.com>
Subject: Re: Simple question for you's......
Message-Id: <dg6qr5$qnf$1$830fa17d@news.demon.co.uk>
As I'm not from a Perl background, I would probably try something like:
if ( length ( $display_url ) > 70 ) {
$display_name = '.../'.substr ($display_url, length (
$display_url ) - 70, 70 );
}
else
{
$display_name = $display_url;
}
This is my naive version - sorry I don't know Perl syntax all that well.
I'm currently modifying someone elses script to make this small change :/.
Anyway, the above kindof works (okay, given 70 chars instead of 50), but
with urls that happen to straddle the http:// on 70 characters, it looks
rather ugly, ie:
.../://www.mysite.com/bla/bla/bla
"Josef Moellers" <josef.moellers@fujitsu-siemens.com> wrote in message
news:dg6ogp$h41$1@nntp.fujitsu-siemens.com...
Slow Learner wrote:
> Hey gurus,
>
>
> If, say, I have a URL (or any "path" type string come to think of it), how
> can I truncate it if it's greater than a certain length? Note: I don't
> want to use it as a path, I just want to truncate it from display
> purposes. For example:
>
>
> http://www.mysite.com/beta/content/english/misc/publications/papers/index.html
>
>
> .... and I want to restrict it to no more than 50 characters, but I want
> the result to look something like this:
>
>
> .../english/misc/publications/papers/index.html
>
>
> In other words, I want the left-most part of a path string replaced with
> ".../" for those bits of the path that make it go over 50 characters.
>
>
>
> How can I do this in Perl?
The usual answer: What have you tried so far and where have you failed?
I'd try split and length, but then TMTOWTDI,
Josef
--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Tue, 13 Sep 2005 17:42:36 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Simple question for you's......
Message-Id: <dg6vhs$ng$1@redhat2.bham.ac.uk>
Slow Learner wrote:
> Subject: Simple question for you's......
Please put the subject of your post in the Subject of your post.
> http://www.mysite.com/beta/content/english/misc/publications/papers/index.html
>
> .... and I want to restrict it to no more than 50 characters, but I want the
> result to look something like this:
>
> .../english/misc/publications/papers/index.html
> In other words, I want the left-most part of a path string replaced with
> ".../" for those bits of the path that make it go over 50 characters.
s/.+?(?=\/.{0,46}$)/.../ if length > 50;
Note: This will leave the string unchaged if there is no '/' in the last
47 characters of the string.
------------------------------
Date: Tue, 13 Sep 2005 14:53:29 +0200
From: arne <arnevt@gmail.com>
Subject: XML-Parser to XML-Parser communication (encoding issues?)
Message-Id: <pan.2005.09.13.12.53.27.588053@gmail.com>
Hi
I've written a XML-daemon to let third partie's communicate with our
backend.
The daemon itself is writte with XML::TreeBuilder (which uses on its turn
XML::Element && XML::Parser).
the daemon can handle multiple charsets, and everything works fine.
The problem came when I wrote a perl-client (until now I've used php),
that also users the above CPAN modules.
So the situation is now
client generates XML (UTF-8) and sends to the daemon the output of
->as_XML() (over a tcp socket), in this case:
<?xml version="1.0" encoding="UTF-8"?><smartyrequest><form type="echo-req" version="1"><text>héhé</text></form><auth><KID>K12345678</KID><username>admin</username><hash>b65b16a31dc80bdeadd50cde73c29993</hash></auth></smartyrequest>
(first differences, my php code doesn't expand the special chars, so it is
<text>héhél</text>)
the daemon accepts this, and takes the text in <text> with ->as_text(),
and puts it in another xml, sending it back to the client
this is what i get
<?xml version="1.0" encoding="UTF-8"?><smartyrequest><form type="echo-answer" version="1"><text>héhé</text></form></smartyrequest>
outputed as h\uffff\uffff\uffff©h\uffff\uffff\uffff© (instead of héhél)
in php this works fine.
So i suspect that XML::Parser can't handle the expanded character
references? or do I need to use an option (now I just use ->parse and
->parsefile).
thx in advance
Arne
------------------------------
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 V10 Issue 8412
***************************************