[23854] in Perl-Users-Digest
Perl-Users Digest, Issue: 6057 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 31 09:06:00 2004
Date: Sat, 31 Jan 2004 06:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 31 Jan 2004 Volume: 10 Number: 6057
Today's topics:
Re: Can someone tell me what is wrong with this? <gnari@simnet.is>
Re: how to check for ip address that falls inside a ran (Walter Roberson)
Re: how to check for ip address that falls inside a ran (Walter Roberson)
Re: how to check for ip address that falls inside a ran <noreply@gunnar.cc>
Re: how to loop over instances of a class <nospam@nospam.net>
Re: how to loop over instances of a class <nobull@mail.com>
interpreting script <spedwards@qwest.net>
Re: interpreting script (Walter Roberson)
More photos like this.. 23730edmailk@pozyxk.pl
Re: Net::FTP and "mput" issue...cannot change local cur <kalinaubears@iinet.net.au>
Re: Net::FTP and "mput" issue...cannot change local cur <usenet@morrow.me.uk>
perl and db-module (Sebastian Diedrich)
Re: perl and db-module <usenet@morrow.me.uk>
Perl For Amateur Computer Programmers <edgrsprj@ix.netcom.com>
Re: printing sub results in heredocs <bmb@ginger.libs.uga.edu>
Re: printing sub results in heredocs <noreply@gunnar.cc>
Regex exp again... need to match exactly two letters. <The Mission of @ Our Lady of Fatima>
Re: Regex exp again... need to match exactly two letter <tassilo.parseval@rwth-aachen.de>
Re: Regex exp again... need to match exactly two letter <gnari@simnet.is>
Re: Regex exp again... need to match exactly two letter <pinyaj@rpi.edu>
Re: Script to download LARGE files (Russell Glasser)
sending an excel attachment with MIME::Lite <pdconetwofour_numbers_@yahoo.co.uk>
Re: sending an excel attachment with MIME::Lite <usenet@morrow.me.uk>
Splitting a String into a List Using Seperator "*" (Christopher M. Lusardi)
Re: Splitting a String into a List Using Seperator "*" (Walter Roberson)
Re: Splitting a String into a List Using Seperator "*" (Walter Roberson)
Re: Splitting a String into a List Using Seperator "*" <syscjm@gwu.edu>
Re: unused lexicals <jill_krugman@yahoo.com>
Re: unused lexicals <matthew.garrish@sympatico.ca>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 31 Jan 2004 10:04:39 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Can someone tell me what is wrong with this?
Message-Id: <bvfupc$o1v$1@news.simnet.is>
"Big Swifty" <bigswifty00000@yahoo.com> wrote in message
news:Xns9480B1C26DD94kburdishoptonlinenet@167.206.3.3...
[snip conversation]
probably whe were not discussing the same thing.
it looked to me like you were building an array:
@documents=(
'1a ib 1c',
'2a 2b 2c',
'3a 3b 3c',
'4a 4b 4c'
);
when you wanted:
@documents=(
['1a','1b','1c'],
['2a','2b','2c'],
['3a','3b','3c'],
['4a','4b','4c']
);
gnari
------------------------------
Date: 31 Jan 2004 04:45:09 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: how to check for ip address that falls inside a range.
Message-Id: <bvfbsl$3g6$1@canopus.cc.umanitoba.ca>
In article <RCkSb.6281$ef.5373@twister01.bloor.is.net.cable.rogers.com>,
Kien Ha <kha@rogers.com> wrote:
:mike wrote:
:> i need to verify if an ip-address falls inside a range for example,
:use IO::Socket qw(inet_aton);
Looking at perldoc, it appears to me that should be Socket instead
of IO::Socket .
: my $packed_ip = inet_aton($_);
: if ( $packed_ip lt $lower or $packed_ip gt $upper ) {
I realized a potential flaw in my pack 'C4' version:
I was using network byte order and numeric comparisions, which
would fail on small-endian or machines with other unusual binary
storage orders. I see that your version avoids that by doing
string comparisons instead of numeric comparisons. Think I'll
go edit some of my code now... ;-)
--
We don't need no side effect-ing
We don't need no scope control
No global variables for execution
Hey! Did you leave those args alone? -- decvax!utzoo!utcsrgv!roderick
------------------------------
Date: 31 Jan 2004 05:06:05 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: how to check for ip address that falls inside a range.
Message-Id: <bvfd3t$41k$1@canopus.cc.umanitoba.ca>
In article <bvfbsl$3g6$1@canopus.cc.umanitoba.ca>,
Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> wrote:
|In article <RCkSb.6281$ef.5373@twister01.bloor.is.net.cable.rogers.com>,
|Kien Ha <kha@rogers.com> wrote:
|: my $packed_ip = inet_aton($_);
|: if ( $packed_ip lt $lower or $packed_ip gt $upper ) {
|I realized a potential flaw in my pack 'C4' version:
|I was using network byte order and numeric comparisions, which
|would fail on small-endian or machines with other unusual binary
|storage orders. I see that your version avoids that by doing
|string comparisons instead of numeric comparisons.
Ah, and I just found a theoretical flaw in the inet_aton version.
The documentation for inet_aton says that it returns an
opaque string, and that one should not assume that it is 32 bits
(e.g., because of IPv6.) Theoretically, then, the results of
inet_aton are not always going to be linear for lt / gt purposes,
even if the inputs are consistantly dotted quads.
--
Oh, yeah, an African swallow maybe, but not a European swallow.
That's my point.
------------------------------
Date: Sat, 31 Jan 2004 06:08:32 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how to check for ip address that falls inside a range.
Message-Id: <bvfdgl$rqqgc$1@ID-184292.news.uni-berlin.de>
Walter Roberson wrote:
> Ah, and I just found a theoretical flaw in the inet_aton version.
> The documentation for inet_aton says that it returns an opaque
> string, and that one should not assume that it is 32 bits (e.g.,
> because of IPv6.) Theoretically, then, the results of inet_aton are
> not always going to be linear for lt / gt purposes, even if the
> inputs are consistantly dotted quads.
So why not keep it simple, then?
http://groups.google.se/groups?selm=bvck8u%24kijvq%241%40ID-184292.news.uni-berlin.de
;-)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 31 Jan 2004 08:10:44 GMT
From: "Jeff Thies" <nospam@nospam.net>
Subject: Re: how to loop over instances of a class
Message-Id: <8qJSb.3758$jH6.2730@newsread1.news.atl.earthlink.net>
> There has got to be a built in way to loop over all instances of a class.
> But I can't find it.
Personally, I push a reference to it on an array. At least that's what I do
in javascript, in perl it seems to go in a hash. I would think this depends
on how you are using the object.
There may be better ways.
Jeff
>
> ie.
>
> foreach $y (MYCLASS::) {
> $y->mymethod();
> }
------------------------------
Date: 31 Jan 2004 09:59:16 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: how to loop over instances of a class
Message-Id: <u9smhwfngr.fsf@wcl-l.bham.ac.uk>
"Jeff Thies" <nospam@nospam.net> writes:
> > There has got to be a built in way to loop over all instances of a class.
> > But I can't find it.
>
> Personally, I push a reference to it on an array.
Yep, and don't forget to Scalar::Util::weaken() it.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 30 Jan 2004 21:56:44 -0700
From: "Shawn" <spedwards@qwest.net>
Subject: interpreting script
Message-Id: <lAGSb.88$hE1.62769@news.uswest.net>
Hi,
I'm having a hard time interpreting a portion of a perl script (below). I
think its looking for the file pattern then determining the age and removing
it if its over 30 days old. The line with >30 has kind of got me. Any help
would be greatly appreciated.
@down_file_list = `/bin/ls *.downloaded *.kl2_download | grep -v
"_ppsd.zip" 2> /dev/null`;
foreach $down_file (@down_file_list) {
chop($down_file); #remove newline
if (-M $down_file > 30 ) {
print "Removing file $down_file in $search_dir/$home_dir\n";
system("/bin/rm -f $down_file");
}
}
------------------------------
Date: 31 Jan 2004 05:01:15 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: interpreting script
Message-Id: <bvfcqr$3v6$1@canopus.cc.umanitoba.ca>
In article <lAGSb.88$hE1.62769@news.uswest.net>,
Shawn <spedwards@qwest.net> wrote:
:I'm having a hard time interpreting a portion of a perl script (below). I
:think its looking for the file pattern then determining the age and removing
:it if its over 30 days old. The line with >30 has kind of got me.
: if (-M $down_file > 30 ) {
-M is documented in perlop :
-M Script start time minus file modification time, in days.
So the check is for whether the file was modified more than 30 days
before the script started running.
--
"Mathematics? I speak it like a native." -- Spike Milligan
------------------------------
Date: Fri, 30 Jan 2004 23:50:06 +0000 (UTC)
From: 23730edmailk@pozyxk.pl
Subject: More photos like this..
Message-Id: <bveqje$av9$1@atlantis.news.tpi.pl>
I'm searching mor photos like that: http://vipersex.us/019.jpg .
------------------------------
Date: Sat, 31 Jan 2004 13:09:12 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Net::FTP and "mput" issue...cannot change local currently directory
Message-Id: <401b0f3a$0$1745$5a62ac22@freenews.iinet.net.au>
John Davis wrote:
> ---------------------
>
>
> #!/opt/perl/bin/perl -w
>
> use strict;
> use Net::FTP
use Cwd;
> my ($hostname, $username, $password, $directory, $ftp, @last);
> $hostname="dbmaster1";
> $username="ftp";
> $password="nothing";
> $directory="/incoming";
# It might not matter but I would have expected:
$directory = "incoming";
> my @filelist;
> my $file;
>
> chdir ("/tmp/dbinfo");
>
# Check that you're where you think you are:
print "Current directory is: ", getcwd(), "\n";
> opendir (DIR, "/tmp/dbinfo") || die "Can't open: $! \n";
> @filelist=readdir(DIR);
> closedir(DIR);
>
> $ftp=Net::FTP->new ($hostname);
> $ftp->login($username, $password);
> $ftp->cwd ($directory);
>
> foreach $file (@filelist) {
> next if ! ($file=~/db.out/) ;
#'.' has special significance in regex. I think you want:
next if ! ($file=~/db\.out/) ;
> $ftp->put("$file");
> }
> $ftp->quit;
Hth.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Sat, 31 Jan 2004 06:57:55 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Net::FTP and "mput" issue...cannot change local currently directory
Message-Id: <bvfjlj$1hg$1@wisteria.csv.warwick.ac.uk>
Sisyphus <kalinaubears@iinet.net.au> wrote:
> #'.' has special significance in regex. I think you want:
> next if ! ($file=~/db\.out/) ;
And *I* think you want
next if $file !~ /db\.out$/;
or
next unless $file =~ /db\.out$/;
Ben
--
We do not stop playing because we grow old;
we grow old because we stop playing.
ben@morrow.me.uk
------------------------------
Date: 31 Jan 2004 03:15:08 -0800
From: sebastian.diedrich@pixelfashion.net (Sebastian Diedrich)
Subject: perl and db-module
Message-Id: <d96e1717.0401310315.73347359@posting.google.com>
hi all,
i have some problems with perl and the berkeley-db-module. when i
start a perl-prog such as cyradm (cyrus-imap) or some other that uses
the berkeley-db; perl throws this error:
<---------------------------
Can't load '/usr/lib/perl5/site_perl/5.6.1/i586-linux/auto/Cyrus/IMAP/IMAP.so'
for module Cyrus::IMAP:
/usr/lib/perl5/site_perl/5.6.1/i586-linux/auto/Cyrus/IMAP/IMAP.so:
undefined symbol: db_version at
/usr/lib/perl5/5.6.1/i586-linux/DynaLoader.pm line 206.
at /usr/lib/perl5/site_perl/5.6.1/i586-linux/Cyrus/IMAP/Admin.pm line
44
Compilation failed in require at
/usr/lib/perl5/site_perl/5.6.1/i586-linux/Cyrus/IMAP/Admin.pm line 44.
BEGIN failed--compilation aborted at
/usr/lib/perl5/site_perl/5.6.1/i586-linux/Cyrus/IMAP/Admin.pm line 44.
Compilation failed in require at
/usr/lib/perl5/site_perl/5.6.1/i586-linux/Cyrus/IMAP/Shell.pm line 60.
BEGIN failed--compilation aborted at
/usr/lib/perl5/site_perl/5.6.1/i586-linux/Cyrus/IMAP/Shell.pm line 60.
Compilation failed in require.
BEGIN failed--compilation aborted.
---------------------------->
i' m on an suse 7.3 box with berkeley 3.1 and perl. 5.0.6.1 (revision
5.0 version 6 subversion 1). db_file is version is 1.807 (detected
with: perl -e 'use DB_File; print "DB_File ver $DB_File::VERSION\n"').
have anyone an idea how to solve this problem?
thanx in advance
cya
sebastian
------------------------------
Date: Sat, 31 Jan 2004 12:03:36 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: perl and db-module
Message-Id: <bvg5io$cvm$1@wisteria.csv.warwick.ac.uk>
sebastian.diedrich@pixelfashion.net (Sebastian Diedrich) wrote:
> i have some problems with perl and the berkeley-db-module. when i
> start a perl-prog such as cyradm (cyrus-imap) or some other that uses
> the berkeley-db; perl throws this error:
>
> <---------------------------
> Can't load '/usr/lib/perl5/site_perl/5.6.1/i586-linux/auto/Cyrus/IMAP/IMAP.so'
> for module Cyrus::IMAP:
> /usr/lib/perl5/site_perl/5.6.1/i586-linux/auto/Cyrus/IMAP/IMAP.so:
> undefined symbol: db_version at
<snip>
>
> i' m on an suse 7.3 box with berkeley 3.1 and perl. 5.0.6.1 (revision
> 5.0 version 6 subversion 1).
That's odd... perl -v does indeed say 'revision 5.0 version...'.
This is referred to as perl 5.6.1.
> db_file is version is 1.807 (detected
> with: perl -e 'use DB_File; print "DB_File ver $DB_File::VERSION\n"').
If you can load DB_File then that is not your problem. Try
reinstalling the Cyrus::IMAP module.
Ben
--
Razors pain you / Rivers are damp
Acids stain you / And drugs cause cramp. [Dorothy Parker]
Guns aren't lawful / Nooses give
Gas smells awful / You might as well live. ben@morrow.me.uk
------------------------------
Date: Sat, 31 Jan 2004 13:45:58 GMT
From: "edgrsprj" <edgrsprj@ix.netcom.com>
Subject: Perl For Amateur Computer Programmers
Message-Id: <qkOSb.4022$jH6.3447@newsread1.news.atl.earthlink.net>
As I stated in some recent posts, I have been looking for a programming
language which scientists and other people around the world who are not
professional computer programmers could use with the same ease as Basic.
I suspect that Perl might not be sufficiently reliable that people who are
developing computer programs for air traffic controllers would make it their
first choice. But for use within the international scientific community it
looks almost ideal because of its versatility, ease of use, and
availability. Unfortunately I have been encountering one major problem with
it. And that is with its documentation.
If you are trying to make the transition from some language such as Basic to
Perl it can be difficult because of the very large number of commands etc.
which are available in Perl, because of their many options, and because of
Perl's structure which I myself do not yet fully understand. So what I have
been doing while I have been learning how to use it during the past few
weeks is prepare a Web page which briefly outlines some of its basic
commands etc. People who can already write simple programs in other
languages can use those commands to almost immediately begin creating and
running simple Perl programs.
The URL for that Web page is:
Perl For Amateur Computer Programmers
http://www.freewebz.com/eq-forecasting/Perl.html
People who would like to see Perl used by more people around the world might
want to examine that Web page and post comments about it here or send them
to me by e-mail. I believe that all of the commands on that page will work
as is. But they should probably be checked for errors by someone other than
me.
Unless there is some good reason not to do this then early next week I will
probably begin letting people around the world know about that Web page.
And I am planning to gradually add additional commands information etc. to
that page.
If anyone would like to list the addresses for good introductory Perl
reference manuals that they might know about on the Internet then that would
be appreciated. I will take a look at them and perhaps add those references
to my own Web page. However, my Web page is intended to provide people with
a certain type of information. And it will probably remain active even if I
learn that there are already some excellent reference manuals available.
------------------------------
Date: Fri, 30 Jan 2004 21:43:21 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: printing sub results in heredocs
Message-Id: <Pine.A41.4.58.0401302130510.19682@ginger.libs.uga.edu>
On Fri, 30 Jan 2004, Brian McCauley wrote:
> Brad Baxter <bmb@ginger.libs.uga.edu> writes:
> > sub context {
> > print <<"--";
> > @_:\tgot @{[wantarray?"list":defined wantarray?"scalar":"null"]}
> > --
> > ''
> > }
> > $x = "${\ context 'Expect scalar?' }";
>
> > Expect scalar?: got list
>
> Actually the context you get after a \ operator is not an ordinary
> list context. It is a context unlike any other you'll ever see in
> Perl.
>
> However in the case simple case of scalar(\func()) &func is in a list
> context and then a reference to the last element is the list is
> returned.
#!/usr/bin/perl -l
use strict;
use warnings;
sub x { 1,2,3 }
print \x;
print scalar \x;
SCALAR(0xf896c)SCALAR(0xf8a50)SCALAR(0xf887c)
SCALAR(0xf887c)
Ouch.
Brad
------------------------------
Date: Sat, 31 Jan 2004 04:19:00 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: printing sub results in heredocs
Message-Id: <bvf71o$r5iad$1@ID-184292.news.uni-berlin.de>
Brad Baxter wrote:
> On Fri, 30 Jan 2004, Brian McCauley wrote:
>> Actually the context you get after a \ operator is not an
>> ordinary list context. It is a context unlike any other you'll
>> ever see in Perl.
>
> sub x { 1,2,3 }
>
> print \x;
> print scalar \x;
>
> SCALAR(0xf896c)SCALAR(0xf8a50)SCALAR(0xf887c)
> SCALAR(0xf887c)
You get the same result with this sub:
sub x { wantarray ? (1,2,3) : 'abc' }
So maybe you'd better give Brian right, after all. ;-)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 31 Jan 2004 16:03:35 +1000
From: "Merlin" <The Mission of @ Our Lady of Fatima>
Subject: Regex exp again... need to match exactly two letters.
Message-Id: <401b4538@dnews.tpgi.com.au>
($row[0] =~ /^[A-Z]{2}$/)
Shouldn't this match a line that has ONLY the country code on it, ie;
AU
US
Fred's AUSTRALIA
Bills US Postal Service. GA
and I only want it to return line 1 and 2. That is
AU
and
US
So it has to match a line that has ONLY two capital letters in it.
thanks
Robert
--
---
The Mission of Our Lady of Fatima.
http://www.the-mission-of-our-lady-of-fatima.org
"I come from Heaven. I am the Lady of The Rosary"
------------------------------
Date: 31 Jan 2004 09:25:32 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Regex exp again... need to match exactly two letters.
Message-Id: <bvfsac$rq9$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Merlin:
> ($row[0] =~ /^[A-Z]{2}$/)
>
> Shouldn't this match a line that has ONLY the country code on it, ie;
>
> AU
> US
> Fred's AUSTRALIA
> Bills US Postal Service. GA
>
> and I only want it to return line 1 and 2. That is
> AU
> and
> US
>
> So it has to match a line that has ONLY two capital letters in it.
And that's exactly what the pattern '^[A-Z]{2}$' does. Why do you think
it doesn't?
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sat, 31 Jan 2004 10:14:09 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Regex exp again... need to match exactly two letters.
Message-Id: <bvfvb6$o2n$1@news.simnet.is>
"Merlin" <The Mission of @ Our Lady of Fatima> wrote in message
news:401b4538@dnews.tpgi.com.au...
>
>
> ($row[0] =~ /^[A-Z]{2}$/)
>
> Shouldn't this match a line that has ONLY the country code on it, ie;
>
> AU
> US
> Fred's AUSTRALIA
> Bills US Postal Service. GA
>
> and I only want it to return line 1 and 2. That is
> AU
> and
> US
>
> So it has to match a line that has ONLY two capital letters in it.
yes. if it does not work you must examine what $row[0] contains
at the time of the match. maybe you are testing the wrong variable,
or maybe it contains extra stuff like spaces.
gnari
------------------------------
Date: Sat, 31 Jan 2004 06:09:39 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: Regex exp again... need to match exactly two letters.
Message-Id: <Pine.SGI.3.96.1040131060842.90402A-100000@vcmr-64.server.rpi.edu>
On Sat, 31 Jan 2004, it was written:
>($row[0] =~ /^[A-Z]{2}$/)
>
>Shouldn't this match a line that has ONLY the country code on it, ie;
No, it should match a STRING that has ONLY the country code on it, plus an
optional trailing newline.
If your string has multiple lines in it, you'll need to add the /m
modifier.
Now, what are you doing, and what's not working like you'd expect?
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: 30 Jan 2004 16:51:36 -0800
From: rglasser@apollowebworks.com (Russell Glasser)
Subject: Re: Script to download LARGE files
Message-Id: <198d54f9.0401301651.40e19d16@posting.google.com>
Ben Morrow <usenet@morrow.me.uk> wrote in message news:<bvc70n$oku$2@wisteria.csv.warwick.ac.uk>...
> rglasser@apollowebworks.com (Russell Glasser) wrote:
> > I'm have a script that downloads files from a web server. The user
> > goes through a web browser based "file explorer" type interface to
> > view which files are available, and then clicks on a file to download.
> >
> > In simplified form, the download script looks something like this:
> > (retyping the relevant section only, so don't be surprised if it fails
> > to compile)
> >
> > open OUTFILE, $filename or die;
> > print "Content-Dispsition: attachment; filename=\"$filename\"\n";
> > print "Content-type: download\n\n";
> > while (<OUTFILE>) {
> > print $_;
> > }
> > close OUTFILE;
> >
> > This actually works well enough in most cases, but recently we had a
> > client attempt to download a BIG file. Like, 300 megabytes or so.
> > The browser died without giving the file over, and the web error log
> > said "Out of memory!"
>
> Was this a binary file? What you have there will read the file into
> memory a line at a time, and write each line after it has been
> read. If the file is large and binary, there may be an extremely long
> line somewhere. There are two ways round this: the first is to read in
> chunks of a given byte length, rather than in lines:
>
> {
> local $/ = \4096;
> local $\; # just in case
> binmode STDOUT;
> binmode OUTFILE;
> print while <OUTFILE>;
> }
>
> The second is to use IO::SendFile if your system supports it: I'm not
> sure, it may only work on Linux. This is a much more efficient way of
> achieving the above.
>
> As a side note, you should give a proper content-type: if you know no
> better, then use application/octet-stream.
>
> Ben
That was exactly what I needed. Thanks!
------------------------------
Date: Sat, 31 Jan 2004 11:38:32 GMT
From: p cooper <pdconetwofour_numbers_@yahoo.co.uk>
Subject: sending an excel attachment with MIME::Lite
Message-Id: <YsMSb.2345$Hd7.22268081@news-text.cableinet.net>
Ive converted a pipe-delimited file to excel format with
Spreadsheet::WriteExcel;
I now want to email it using MIME::Lite
anyone help out with
$message ->Type & encoding
( and the other stuff if its not correct)
my $message = MIME::Lite->new(
From => 'xxxxx' ,
To => 'xxx' ,
Cc =>'xx',
Subject => 'The database file as an Excel format,
Type => 'application/excel',
Encoding => '8bit',
Data => "Database files"
);
my ($mime_type, $encoding) = ('application/xls', 'base64');
$message->attach (
Type => $mime_type ,
Encoding => $encoding ,
Path => '/tmp/file.xls' ,
Filename => 'file.xls'
);
------------------------------
Date: Sat, 31 Jan 2004 12:07:23 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: sending an excel attachment with MIME::Lite
Message-Id: <bvg5pr$cvm$2@wisteria.csv.warwick.ac.uk>
p cooper <pdconetwofour_numbers_@yahoo.co.uk> wrote:
> Ive converted a pipe-delimited file to excel format with
> Spreadsheet::WriteExcel;
>
> I now want to email it using MIME::Lite
>
> anyone help out with
> $message ->Type & encoding
> ( and the other stuff if its not correct)
>
>
> my $message = MIME::Lite->new(
> From => 'xxxxx' ,
> To => 'xxx' ,
> Cc =>'xx',
> Subject => 'The database file as an Excel format,
> Type => 'application/excel',
You don't want this here. Probably you don't want a type here at
all. If you do want one, you want multipart/mixed.
> my ($mime_type, $encoding) = ('application/xls', 'base64');
The list of MIME types is at
http://www.iana.org/assignments/media-types/index.html, and the
correct one for Excel is appliaction/vnd.ms-excel. The encoding should
be Base64.
Note that this is not a Perl question.
Ben
--
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else * ben@morrow.me.uk
------------------------------
Date: 30 Jan 2004 16:13:43 -0800
From: clusardi2k@aol.com (Christopher M. Lusardi)
Subject: Splitting a String into a List Using Seperator "*"
Message-Id: <d5cfdc47.0401301613.45257334@posting.google.com>
Hello,
How do I split a string using the library function "split" with an asterisk?
I have to tell split break the string when it sees "abc*". I.E.: If I give split
the string "abc def ghi jkl abc* message" I want to get back two parts.
I want "abc def ghi jkl" and "message".
Thank you,
Christopher Lusardi
------------------------------
Date: 31 Jan 2004 01:19:06 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Splitting a String into a List Using Seperator "*"
Message-Id: <bvevqa$rlg$1@canopus.cc.umanitoba.ca>
In article <d5cfdc47.0401301613.45257334@posting.google.com>,
Christopher M. Lusardi <clusardi2k@aol.com> wrote:
: How do I split a string using the library function "split" with an asterisk?
Escape it.
:I have to tell split break the string when it sees "abc*". I.E.: If I give split
:the string "abc def ghi jkl abc* message" I want to get back two parts.
:I want "abc def ghi jkl" and "message".
split /abc\*/, $string
--
Rump-Titty-Titty-Tum-TAH-Tee -- Fritz Lieber
------------------------------
Date: 31 Jan 2004 01:22:32 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Splitting a String into a List Using Seperator "*"
Message-Id: <bvf00o$rnu$1@canopus.cc.umanitoba.ca>
In article <bvevqa$rlg$1@canopus.cc.umanitoba.ca>,
Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> wrote:
|In article <d5cfdc47.0401301613.45257334@posting.google.com>,
|Christopher M. Lusardi <clusardi2k@aol.com> wrote:
|:I have to tell split break the string when it sees "abc*". I.E.: If I give split
|:the string "abc def ghi jkl abc* message" I want to get back two parts.
|:I want "abc def ghi jkl" and "message".
|split /abc\*/, $string
By the way, that split would result in
'abc def ghi jkl ' and ' message' -- notice the trailing and then
leading spaces!
Possibly what you want is
split /\s+abc\*\s+/, $string
but it depends on how you would want to handle
'abc def ghi jklabc* message' or 'abc def ghi jkl abc*message'
--
Aleph sub {Aleph sub null} little, Aleph sub {Aleph sub one} little,
Aleph sub {Aleph sub two} little infinities...
------------------------------
Date: Fri, 30 Jan 2004 20:34:54 -0500
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: Splitting a String into a List Using Seperator "*"
Message-Id: <401B063E.3050301@gwu.edu>
Walter Roberson wrote:
> In article <d5cfdc47.0401301613.45257334@posting.google.com>,
> Christopher M. Lusardi <clusardi2k@aol.com> wrote:
> : How do I split a string using the library function "split" with an asterisk?
>
> Escape it.
>
> :I have to tell split break the string when it sees "abc*". I.E.: If I give split
> :the string "abc def ghi jkl abc* message" I want to get back two parts.
> :I want "abc def ghi jkl" and "message".
>
> split /abc\*/, $string
split / abc\* /, $string, otherwise he gets extraneous spaces.
Chris Mattern
------------------------------
Date: Fri, 30 Jan 2004 23:05:39 +0000 (UTC)
From: J Krugman <jill_krugman@yahoo.com>
Subject: Re: unused lexicals
Message-Id: <bveo03$f98$1@reader2.panix.com>
In <Xns94806FAC09692dkwwashere@216.168.3.30> "David K. Wall" <dwall@fastmail.fm> writes:
>bill <no_spam@no_spam.com> wrote:
>> Is there a simple way to find the unused lexicals in Perl code?
>> By "unused lexicals" I mean lexicals that are mentioned only once
>> in their scope.
> use warnings;
I don't think this takes care of unused lexicals, as bill defines
them. At least, if I run the script
#!/usr/bin/perl -w
use warnings;
my $foo;
1;
I get no warning for the unused lexical $foo.
jill
------------------------------
Date: Sat, 31 Jan 2004 00:36:13 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: unused lexicals
Message-Id: <c9HSb.45030$mf4.1664315@news20.bellglobal.com>
"J Krugman" <jill_krugman@yahoo.com> wrote in message
news:bveo03$f98$1@reader2.panix.com...
> In <Xns94806FAC09692dkwwashere@216.168.3.30> "David K. Wall"
<dwall@fastmail.fm> writes:
>
> >bill <no_spam@no_spam.com> wrote:
>
> >> Is there a simple way to find the unused lexicals in Perl code?
> >> By "unused lexicals" I mean lexicals that are mentioned only once
> >> in their scope.
>
> > use warnings;
>
> I don't think this takes care of unused lexicals, as bill defines
> them. At least, if I run the script
>
> #!/usr/bin/perl -w
> use warnings;
> my $foo;
> 1;
>
> I get no warning for the unused lexical $foo.
>
One solution is to use B::Xref and parse the output to see whether a
variable is referenced only once:
Subroutine (main)
Package (lexical)
$foo i3
There are a number of limititations to this approach, but it's better than
nothing...
Matt
------------------------------
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 6057
***************************************