[29666] in Perl-Users-Digest
Perl-Users Digest, Issue: 910 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 5 18:09:44 2007
Date: Fri, 5 Oct 2007 15:09:07 -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 Fri, 5 Oct 2007 Volume: 11 Number: 910
Today's topics:
Re: Annoying 32/64-bit inconsistency xhoster@gmail.com
Re: Annoying 32/64-bit inconsistency <nospam-abuse@ilyaz.org>
error closing a file <lerameur@yahoo.com>
Re: error closing a file <lerameur@yahoo.com>
Re: FAQ 5.5 How can I copy a file? <rvtol+news@isolution.nl>
Re: How to manipulate the cases of letters in a string? <jgibson@mail.arc.nasa.gov>
Re: How to manipulate the cases of letters in a string? <zhang.xi.cn@gmail.com>
Re: How to manipulate the cases of letters in a string? <spamtrap@dot-app.org>
Re: jabba the tuh <news@lawshouse.org>
More math than perl... <bill@ts1000.us>
Re: More math than perl... <cwilbur@chromatico.net>
Re: More math than perl... <dummy@example.com>
Re: More math than perl... <jgibson@mail.arc.nasa.gov>
Re: More math than perl... <bill@ts1000.us>
newbie question: find index of substr using regexp <seannakasone@yahoo.com>
Re: newbie question: find index of substr using regexp <glex_no-spam@qwest-spam-no.invalid>
Re: newbie question: find index of substr using regexp <jgibson@mail.arc.nasa.gov>
Re: newbie question: find index of substr using regexp <seannakasone@yahoo.com>
Re: newbie question: find index of substr using regexp <seannakasone@yahoo.com>
Re: newbie question: find index of substr using regexp <jgibson@mail.arc.nasa.gov>
Re: newbie question: find index of substr using regexp <dummy@example.com>
passing $fd as a reference <dontmewithme@got.it>
Re: passing $fd as a reference <jgibson@mail.arc.nasa.gov>
Re: Reading a files's name <paduille.4061.mumia.w+nospam@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 05 Oct 2007 20:11:19 GMT
From: xhoster@gmail.com
Subject: Re: Annoying 32/64-bit inconsistency
Message-Id: <20071005161121.309$Yg@newsreader.com>
kj <socyl@987jk.com.invalid> wrote:
>
> Is there any way I can modify these build parameters for 64-bit to
> make perl handle the string containing the number ~0 + 1 in the
> same way it does under 32-bit?
No, I don't think there is. 32 bits integers can be "promoted" to
64 bit "double", which can represent integers up to something like 1<<51
without losing of precision. 64 bit integers can't be promoted to doubles
without loss of precision: they have no place to go.
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: Fri, 5 Oct 2007 21:18:42 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Annoying 32/64-bit inconsistency
Message-Id: <fe69ni$mik$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
kj
<socyl@987jk.com.invalid>], who wrote in article <fe5pe1$cuh$1@reader1.panix.com>:
> (NOTE: In the DB interactions below, I've rendered undef values as
> (undef), even though in the real interaction DB would just print
> a blank line. And, of course, the comments are my addition.)
To examine values under debugger, use `x' command.
> DB<6> p $x == ~0 # ditto
> (undef)
It is not.
> Is there any way I can modify these build parameters for 64-bit to
> make perl handle the string containing the number ~0 + 1 in the
> same way it does under 32-bit?
You want NV to have more bits than IV. Use `long double' for NV, if
your compiler allows this.
Hope this helps,
Ilya
------------------------------
Date: Fri, 05 Oct 2007 12:25:28 -0700
From: lerameur <lerameur@yahoo.com>
Subject: error closing a file
Message-Id: <1191612328.270858.302880@k79g2000hse.googlegroups.com>
HI,
I am getting this error while closing a file:
Use of uninitialized value in ref-to-glob cast at ./spam_working2.pl
line 170.
Can't close out_file Bad file number at ./spam_working2.pl line 170.
line 170: close $out_file or die "Can't close out_file $!";
why isn't it closing?
ken
------------------------------
Date: Fri, 05 Oct 2007 12:27:29 -0700
From: lerameur <lerameur@yahoo.com>
Subject: Re: error closing a file
Message-Id: <1191612449.017711.149390@19g2000hsx.googlegroups.com>
On Oct 5, 3:25 pm, lerameur <leram...@yahoo.com> wrote:
> HI,
>
> I am getting this error while closing a file:
>
> Use of uninitialized value in ref-to-glob cast at ./spam_working2.pl
> line 170.
> Can't close out_file Bad file number at ./spam_working2.pl line 170.
>
> line 170: close $out_file or die "Can't close out_file $!";
>
> why isn't it closing?
> ken
Ok I answered my own question, I had previously commented out the open
file lines...
------------------------------
Date: Fri, 5 Oct 2007 23:02:21 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: FAQ 5.5 How can I copy a file?
Message-Id: <fe6fvn.j0.1@news.isolution.nl>
PerlFAQ Server schreef:
> use File::Copy;
But not before reading some of
http://www.google.co.uk/search?q=file.copy+abigail
http://perl.abigail.be/Talks/FC/HTML/
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Fri, 05 Oct 2007 11:34:51 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: How to manipulate the cases of letters in a string?
Message-Id: <051020071134518140%jgibson@mail.arc.nasa.gov>
In article <fe4fgi$1623$1@ns.felk.cvut.cz>, Petr Vileta
<stoupa@practisoft.cz> wrote:
> Jim Gibson wrote:
> > In article <1191541667.632448.15320@g4g2000hsf.googlegroups.com>, xz
> > <zhang.xi.cn@gmail.com> wrote:
> >
> >> Say, change "i LOVE this Game" into "I LOVE THIS GAME" or "i love
> >> this game"
> >
> > perldoc -f uc
> > perldoc -f lc
>
> Your answer is short and to the subject, but not all perl programmers use
> Linux. I can mention only that some of us are using ActiveState Perl and we
> have not any perldoc.exe on our Windows PCs :-)
> Maybe will be better to write some "OS independent", e.g. "look at function
> uc()".
No time. :)
> I don't know what type of documentation is on Mac.
perldoc
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Fri, 05 Oct 2007 19:15:04 -0000
From: xz <zhang.xi.cn@gmail.com>
Subject: Re: How to manipulate the cases of letters in a string?
Message-Id: <1191611704.434084.230940@g4g2000hsf.googlegroups.com>
On Oct 5, 10:50 am, xz <zhang.xi...@gmail.com> wrote:
> On Oct 5, 3:15 am, Reinhard Pagitsch <r...@gmx.net> wrote:
>
>
>
> > Petr Vileta wrote:
> > > Jim Gibson wrote:
> > >> In article <1191541667.632448.15...@g4g2000hsf.googlegroups.com>, xz
> > >> <zhang.xi...@gmail.com> wrote:
>
> > >>> Say, change "i LOVE this Game" into "I LOVE THIS GAME" or "i love
> > >>> this game"
>
> > >> perldoc -f uc
> > >> perldoc -f lc
>
> > > Your answer is short and to the subject, but not all perl programmers
> > > use Linux. I can mention only that some of us are using ActiveState Perl
> > > and we have not any perldoc.exe on our Windows PCs :-)
>
> > We have perldoc.bat on our system in the \perl\bin directory.
> > And we have also the HTML documentation under \perl\html.
>
> Do you know where is this html documentation on linux?
> Thanks!
Just figured out this..... thank you guys.
>
> > Simply open the index.html, in the left frame search for perlfunc, klick
> > it and search for upper.
>
> > > Maybe will be better to write some "OS independent", e.g. "look at
> > > function uc()".
> > > I don't know what type of documentation is on Mac.
>
> > I think the same as on Win. or Unix: perldoc and/or the HTML documentation.
>
> > regards,
> > Reinhard
>
> > --
------------------------------
Date: Fri, 05 Oct 2007 17:33:46 -0400
From: Sherman Pendley <spamtrap@dot-app.org>
Subject: Re: How to manipulate the cases of letters in a string?
Message-Id: <m1y7eh8cw5.fsf@dot-app.org>
Reinhard Pagitsch <rprp@gmx.net> writes:
> Petr Vileta wrote:
>
>> Maybe will be better to write some "OS independent", e.g. "look at
>> function uc()".
>> I don't know what type of documentation is on Mac.
>
> I think the same as on Win. or Unix: perldoc and/or the HTML documentation.
Or ShuX. :-)
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Fri, 05 Oct 2007 22:44:28 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: jabba the tuh
Message-Id: <1191620581.28528.0@damia.uk.clara.net>
Wade Ward wrote:
> Thanks all for replies. Michele errs when he claims that getting plonked by
> one of 800 million Indians, because I'm the type of guy who would jusy as
> soon blow up your country as talk to you. Idle threat? I can launch a
> pound of hamburger from my desk here in abq and hit 60 e to 90 e, the
> equator plus 30 in ihat oh I don't, 10^20 times, and depending on how close
> I want to get, wipe out 80 percent of India's cows.
Hey! I get it: it's a bot. Some research program somewhere, I expect.
--
Henry Law Manchester, England
------------------------------
Date: Fri, 05 Oct 2007 14:12:18 -0700
From: Bill H <bill@ts1000.us>
Subject: More math than perl...
Message-Id: <1191618738.361537.183720@o3g2000hsb.googlegroups.com>
Background:
I have a routine I am writing in perl that will give me the median for
a 0 to 5 rating. The ratings are stored in a file and I load the
values into 7 different variables, RATE0 - RATE5 and one called TOTAL.
When a person rates a page I increment one of the RATE variables
based on what they selected (0 - 5) and increment TOTAL so I have a
running count (which is really just the sum of RATE0 - RATE5).
The problem I have (and I hope I am explaining this right), to
calculate a median, I have to make an array that contains all the
values, sorted from low to high, and then look at the value of the
element in the middle to get the median. As an example if I have the
following (not real code, just an example of the logic):
$RATE[0] = 3;
$RATE[1] = 1;
$RATE[2] = 0;
$RATE[3] = 4;
$RATE[4] = 1;
$RATE[5] = 2;
Then my array would be:
@ARRAY = (0,0,0,1,3,3,3,3,4,5,5);
And the median would be $ARRAY[5] or 3. With an even number of
elements in @ARRAY I have to add the value below the middle and the
value above the middle, divide by 2 to get the median.
For a small sample this is no problem, but when the number of people
who have rated it get in to the 1000's this array is going to be too
cumbersome. Does anyone know of a simpler way to do it in perl without
adding in modules or using alot of memory?
Any / all ideas are welcomed, but please remember that the example I
gave is just typed to give you an idea and is not any real code I am
using.
Bill H
------------------------------
Date: 05 Oct 2007 17:44:43 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: More math than perl...
Message-Id: <873awpz16c.fsf@mithril.chromatico.net>
>>>>> "BH" == Bill H <bill@ts1000.us> writes:
BH> The problem I have (and I hope I am explaining this right), to
BH> calculate a median, I have to make an array that contains all
BH> the values, sorted from low to high, and then look at the
BH> value of the element in the middle to get the median.
So, let me see if I understand this right.
You have five variables, $RATE0 through $RATE5, and each contains a
count of how many people rated that page that number?
You could probably do something slick, but the brute-force method
looks like this:
my @array = ((0) x $RATE0, (1) x $RATE1, (2) x $RATE2,
(3) x $RATE3, (4) x $RATE4, (5) x $RATE5);
my $median;
if (@array % 2)
{
$median = ($array[(@array-1)/2] + $array[(@array+1)/2])/2;
}
else
{
$median = $array[@array/2];
}
Alternately, if you did the sensible thing and kept $RATE0 through
$RATE5 in an array, you could say, much more elegantly,
my @array = map { ($_) x $RATE[$_] } (0..5);
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Fri, 05 Oct 2007 21:51:50 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: More math than perl...
Message-Id: <WlyNi.19$Cj1.4@edtnps90>
Bill H wrote:
> Background:
>
> I have a routine I am writing in perl that will give me the median for
> a 0 to 5 rating. The ratings are stored in a file and I load the
> values into 7 different variables, RATE0 - RATE5 and one called TOTAL.
> When a person rates a page I increment one of the RATE variables
> based on what they selected (0 - 5) and increment TOTAL so I have a
> running count (which is really just the sum of RATE0 - RATE5).
>
> The problem I have (and I hope I am explaining this right), to
> calculate a median, I have to make an array that contains all the
> values, sorted from low to high, and then look at the value of the
> element in the middle to get the median. As an example if I have the
> following (not real code, just an example of the logic):
>
> $RATE[0] = 3;
> $RATE[1] = 1;
> $RATE[2] = 0;
> $RATE[3] = 4;
> $RATE[4] = 1;
> $RATE[5] = 2;
>
> Then my array would be:
>
> @ARRAY = (0,0,0,1,3,3,3,3,4,5,5);
>
> And the median would be $ARRAY[5] or 3. With an even number of
> elements in @ARRAY I have to add the value below the middle and the
> value above the middle, divide by 2 to get the median.
>
> For a small sample this is no problem, but when the number of people
> who have rated it get in to the 1000's this array is going to be too
> cumbersome. Does anyone know of a simpler way to do it in perl without
> adding in modules or using alot of memory?
>
> Any / all ideas are welcomed, but please remember that the example I
> gave is just typed to give you an idea and is not any real code I am
> using.
Perhaps this is close to what you require:
$ perl -le'
my @RATES = ( 3, 1, 0, 4, 1, 2 );
my $TOTAL = 11;
my $half = int( $TOTAL / 2 );
for my $i ( 0 .. $#RATES ) {
if ( ( $half -= $RATES[ $i ] ) < 0 ) {
print "Median = $i";
last;
}
}
'
Median = 3
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Fri, 05 Oct 2007 14:53:25 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: More math than perl...
Message-Id: <051020071453250824%jgibson@mail.arc.nasa.gov>
In article <1191618738.361537.183720@o3g2000hsb.googlegroups.com>, Bill
H <bill@ts1000.us> wrote:
> Background:
>
> I have a routine I am writing in perl that will give me the median for
> a 0 to 5 rating. The ratings are stored in a file and I load the
> values into 7 different variables, RATE0 - RATE5 and one called TOTAL.
> When a person rates a page I increment one of the RATE variables
> based on what they selected (0 - 5) and increment TOTAL so I have a
> running count (which is really just the sum of RATE0 - RATE5).
>
> The problem I have (and I hope I am explaining this right), to
> calculate a median, I have to make an array that contains all the
> values, sorted from low to high, and then look at the value of the
> element in the middle to get the median. As an example if I have the
> following (not real code, just an example of the logic):
>
> $RATE[0] = 3;
> $RATE[1] = 1;
> $RATE[2] = 0;
> $RATE[3] = 4;
> $RATE[4] = 1;
> $RATE[5] = 2;
>
> Then my array would be:
>
> @ARRAY = (0,0,0,1,3,3,3,3,4,5,5);
>
> And the median would be $ARRAY[5] or 3. With an even number of
> elements in @ARRAY I have to add the value below the middle and the
> value above the middle, divide by 2 to get the median.
>
> For a small sample this is no problem, but when the number of people
> who have rated it get in to the 1000's this array is going to be too
> cumbersome. Does anyone know of a simpler way to do it in perl without
> adding in modules or using alot of memory?
If you have the counts in an array, you needn't generate an array with
the actual scores. Start adding the counts from 0 to 5. Find the count
element that, when added to the subtotal, makes the subtotal exceed
half of the total count. The score for that array element is the
median.
#!/usr/local/bin/perl
use warnings;
use strict;
my @rate = qw( 3 1 0 4 1 2 );
my $total =0;
$total += $_ for @rate;
my $median = ($total/2);
print "median score is $median of $total\n";
my $subtotal = 0;
for my $r ( 0 .. $#rate ) {
$subtotal += $rate[$r];
if( $subtotal >= $median ) {
print "Median score of (@rate) is $r\n";
last;
}
}
__OUTPUT__
median score is 5.5 of 11
Median score of (3 1 0 4 1 2) is 3
There are some edge cases, such as $subtotal == $median, that are left
as an exercise. :)
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Fri, 05 Oct 2007 14:56:39 -0700
From: Bill H <bill@ts1000.us>
Subject: Re: More math than perl...
Message-Id: <1191621399.827170.94590@50g2000hsm.googlegroups.com>
On Oct 5, 5:44 pm, Charlton Wilbur <cwil...@chromatico.net> wrote:
> >>>>> "BH" == Bill H <b...@ts1000.us> writes:
>
> BH> The problem I have (and I hope I am explaining this right), to
> BH> calculate a median, I have to make an array that contains all
> BH> the values, sorted from low to high, and then look at the
> BH> value of the element in the middle to get the median.
>
> So, let me see if I understand this right.
>
> You have five variables, $RATE0 through $RATE5, and each contains a
> count of how many people rated that page that number?
>
> You could probably do something slick, but the brute-force method
> looks like this:
>
> my @array = ((0) x $RATE0, (1) x $RATE1, (2) x $RATE2,
> (3) x $RATE3, (4) x $RATE4, (5) x $RATE5);
>
> my $median;
>
> if (@array % 2)
> {
> $median = ($array[(@array-1)/2] + $array[(@array+1)/2])/2;}
>
> else
> {
> $median = $array[@array/2];
>
> }
>
> Alternately, if you did the sensible thing and kept $RATE0 through
> $RATE5 in an array, you could say, much more elegantly,
>
> my @array = map { ($_) x $RATE[$_] } (0..5);
>
> Charlton
>
> --
> Charlton Wilbur
> cwil...@chromatico.net
Thanks Charlton, but would this not still make a large array if the
total number of people is high (unles I am missing something in it).
Bill H
------------------------------
Date: Fri, 5 Oct 2007 08:44:58 -1000
From: Sean Nakasone <seannakasone@yahoo.com>
Subject: newbie question: find index of substr using regexp
Message-Id: <Pine.WNT.4.64.0710050842250.3956@ctfanxnfba.unjnvvnaryrpgevp.arg>
Hello, i think this should be an easy question. how do i search for a
substring in a string by using a regular expression and obtain the index
of the substring.
i would think i could just use index(), and use a regular expression as
the 2nd parameter, but that doesn't seem to work.
------------------------------
Date: Fri, 05 Oct 2007 13:59:14 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: newbie question: find index of substr using regexp
Message-Id: <47068982$0$3575$815e3792@news.qwest.net>
Sean Nakasone wrote:
> Hello, i think this should be an easy question. how do i search for a
> substring in a string by using a regular expression and obtain the index
> of the substring.
>
> i would think i could just use index(), and use a regular expression as
> the 2nd parameter, but that doesn't seem to work.
>
perldoc perlre
perldoc -f pos
Also, to see what index supports: perldoc -f index
"...searches for one string within another"
------------------------------
Date: Fri, 05 Oct 2007 12:19:59 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: newbie question: find index of substr using regexp
Message-Id: <051020071219598790%jgibson@mail.arc.nasa.gov>
In article
<Pine.WNT.4.64.0710050842250.3956@ctfanxnfba.unjnvvnaryrpgevp.arg>,
Sean Nakasone <seannakasone@yahoo.com> wrote:
> Hello, i think this should be an easy question. how do i search for a
> substring in a string by using a regular expression and obtain the index
> of the substring.
>
> i would think i could just use index(), and use a regular expression as
> the 2nd parameter, but that doesn't seem to work.
>
No, index takes only strings, which are not interpreted as regular
expressions.
You can use the length of the $` variable, which is set to the
substring to the left of the match (but be aware of the speed penalty
for doing so as described in 'perldoc perlre').
You can also put (.*?) at the beginning of your regular expression and
use the length of the captured string $1, but make sure that addition
doesn't screw up your RE.
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Fri, 5 Oct 2007 09:29:33 -1000
From: Sean Nakasone <seannakasone@yahoo.com>
Subject: Re: newbie question: find index of substr using regexp
Message-Id: <Pine.WNT.4.64.0710050928370.3956@ctfanxnfba.unjnvvnaryrpgevp.arg>
Ok, i read it. Is this the easiest way to find the offset of the first
non-space character?
use strict;
use warnings;
my $a = " quick brown";
$a =~ m/[^ ]/g;
print (pos($a));
------------------------------
Date: Fri, 5 Oct 2007 09:45:31 -1000
From: Sean Nakasone <seannakasone@yahoo.com>
Subject: Re: newbie question: find index of substr using regexp
Message-Id: <Pine.WNT.4.64.0710050944340.3956@ctfanxnfba.unjnvvnaryrpgevp.arg>
ok i guess i'll be using this. thanks for your help
use strict;
use warnings;
my $a = " quick brown";
$a =~ /[^ ]/;
print (length($`));
------------------------------
Date: Fri, 05 Oct 2007 12:53:24 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: newbie question: find index of substr using regexp
Message-Id: <051020071253244860%jgibson@mail.arc.nasa.gov>
In article
<Pine.WNT.4.64.0710050944340.3956@ctfanxnfba.unjnvvnaryrpgevp.arg>,
Sean Nakasone <seannakasone@yahoo.com> wrote:
> ok i guess i'll be using this. thanks for your help
>
>
> use strict;
> use warnings;
>
> my $a = " quick brown";
> $a =~ /[^ ]/;
> print (length($`));
Don't use any of the RE special variables unless the match succeeded:
if( $a =~ /[^ ]/ ) {
print (length($`));
}
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Fri, 05 Oct 2007 21:13:16 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: newbie question: find index of substr using regexp
Message-Id: <MNxNi.3$Cj1.0@edtnps90>
Sean Nakasone wrote:
> Hello, i think this should be an easy question. how do i search for a
> substring in a string by using a regular expression and obtain the index
> of the substring.
>
> i would think i could just use index(), and use a regular expression as
> the 2nd parameter, but that doesn't seem to work.
perldoc perlvar
Look for the variables @+ (@LAST_MATCH_END) and @- (@LAST_MATCH_START).
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Fri, 05 Oct 2007 21:06:31 +0200
From: Larry <dontmewithme@got.it>
Subject: passing $fd as a reference
Message-Id: <dontmewithme-AF2DFA.21063105102007@news.tin.it>
Hi everybody,
below is a few lines from http::daemon pod:
--
$c->send_file( $filename )
$c->send_file( $fd )
Copy the file to the client. The file can be a string (which will be
interpreted as a filename) or a reference to an IO::Handle or glob.
--
I have to admit I have never read file contents by IO::Handle
I usually go about it by:
my $song = 'song.mp3';
open my $fh1, '<', $song or die "open(): $!\n";
binmode $fh1;
close($fh1);
how can I tie the code above to $c->send_file( $fd ) ???
--
btw, when reading a binary file in order to move cursor position, do you
think I should use "seek" or "sysseek" and the should I use read the
file by "read" or "sysread" ??
thanks ever so much!
------------------------------
Date: Fri, 05 Oct 2007 13:02:38 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: passing $fd as a reference
Message-Id: <051020071302388074%jgibson@mail.arc.nasa.gov>
In article <dontmewithme-AF2DFA.21063105102007@news.tin.it>, Larry
<dontmewithme@got.it> wrote:
> Hi everybody,
>
> below is a few lines from http::daemon pod:
>
> --
> $c->send_file( $filename )
> $c->send_file( $fd )
>
> Copy the file to the client. The file can be a string (which will be
> interpreted as a filename) or a reference to an IO::Handle or glob.
> --
>
> I have to admit I have never read file contents by IO::Handle
>
> I usually go about it by:
>
> my $song = 'song.mp3';
> open my $fh1, '<', $song or die "open(): $!\n";
> binmode $fh1;
> close($fh1);
>
> how can I tie the code above to $c->send_file( $fd ) ???
Use IO::File (untested):
my $fh1 = new IO::File $song;
die "open: $!" unless defined $fh1;
$fh1->binmode;
$c->send_file($fh1);
$fh1->close;
>
> --
>
> btw, when reading a binary file in order to move cursor position, do you
> think I should use "seek" or "sysseek" and the should I use read the
> file by "read" or "sysread" ??
Use sysseek if you are using sysread to read the file, seek otherwise.
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Fri, 05 Oct 2007 14:50:42 -0500
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Reading a files's name
Message-Id: <13gd6hlgfvstkf4@corp.supernews.com>
On 10/05/2007 10:49 AM, lerameur wrote:
>
> Ok here are the name again:
> 07100510555501.log
> 07100510555503.log
> 07100510555505.log
> 07100511555501.log
> 07100511555503.log
> 07100511555505.log
> 07100512555501.log
> 07100512555503.log
> 07100512555505.log
> I need to open 07100510555501.log
> I can use
> -glob($year$month$day$hour*)
> -read the file
> - hours++
> then read the following file.... but oupss I have three files within
> that hour.
> How do I read the 01, 03 and 05 near the end of the file so I can
> treat these seperatly?
>
> k
>
You can use a regular expression to capture the last two digits in the
filename.
Don't be offended, but I don't think you've given yourself enough time
to learn the Perl functions and operations. Your task is too simple for
someone who's been using Perl for a while. Please read these tutorials
and do the exercises in them:
http://perldoc.perl.org/perlintro.html
http://perldoc.perl.org/perlrequick.html
http://perldoc.perl.org/perlretut.html
Invest in a good Perl book for newbies, and you'll be happier.
--
http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
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 910
**************************************