[30578] in Perl-Users-Digest
Perl-Users Digest, Issue: 1821 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 26 18:09:45 2008
Date: Tue, 26 Aug 2008 15:09:06 -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 Aug 2008 Volume: 11 Number: 1821
Today's topics:
Re: A variable within an Inline use statement xhoster@gmail.com
Re: A variable within an Inline use statement <ben@morrow.me.uk>
Re: A variable within an Inline use statement <joost@zeekat.nl>
Re: Can't remove directory <slick.users@gmail.com>
Re: Converting the text output to excel via perl. <1usa@llenroc.ude.invalid>
Re: Converting the text output to excel via perl. <cartercc@gmail.com>
Getting the names for >200 directories frankthechicken@gmail.com
Re: Getting the names for >200 directories frankthechicken@gmail.com
Internal limit on variable length? <dn.perl@gmail.com>
Re: Internal limit on variable length? <bill@ts1000.us>
Re: Internal limit on variable length? <jurgenex@hotmail.com>
Re: Internal limit on variable length? <willem@stack.nl>
Re: Internal limit on variable length? <jurgenex@hotmail.com>
Re: Internal limit on variable length? xhoster@gmail.com
Re: Internal limit on variable length? <news1234@free.fr>
Soap:lite with msdl file crash perl.exe v5.6.1 qa4ever@gmail.com
Re: Soap:lite with msdl file crash perl.exe v5.6.1 <smallpond@juno.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Aug 2008 16:18:14 GMT
From: xhoster@gmail.com
Subject: Re: A variable within an Inline use statement
Message-Id: <20080826121816.137$DL@newsreader.com>
Ben Morrow <ben@morrow.me.uk> wrote:
> Quoth Thomas <th@example.invalid>:
> > The following code works for me at the beginning of my own module which
> > uses Inline C 0.44:
> >
> > use Inline (C => 'DATA',
> > LIBS => 'foo.lib',
> > BUILD_NOISY => 1,
> > FORCE_BUILD => 1,
> > );
> >
> > However, this variant:
> >
> > my $lib_path = 'foo.lib';
> > use Inline (C => 'DATA',
> > LIBS => $lib_path,
> > BUILD_NOISY => 1,
> > FORCE_BUILD => 1,
> > );
> >
> > does not. It runs, but the string 'foo.lib' is not given as a library
> > to Inline's make process so that I end up with an error "unresolved
> > externals" when linking the DLL Inline creates as glue code. So a
> > literal string is fine in that particular context, a variable is not.
> > This is probably a basic language understanding problem of mine and has
> > less to do with the Inline module, but I can't figure this one out
> > alone.
>
> 'use' statements are executed at compile time, but assignments are not
> executed until runtime. This means that when the 'use Inline' line is
> executed, $lib_path doesn't yet have a value.
Why is this? Since Perl does compile time constant folding, why not do
compile time constant assignment as well? Is there a good reason not
to, or it just the way the cookie crumbles?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Tue, 26 Aug 2008 17:55:29 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: A variable within an Inline use statement
Message-Id: <15pdo5-n2p1.ln1@osiris.mauzo.dyndns.org>
Quoth xhoster@gmail.com:
> Ben Morrow <ben@morrow.me.uk> wrote:
[
my $lib_path = "foo";
use Inline ..., $lib_path, ...;
]
> >
> > 'use' statements are executed at compile time, but assignments are not
> > executed until runtime. This means that when the 'use Inline' line is
> > executed, $lib_path doesn't yet have a value.
>
> Why is this? Since Perl does compile time constant folding, why not do
> compile time constant assignment as well? Is there a good reason not
> to, or it just the way the cookie crumbles?
I don't know. One sort-of good reason is that the variable must be
reassigned-to every time the block is entered (in the general case)
anyway, so it would be awkward to make the first assignment happen
early.
I would really like a Perl6ish
my $x :BEGIN = "foo";
construct. I wonder how hard that would be? Data::Alias must already
have most of what you need (tracing the boundaries of a particular
assignment and executing it specially)...
Ben
--
"Faith has you at a disadvantage, Buffy."
"'Cause I'm not crazy, or 'cause I don't kill people?"
"Both, actually."
[ben@morrow.me.uk]
------------------------------
Date: Tue, 26 Aug 2008 20:05:06 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: A variable within an Inline use statement
Message-Id: <871w0b1wkt.fsf@zeekat.nl>
xhoster@gmail.com writes:
> Ben Morrow <ben@morrow.me.uk> wrote:
>> Quoth Thomas <th@example.invalid>:
>> > The following code works for me at the beginning of my own module which
>> > uses Inline C 0.44:
>> >
>> > use Inline (C => 'DATA',
>> > LIBS => 'foo.lib',
>> > BUILD_NOISY => 1,
>> > FORCE_BUILD => 1,
>> > );
>> >
>> > However, this variant:
>> >
>> > my $lib_path = 'foo.lib';
>> > use Inline (C => 'DATA',
>> > LIBS => $lib_path,
>> > BUILD_NOISY => 1,
>> > FORCE_BUILD => 1,
>> > );
>> >
>> > does not. It runs, but the string 'foo.lib' is not given as a library
>> > to Inline's make process so that I end up with an error "unresolved
>> > externals" when linking the DLL Inline creates as glue code. So a
>> > literal string is fine in that particular context, a variable is not.
>> > This is probably a basic language understanding problem of mine and has
>> > less to do with the Inline module, but I can't figure this one out
>> > alone.
>>
>> 'use' statements are executed at compile time, but assignments are not
>> executed until runtime. This means that when the 'use Inline' line is
>> executed, $lib_path doesn't yet have a value.
>
> Why is this? Since Perl does compile time constant folding, why not do
> compile time constant assignment as well? Is there a good reason not
> to, or it just the way the cookie crumbles?
Perl only does constant folding for actual constants. Which are never
variables. You can in fact make use of this at compile time:
#!/usr/bin/perl -w
use strict;
use constant PATH => "foo.lib" ;
use Inline (C => 'DATA',
LIBS => PATH,
BUILD_NOISY => 1,
FORCE_BUILD => 1,
);
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: Tue, 26 Aug 2008 14:57:36 -0700 (PDT)
From: Slickuser <slick.users@gmail.com>
Subject: Re: Can't remove directory
Message-Id: <037976f5-d798-48ba-80ba-c18bb8a35d6d@x16g2000prn.googlegroups.com>
Sorry, it was \\. I try all possible case with directory structure,
still doesn't work. Even with C:/folderA/..
Those folders do exist. I can delete it manually. It just ask me to
remove all files. I have to confirm ALL to remove it.
my $dir_del = "C:\\folderA\\ABC\\D\\E";
#$dir_del = 'C:\folderA\ABC\D\E';
$dir_del =~ s/\\/\//ig;
chmod($dir_del,0755);
rmtree($dir_del);
------------------------------
Date: Tue, 26 Aug 2008 11:04:02 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Converting the text output to excel via perl.
Message-Id: <Xns9B0647DE24841asu1cornelledu@127.0.0.1>
Ben Morrow <ben@morrow.me.uk> wrote in
news:orqco5-7i21.ln1@osiris.mauzo.dyndns.org:
>
> Quoth "A. Sinan Unur" <1usa@llenroc.ude.invalid>:
>> "John W. Krahn" <someone@example.com> wrote in news:4mLsk.116668
>> $nD.65207@pd7urf1no:
>>
>> > my $row = [ split ' ', $line ];
>>
>> Someone up-thread had mentioned tab-separated values. My editor did
>> not show any tabs, just multiple spaces. I split on \s+ to avoid any
>> problems just in case the OP's data contained a combination of tabs
>> and spaces.
>
> I think you need to go reread perldoc -f split, particularly the
> paragraph
>
> As a special case, specifying a PATTERN of space (' ') ...
>
>:)
Aaaaargh!
I forgot.
Thank you for catching that.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Tue, 26 Aug 2008 10:18:36 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: Re: Converting the text output to excel via perl.
Message-Id: <2679cd45-c949-437a-8add-9d966d83ae00@p10g2000prf.googlegroups.com>
On Aug 25, 3:10=A0am, Sana <scripts...@gmail.com> wrote:
> I have the following output =A0which I want to convert into excel...Any
> pointers how to achieve it via Spreadsheet::WriteExcel;
My job requires me to export big globs of data to Excel and similar
formats, 'big' being defined as 100 columns across and 7,000 rows
deep. I don't use any modules but do it natively. Here's how, assuming
that your data can be gotten at using @ar:
open OUTFILE, ">data.csv";
print OUTFILE "HEAD1,HEAD2,HEAD3,HEAD4,etc\n";
while (<DATA>)
{
print OUTFILE "$ar[0],$ar[1],$ar[2],$ar[3],etc.\n";
}
close OUTFILE;
This will put 'data.csv' in your working directory with an Excel-like
icon, and when you click on it, it opens up in Excel. Nice and easy.
CC
------------------------------
Date: Tue, 26 Aug 2008 06:15:03 -0700 (PDT)
From: frankthechicken@gmail.com
Subject: Getting the names for >200 directories
Message-Id: <5e1bd409-f592-48ee-9a13-159a6fa22868@s20g2000prd.googlegroups.com>
I am attempting to either put into an array, or just iterate through
all the names of the directories I have.
I can do this with:-
my @dir_names = grep -d "$path/$_", readdir DIR;
or
opendir(DIR, $path) or die "cant find $path: $!";
while (defined(my $file = readdir(DIR))) {
next if $file =~ /^\.\.?$/;
if (-d "$path$file"){
However there are > 200 directories, and there seems to be a hard
limit of 200 when I try to store or iterate through.
Is there any way round this, and why does it occur?
Many thanks
------------------------------
Date: Tue, 26 Aug 2008 06:57:36 -0700 (PDT)
From: frankthechicken@gmail.com
Subject: Re: Getting the names for >200 directories
Message-Id: <dbbb25f2-a572-4da7-b0af-00129bd75691@n38g2000prl.googlegroups.com>
OK, seems like its a problem elsewhere in the code as I did a quick
little test of both methods on their own, and they seem to work fine.
------------------------------
Date: Tue, 26 Aug 2008 04:10:56 -0700 (PDT)
From: "dn.perl@gmail.com" <dn.perl@gmail.com>
Subject: Internal limit on variable length?
Message-Id: <f596a88b-c1ae-4706-a95b-06644835c51d@z11g2000prl.googlegroups.com>
I am feeling somewhat uneasy posting my query because quite likely it
is some other bug which is causing my code to fail and it is only a
matter of time before I discover it; but I have already spent far too
much time debugging it. So I might as well try to cover some
unsuspected source of bug.
The crux of my code is:
my @in_arr ;
foreach my $in(1 .. 10) {
my $in1 = "aabb" ;
my $in2 = "a string longer than 256 chars, say 275 chars" ;
my $in_str = "$in1 \t $in2 " ;
push @in_arr, $in_str ;
}
while (my $out_str = pop @in_arr) {
my ($out1, $out2) = split /\t/ , $out_str ;
print "out1 is $out1, out2 is $out2 \n" ;
}
The script hangs within the while loop. Could it happen if the value
of $out2 exceeds 256 characters at some point(s) during the code-run?
------------------------------
Date: Tue, 26 Aug 2008 04:31:23 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Re: Internal limit on variable length?
Message-Id: <65de5294-b343-4115-9cda-6a21b23ed354@w24g2000prd.googlegroups.com>
On Aug 26, 7:10=A0am, "dn.p...@gmail.com" <dn.p...@gmail.com> wrote:
> I am feeling somewhat uneasy posting my query because quite likely it
> is some other bug which is causing my code to fail and it is only a
> matter of time before I discover it; but I have already spent far too
> much time debugging it. So I might as well try to cover some
> unsuspected source of bug.
>
> The crux of my code is:
>
> my @in_arr ;
> foreach my $in(1 .. 10) =A0{
> =A0 =A0 my $in1 =3D "aabb" ;
> =A0 =A0 my $in2 =3D "a string longer than 256 chars, say 275 chars" ;
> =A0 =A0 my =A0$in_str =3D "$in1 \t $in2 " ;
> =A0 =A0 push =A0@in_arr, $in_str ;}
>
> while (my $out_str =3D pop @in_arr) =A0{
> =A0 =A0 my ($out1, $out2) =3D split /\t/ , $out_str ;
> =A0 =A0 print "out1 is $out1, out2 is $out2 \n" ;
>
> }
>
> The script hangs within the while loop. Could it happen if the value
> of $out2 exceeds 256 characters at some point(s) during the code-run?
Its early, I havent had my 1st cup of coffee and I could be wrong, but
won't this always be positive and the while loop will never exit?
while (my $out_str =3D pop @in_arr)
Bill H
------------------------------
Date: Tue, 26 Aug 2008 11:35:29 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Internal limit on variable length?
Message-Id: <d6q7b49llabmmmnkhaqo50baitsmjijj40@4ax.com>
"dn.perl@gmail.com" <dn.perl@gmail.com> wrote:
>while (my $out_str = pop @in_arr) {
> my ($out1, $out2) = split /\t/ , $out_str ;
> print "out1 is $out1, out2 is $out2 \n" ;
>}
>
>The script hangs within the while loop. Could it happen if the value
>of $out2 exceeds 256 characters at some point(s) during the code-run?
There are certainly bugs in perl and and you can never completely rule
them out as the cause. But it is highly unlikely, in particular in your
case, because splitting long strings on tabs is such a standard
operation and so frequently used that most likely someone would have run
into this problem already in the past two decades.
jue
------------------------------
Date: Tue, 26 Aug 2008 11:55:35 +0000 (UTC)
From: Willem <willem@stack.nl>
Subject: Re: Internal limit on variable length?
Message-Id: <slrngb7rpn.c7q.willem@snail.stack.nl>
dn.perl@gmail.com wrote:
)
) I am feeling somewhat uneasy posting my query because quite likely it
) is some other bug which is causing my code to fail and it is only a
) matter of time before I discover it; but I have already spent far too
) much time debugging it. So I might as well try to cover some
) unsuspected source of bug.
)
) The crux of my code is:
)
) my @in_arr ;
) foreach my $in(1 .. 10) {
) my $in1 = "aabb" ;
) my $in2 = "a string longer than 256 chars, say 275 chars" ;
) my $in_str = "$in1 \t $in2 " ;
) push @in_arr, $in_str ;
) }
) while (my $out_str = pop @in_arr) {
) my ($out1, $out2) = split /\t/ , $out_str ;
) print "out1 is $out1, out2 is $out2 \n" ;
) }
)
) The script hangs within the while loop. Could it happen if the value
) of $out2 exceeds 256 characters at some point(s) during the code-run?
I copy/pasted the above code and it does not display any weird behaviour,
even if I change the strig $in2 to actually have more than 256 characters.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
------------------------------
Date: Tue, 26 Aug 2008 11:55:37 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Internal limit on variable length?
Message-Id: <emr7b41bhre0vjtq8gur0gu7hra27a5va2@4ax.com>
Bill H <bill@ts1000.us> wrote:
>Its early, I havent had my 1st cup of coffee and I could be wrong, but
>won't this always be positive and the while loop will never exit?
>
>while (my $out_str = pop @in_arr)
It shouldn't:
If there are no elements in the array, returns the undefined
value (although this may happen at other times as well).
undef should evaluate to false in boolean context.
jue
------------------------------
Date: 26 Aug 2008 16:05:26 GMT
From: xhoster@gmail.com
Subject: Re: Internal limit on variable length?
Message-Id: <20080826120528.388$i3@newsreader.com>
"dn.perl@gmail.com" <dn.perl@gmail.com> wrote:
> I am feeling somewhat uneasy posting my query because quite likely it
> is some other bug which is causing my code to fail and it is only a
> matter of time before I discover it; but I have already spent far too
> much time debugging it. So I might as well try to cover some
> unsuspected source of bug.
>
> The crux of my code is:
>
> my @in_arr ;
> foreach my $in(1 .. 10) {
> my $in1 = "aabb" ;
> my $in2 = "a string longer than 256 chars, say 275 chars" ;
my $in2 = "a string longer than 256 chars, say 275 chars" x 1000;
That is safely greater than 256 chars. And in my hands it doesn't
reproduce your problem.
> my $in_str = "$in1 \t $in2 " ;
> push @in_arr, $in_str ;
> }
> while (my $out_str = pop @in_arr) {
> my ($out1, $out2) = split /\t/ , $out_str ;
> print "out1 is $out1, out2 is $out2 \n" ;
> }
>
> The script hangs within the while loop.
Where in the while loop does it hang? Add a print statement as the first
thing in the loop. How many iterations does it do before hanging?
> Could it happen if the value
> of $out2 exceeds 256 characters at some point(s) during the code-run?
I don't see how that would matter. On linux, I'd "strace" or "ltrace" the
program and see what was the last thing it did before hanging.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Tue, 26 Aug 2008 20:39:14 +0200
From: nntpman68 <news1234@free.fr>
Subject: Re: Internal limit on variable length?
Message-Id: <48b44dd1$0$19715$426a34cc@news.free.fr>
Hi,
Could you just copy the exact code snippet that fails?
The problem might be in one of the lines, which you didn't show us.
apart from that I'd suggest like xhoster to use
print statements (and strace if the prints reveal nothing)
If the real code counts for example mnuch higher than 10 in your first
loop, then you could add a print statement of following kind
print "in=$in" if $in % 100; # print $in every 100th time.
bye
N
dn.perl@gmail.com wrote:
> I am feeling somewhat uneasy posting my query because quite likely it
> is some other bug which is causing my code to fail and it is only a
> matter of time before I discover it; but I have already spent far too
> much time debugging it. So I might as well try to cover some
> unsuspected source of bug.
>
> The crux of my code is:
>
> my @in_arr ;
> foreach my $in(1 .. 10) {
> my $in1 = "aabb" ;
> my $in2 = "a string longer than 256 chars, say 275 chars" ;
> my $in_str = "$in1 \t $in2 " ;
> push @in_arr, $in_str ;
> }
> while (my $out_str = pop @in_arr) {
> my ($out1, $out2) = split /\t/ , $out_str ;
> print "out1 is $out1, out2 is $out2 \n" ;
> }
>
> The script hangs within the while loop. Could it happen if the value
> of $out2 exceeds 256 characters at some point(s) during the code-run?
>
>
------------------------------
Date: Tue, 26 Aug 2008 08:06:31 -0700 (PDT)
From: qa4ever@gmail.com
Subject: Soap:lite with msdl file crash perl.exe v5.6.1
Message-Id: <feb8cba3-2f05-4463-a630-e7f9489d892e@v39g2000pro.googlegroups.com>
Dear Soap / Perl gurus!
I'm using Windows Server 2k3 SP1 and Perl v5.6.1
I see perl.exe crash before I see "connected" text, why?
The wsdl file describe the soap interface that is found at http://machinename:2222.
(The wsdl file is not found/hosted at the http address, does it need
to?, but instead is found on local disk)
#!perl -w
use SOAP::Lite +trace => qw(debug);
my $soap = SOAP::Lite
-> service('file://C:/Code/wsdl/webservice.x.y.1.1.wsdl')
-> proxy('http://machinename:2222');
<<<< crash in perl.exe
print ">connected";
Do I also need to update the C:/Code/wsdl/webservice.x.y.1.1.wsdl'
file in this section?:
<!-- Services -->
<wsdl:service name="11WebService">
<wsdl:port name="11Port" binding="tns:11Binding">
<soap:address location=""/>
</wsdl:port>
</wsdl:service>
Thank you for any hints that can shed som light on this.
QA4Ever
------------------------------
Date: Tue, 26 Aug 2008 13:09:39 -0400
From: smallpond <smallpond@juno.com>
Subject: Re: Soap:lite with msdl file crash perl.exe v5.6.1
Message-Id: <9d72f$48b438e0$7440@news.teranews.com>
qa4ever@gmail.com wrote:
> Dear Soap / Perl gurus!
>
> I'm using Windows Server 2k3 SP1 and Perl v5.6.1
>
> I see perl.exe crash before I see "connected" text, why?
>
> The wsdl file describe the soap interface that is found at http://machinename:2222.
> (The wsdl file is not found/hosted at the http address, does it need
> to?, but instead is found on local disk)
>
>
> #!perl -w
> use SOAP::Lite +trace => qw(debug);
>
> my $soap = SOAP::Lite
> -> service('file://C:/Code/wsdl/webservice.x.y.1.1.wsdl')
> -> proxy('http://machinename:2222');
> <<<< crash in perl.exe
> print ">connected";
>
>
You go through a proxy to get to your local hard drive?
--S
** Posted from http://www.teranews.com **
------------------------------
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 1821
***************************************