[29632] in Perl-Users-Digest
Perl-Users Digest, Issue: 876 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 23 03:09:36 2007
Date: Sun, 23 Sep 2007 00:09:04 -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 Sun, 23 Sep 2007 Volume: 11 Number: 876
Today's topics:
64-bit seek()/tell()? <eponymousalias@yahoo.com>
Re: 64-bit seek()/tell()? <joe@inwap.com>
Re: 64-bit seek()/tell()? xhoster@gmail.com
Re: 64-bit seek()/tell()? <eponymousalias@yahoo.com>
Re: List Variable becomes undefined inexplicably <joe@inwap.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 22 Sep 2007 19:36:14 -0700
From: Glenn <eponymousalias@yahoo.com>
Subject: 64-bit seek()/tell()?
Message-Id: <1190514974.540253.221210@22g2000hsm.googlegroups.com>
Is a 64-bit file offset supported in seek() and/or tell()?
I thought the "no limits" philosophy of Perl would mean
this is no problem on my 64-bit Linux platform. But my
program seems to be acting as though file offsets are
only processed as 32-bit values.
Given that I want the buffering of the <> operator, and
thus don't want to use sysseek(), what are my options?
------------------------------
Date: Sat, 22 Sep 2007 19:41:25 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: 64-bit seek()/tell()?
Message-Id: <ObmdneRBE4HAT2jbnZ2dnUVZ_uuqnZ2d@comcast.com>
Glenn wrote:
> Is a 64-bit file offset supported in seek() and/or tell()?
Yes, provide that your copy of perl was compiled with largefile support.
linux% perl -V | egrep 'Summary|largefiles='
Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
-Joe
------------------------------
Date: 23 Sep 2007 03:00:20 GMT
From: xhoster@gmail.com
Subject: Re: 64-bit seek()/tell()?
Message-Id: <20070922230023.733$Hg@newsreader.com>
Glenn <eponymousalias@yahoo.com> wrote:
> Is a 64-bit file offset supported in seek() and/or tell()?
On my system it is.
$ strace perl -le 'seek STDIN, 1<<63,0' |& tail -n 3
close(3) = 0
lseek(0, 9223372036854775808, SEEK_SET) = -1 ESPIPE (Illegal seek)
exit_group(0) = ?
> I thought the "no limits" philosophy of Perl would mean
> this is no problem on my 64-bit Linux platform. But my
> program seems to be acting as though file offsets are
> only processed as 32-bit values.
What specific observations is that based on? What compilation options
were used when you built Perl (perl -V)?
>
> Given that I want the buffering of the <> operator, and
> thus don't want to use sysseek(), what are my options?
On my system, seek and sysseek result in the same underlying system
call being issued. The difference is only in perl's internal
accounting, not the system's.
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: Sat, 22 Sep 2007 20:14:16 -0700
From: Glenn <eponymousalias@yahoo.com>
Subject: Re: 64-bit seek()/tell()?
Message-Id: <1190517256.040977.197910@19g2000hsx.googlegroups.com>
> > Is a 64-bit file offset supported in seek() and/or tell()?
>
> Yes, provide that your copy of perl was compiled with largefile support.
>
> linux% perl -V | egrep 'Summary|largefiles='
> Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
> useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
Thanks. I'm using a properly compiled copy, but you just gave me
the clue that caused me to figure out the silly bug in my own code.
------------------------------
Date: Sat, 22 Sep 2007 20:31:32 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: List Variable becomes undefined inexplicably
Message-Id: <zMidnYNdcPiBQ2jbnZ2dnUVZWhednZ2d@comcast.com>
mattbreedlove@yahoo.com wrote:
> The issue is that a global list variable that is built inside
> subroutine A, iterated over in a foreach loop in subroutine B, is then
> magically undefined after the foreach loop if the loop contains a
> command pipe with a while loop.
Here's an example that has more print() statements to show what's going on.
#!/usr/bin/perl
use strict; use warnings;
my @hosts = qw(alpha delta goofy);
print "Before: \@hosts = (@hosts)\n";
iterate_hosts();
print "After: \@hosts = (@hosts)\n";
sub iterate_hosts {
print " Start of iterate_hosts: \@hosts = (@hosts)\n";
foreach (@hosts) {
print " Top of loop: \$_ = '$_', \@hosts = (@hosts)\n";
$_ = "a line of text\n"; # Simulate while(<CMD>)
$_ = '__'; # Simulate EOF on CMD
print " Bottom of loop: \$_ = '$_', \@hosts = (@hosts)\n";
}
print " End of iterate_hosts: \@hosts = (@hosts)\n";
}
Output:
Before: @hosts = (alpha delta goofy)
Start of iterate_hosts: @hosts = (alpha delta goofy)
Top of loop: $_ = 'alpha', @hosts = (alpha delta goofy)
Bottom of loop: $_ = '__', @hosts = (__ delta goofy)
Top of loop: $_ = 'delta', @hosts = (__ delta goofy)
Bottom of loop: $_ = '__', @hosts = (__ __ goofy)
Top of loop: $_ = 'goofy', @hosts = (__ __ goofy)
Bottom of loop: $_ = '__', @hosts = (__ __ __)
End of iterate_hosts: @hosts = (__ __ __)
After: @hosts = (__ __ __)After: @hosts = ( )
As others have mentioned, using
foreach my $host (@hosts) {...}
or
while(my $line=<CMD>) {...}
or both will eliminate your problem.
-Joe
------------------------------
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 876
**************************************