[21846] in Perl-Users-Digest
Perl-Users Digest, Issue: 4050 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 31 00:05:46 2002
Date: Wed, 30 Oct 2002 21:05:08 -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 Wed, 30 Oct 2002 Volume: 10 Number: 4050
Today's topics:
Re: *** PERL monitor script...*** <pkent77tea@yahoo.com.tea>
[OT] Re: Open a HTML page not using redirect <jeff@vpservices.com>
Re: Can package names be supplied on-the-fly? <jkeen@concentric.net>
hash lookup problem (B Puli)
Re: hash lookup problem <steven.smolinski@sympatico.ca>
Re: hash lookup problem ctcgag@hotmail.com
Re: hash lookup problem <me@dwall.fastmail.fm>
Re: hash lookup problem <steven.smolinski@sympatico.ca>
How to merge two sequential lines ? (Slavko Vorkapitch)
Re: How to merge two sequential lines ? (Jay Tilton)
Re: How to pass control character to a telnet session (Prashant Varghese)
Re: How to pass control character to a telnet session (Prashant Varghese)
log files for previous month <pasdespam_desmond@zeouane.org>
Re: More Efficient Way To Get Last Line From A TXT File <jlim30@hotmail.com>
Re: setreuid on AIX 5.1 with perl 5.6.1 <techcog@acme.N3T>
Re: significance of 42 for perl, any?!? <bart.lateur@pandora.be>
Re: significance of 42 for perl, any?!? <jeff@vpservices.com>
Re: significance of 42 for perl, any?!? <flavell@mail.cern.ch>
UTF-8 translation? <ekulis@apple.com>
Re: UTF-8 translation? (Alan Barclay)
Re: while vs. foreach (Jan Fure)
Re: while vs. foreach <krahnj@acm.org>
Re: while vs. foreach <wyzelli@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 30 Oct 2002 23:18:02 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: *** PERL monitor script...***
Message-Id: <pkent77tea-BA973C.23180130102002@news-text.blueyonder.co.uk>
In article <3DC00183.FDAA946@mis.gla.ac.uk>,
inderjit s gabrie <igabrie@mis.gla.ac.uk> wrote:
> I am just starting out in perl/cgi scripting...i have done some simple
> programs , what i want to do is to have a 'system status' web page which
> has all of our unix box names on it...what i want is a perl script that
> i can embed into html to monitor these two unix systems, any alerts or
> if they crash i want this system staus webpage to show the system
> staus, can this be done...or is there any perl/cgi script that can do
> the job ....thanks in advance...indy
Try Netsaint, Big Brother, Big Sister, and the like. You may be
interested in MRTG too.
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Wed, 30 Oct 2002 15:00:14 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: [OT] Re: Open a HTML page not using redirect
Message-Id: <3DC0647E.90702@vpservices.com>
TBN wrote:
>>>the returned results will be in the same window as the submitted form.
>>>
>>
>>Not necessarily. The results will go to wherever the TARGET tag of the
>>form is aimed at or wherever the page's base TARGET is aimed at. Those
>>targets may or may not be the same window the form was submitted from.
>>
>
> Good point, I forgot about that, but that's outside scope since it still
> won't return results to a designated popup window that has not yet been
> created.
Balderdash. Where do you think this goes, regardless of what has or
hasn't been created previously and regardless of the level of javascript
support?
<a href="foo" target="newWin">bar</a>
But since this has nothing to do with perl, why don't we just drop it.
--
Jeff
------------------------------
Date: 31 Oct 2002 02:35:36 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Can package names be supplied on-the-fly?
Message-Id: <apq4to$n1t@dispatch.concentric.net>
"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3DBEDC2A.BBD10C85@earthlink.net...
> Randal L. Schwartz wrote:
> >
> > >>>>> "Benjamin" == Benjamin Goldberg <goldbb2@earthlink.net> writes:
> >
> > Benjamin> foreach (sort keys %{ $pkg . "::" } ) {
> > Benjamin> $reprocess_subs{$_}++ if
> > Benjamin> $_ =~ /^reprocess_/ and defined *{$_}{CODE};
> > Benjamin> }
> >
> > And even simpler, a routine that can be called from any package:
> >
> > sub my_reprocess_subs {
> > my $caller_package = shift || caller;
> > no strict 'refs';
> > grep { /^reprocess_/ and defined *{$_}{CODE} }
> > sort keys %{ $caller_package . "::" }
> > }
>
>
> The keys of %Foo:: are not fully qualified... they are strings like
> "bar". Checking for defined *{"bar"}{CODE} will check in the *current*
> package. That was why I qualified my last suggested change with
> pointing out that that $pkg always comes from __PACKAGE__.
>
Which is the way I want it. Ben, your second suggestion, like the first,
DWIW and eliminates one named variable. Occam's Razor: it goes in the
code. Thanks.
------------------------------
Date: 30 Oct 2002 15:15:23 -0800
From: bpuli@hotmail.com (B Puli)
Subject: hash lookup problem
Message-Id: <42ec637b.0210301515.2c8eaca4@posting.google.com>
hi folks:
i have a (large) hash that looks like this:
my %prj = (
'Base-Project-Nothing'=>'C-Base-MDriver',
'Base-Project-WDE'=>'C-Base-WDE',
'Base-Project-DEP'=>'C-Base-DEP',
'Amarillo-All'=>'1-Base-Amarillo'
);
i contruct the key part from variables and do a hash lookup.
$base="Base";
$pj = "Project"
$d = "WDE";
$tmp = $base."-".$pj."-".$d;
when i do a
print $prj{$tmp};
i get nothing. but if i do a
print $prj{'Base-Project-WDE'}, i get the right value 'C-Base-WDE'
is this a quoting problem somewhere?
any pointers appreciated.
tia
bp
------------------------------
Date: Wed, 30 Oct 2002 23:27:46 GMT
From: Steven Smolinski <steven.smolinski@sympatico.ca>
Subject: Re: hash lookup problem
Message-Id: <SVZv9.5705$h_4.969781@news20.bellglobal.com>
B Puli <bpuli@hotmail.com> wrote:
> i have a (large) hash that looks like this:
>
> my %prj = (
> 'Base-Project-Nothing'=>'C-Base-MDriver',
> 'Base-Project-WDE'=>'C-Base-WDE',
> 'Base-Project-DEP'=>'C-Base-DEP',
> 'Amarillo-All'=>'1-Base-Amarillo'
> );
>
> i contruct the key part from variables and do a hash lookup.
> $base="Base";
> $pj = "Project"
> $d = "WDE";
>
> $tmp = $base."-".$pj."-".$d;
>
> when i do a
>
> print $prj{$tmp};
>
> i get nothing. but if i do a
>
> print $prj{'Base-Project-WDE'}, i get the right value 'C-Base-WDE'
>
> is this a quoting problem somewhere?
You should post a small bit of actual code, what you expected it to do,
and what it does that you did not expect. It's much easier to help you
that way. Without more details, all I can say is "Works For Me."
Here's your code above cut and pasted into a program, which seems to
work as you'd expect:
#!/usr/bin/perl
use warnings;
use strict;
my %prj = (
'Base-Project-Nothing'=>'C-Base-MDriver',
'Base-Project-WDE'=>'C-Base-WDE',
'Base-Project-DEP'=>'C-Base-DEP',
'Amarillo-All'=>'1-Base-Amarillo'
);
my $base="Base";
my $pj = "Project";
my $d = "WDE";
my $tmp = $base."-".$pj."-".$d;
print $prj{$tmp}, "\n";
__END__
Steve
------------------------------
Date: 31 Oct 2002 00:45:01 GMT
From: ctcgag@hotmail.com
Subject: Re: hash lookup problem
Message-Id: <20021030194501.661$NL@newsreader.com>
bpuli@hotmail.com (B Puli) wrote:
> hi folks:
>
> i have a (large) hash that looks like this:
>
> my %prj = (
> 'Base-Project-Nothing'=>'C-Base-MDriver',
> 'Base-Project-WDE'=>'C-Base-WDE',
> 'Base-Project-DEP'=>'C-Base-DEP',
> 'Amarillo-All'=>'1-Base-Amarillo'
> );
>
> # i contruct the key part from variables and do a hash lookup.
^ I've commented out your comments
> $base="Base";
> $pj = "Project"
the lack of ; generates a syntax error
> $d = "WDE";
>
> $tmp = $base."-".$pj."-".$d;
>
> # when i do a
>
> print $prj{$tmp};
>
> # i get nothing. but if i do a
I get C-Base-WDE here. The code you post doesn't demonstrate
the problem you claim.
>
> print $prj{'Base-Project-WDE'}, i get the right value 'C-Base-WDE'
>
> # is this a quoting problem somewhere?
I'm betting our real code has some line-endings stuck where they shouldn't
be.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service
------------------------------
Date: Thu, 31 Oct 2002 00:47:55 GMT
From: "David K. Wall" <me@dwall.fastmail.fm>
Subject: Re: hash lookup problem
Message-Id: <Xns92B7C96744EA3dkwwashere@216.148.227.77>
Steven Smolinski <steven.smolinski@sympatico.ca> wrote:
> You should post a small bit of actual code, what you expected it to do,
> and what it does that you did not expect. It's much easier to help you
> that way. Without more details, all I can say is "Works For Me."
[snip]
> my $tmp = $base."-".$pj."-".$d;
The only thing I would add is that it's easier to read it as
my $tmp = "$base-$pj-$d";
I'm sure you knew that, but were just following the OP's style. Just
thought I'd mention it.
--
David Wall - me@dwall.fastmail.fm
"Oook."
------------------------------
Date: Thu, 31 Oct 2002 01:25:17 GMT
From: Steven Smolinski <steven.smolinski@sympatico.ca>
Subject: Re: hash lookup problem
Message-Id: <1E%v9.10263$Nf2.949136@news20.bellglobal.com>
David K. Wall <me@dwall.fastmail.fm> wrote:
> Steven Smolinski <steven.smolinski@sympatico.ca> wrote:
>
>> You should post a small bit of actual code, what you expected it to do,
>> and what it does that you did not expect. It's much easier to help you
>> that way. Without more details, all I can say is "Works For Me."
> [snip]
>> my $tmp = $base."-".$pj."-".$d;
>
> The only thing I would add is that it's easier to read it as
>
> my $tmp = "$base-$pj-$d";
>
> I'm sure you knew that, but were just following the OP's style. Just
> thought I'd mention it.
Well, yeah, I was cutting and pasting the OP's code. Were it me, and I
wanted a data structure with three keys to a value, I'd probably make a
data structure with three keys to a value, not concatenate three keys
into one (ceteris paribus).
Steve
------------------------------
Date: 30 Oct 2002 17:28:18 -0800
From: el_squid_2000@yahoo.com (Slavko Vorkapitch)
Subject: How to merge two sequential lines ?
Message-Id: <e0a5b916.0210301728.7f7c8a0@posting.google.com>
Hi I need to merge two lines that look something like
important stuff on line 1
important stuff on line 2
which becomes:
important stuff on line 1 important stuff on line 2
Problem with s/\n// etc.. is it doesn't create a merged line - that
only happens out of a print statement. One alternative is to make 2
passes through a while loop, keeping a variable from the previous
pass.. merging the two strings.. but this seems kludgy. Any help
appreciated.
Thanks in advance,
El Squid
------------------------------
Date: Thu, 31 Oct 2002 02:52:43 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: How to merge two sequential lines ?
Message-Id: <3dc09683.81036705@news.erols.com>
On 30 Oct 2002 17:28:18 -0800, el_squid_2000@yahoo.com (Slavko
Vorkapitch) wrote:
: Hi I need to merge two lines that look something like
:
: important stuff on line 1
: important stuff on line 2
:
: which becomes:
: important stuff on line 1 important stuff on line 2
my $foo1 = 'important stuff on line 1';
my $foo2 = 'important stuff on line 2';
my $foos = join ' ', $foo1, $foo2;
: Problem with s/\n// etc.. is it doesn't create a merged line - that
: only happens out of a print statement.
Whut? Why is print() a necessary ingredient in the genesis of a
string?
: One alternative is to make 2
: passes through a while loop, keeping a variable from the previous
: pass.. merging the two strings.. but this seems kludgy. Any help
: appreciated.
The requirements are not at all clear. Some sample code illustrating
exactly what you want to happen would help tremendously.
If the "lines" are elements of an array, try this.
my @ary = qw/foo bar baz fraz/;
my @ary_copy = @ary;
print join(' ', splice @ary_copy, 0, 2), "\n" while @ary_copy;
If the idea is to filter between STDIN and STDOUT, try this.
{
local $\;
while(<>) {
chomp;
$\ = $. % 2 ? ' ' : "\n";
print
}
}
------------------------------
Date: 30 Oct 2002 20:26:10 -0800
From: pv79@ddsl.net (Prashant Varghese)
Subject: Re: How to pass control character to a telnet session
Message-Id: <5ff7e2e0.0210302026.797665c9@posting.google.com>
Dear Chris and Brian McCauley ,
Thanks and now i understood where exactly ^] is used. I was under the
impression that it is passed to the remote host.
$r is a Net::Telnet object
i.e $r=new Net::Telnet(Dump_Log =>$file);
Thanks and regards,
Prashant
news@roaima.freeserve.co.uk wrote in message news:<tplopa.6uh.ln@moldev.cmagroup.co.uk>...
> Prashant Varghese <pv79@ddsl.net> wrote:
> > has anyone tried passing control character over telnet session to a
> > remote host.
>
> > I've been trying to find a way to pass '^]' to terminate the telnet
> > session in the following manner.
>
> > $r->print ("\c]");
>
> > Please tell me if its correct and why it is not working out?
>
> I don't know what your $r object is supposed to be, so I can only guess
> at a possible answer.
>
> 1. When you type ^] in a telnet client, it and the following text is
> grabbed and interpreted by that local client. None of it gets
> anywhere near the remote host. This means that you can't send a
> ^] to a remote host using something like Net::Telnet and expect
> it to work in the same manner. (Net::Telnet has other mechanisms
> for ending a session.)
>
> 2. Are you sure that you should represent ^] by the sequence of
> characters "\c]"? This doesn't feel right to me
>
> Chris
------------------------------
Date: 30 Oct 2002 20:35:24 -0800
From: pv79@ddsl.net (Prashant Varghese)
Subject: Re: How to pass control character to a telnet session
Message-Id: <5ff7e2e0.0210302035.78e35979@posting.google.com>
Dear Chris,
How can i find a solution for this problem of using ^] ?
man perlop will detail you abt how to repesent control character under
Quote and Quote-like Operators section.
If thats not true then how do i use it?Do you have any suggestions?
Thanks and Regards,
Prashant
news@roaima.freeserve.co.uk wrote in message news:<tplopa.6uh.ln@moldev.cmagroup.co.uk>...
> Prashant Varghese <pv79@ddsl.net> wrote:
> > has anyone tried passing control character over telnet session to a
> > remote host.
>
> > I've been trying to find a way to pass '^]' to terminate the telnet
> > session in the following manner.
>
> > $r->print ("\c]");
>
> > Please tell me if its correct and why it is not working out?
>
> I don't know what your $r object is supposed to be, so I can only guess
> at a possible answer.
>
> 1. When you type ^] in a telnet client, it and the following text is
> grabbed and interpreted by that local client. None of it gets
> anywhere near the remote host. This means that you can't send a
> ^] to a remote host using something like Net::Telnet and expect
> it to work in the same manner. (Net::Telnet has other mechanisms
> for ending a session.)
>
> 2. Are you sure that you should represent ^] by the sequence of
> characters "\c]"? This doesn't feel right to me
>
> Chris
------------------------------
Date: Thu, 31 Oct 2002 01:40:32 +0000
From: Desmond Coughlan <pasdespam_desmond@zeouane.org>
Subject: log files for previous month
Message-Id: <slrnas12gf.1bfi.pasdespam_desmond@lievre.voute.net>
Hi,
I'm working on a script which will be pathetically simple by the standards
of most of you here, but which is 'advanced' for me. :-)
A friend of mine uses my webserver for virtual hosting. I want to gather
the statistics from the log file, grep them to find only the pages in
his directory that were accessed. Here's what I've come up with ...
http://www.zeouane.org/perl/visitors.html
It's basic, but it works. What I need to do now is to somehow only send
the previous seven day's logs. The logs (it's an apache box) look roughly
like this ...
255.255.255.255 - - [30/Oct/2002:23:49:11 +0000] "GET /path/to/file HTTP/1.0" \
200 7377
Can someone help ? Thanks.
--
Desmond Coughlan |CUNT#1 YGL#4 YFC#1 YFB#1 UKRMMA#14 two#38
desmond @ zeouane.org |BONY#48 ANORAK#11
http: // www . zeouane . org
------------------------------
Date: Thu, 31 Oct 2002 11:06:30 +0800
From: Johnny Lim <jlim30@hotmail.com>
Subject: Re: More Efficient Way To Get Last Line From A TXT File
Message-Id: <oc71sucfjk1mvd2kg7l5eel0jgpapndiql@4ax.com>
Good day Ben,
On Wed, 30 Oct 2002 12:47:37 -0500, "Ben Kennedy" <bkennedy@hmsonline.com>
wrote:
<SNIP>
>This is the most common way of using file handles, as "slurping" does not
>scale very well. Look at the "I/O Operators" section in "perldoc perlop".
>Something that would work for you is:
>
>my $last_line; # this will hold the last line successfully read
>while(<CSVFILE>) { # cycle through whole file
> $last_line = $_; # the data returned by <CSVFILE> is stored in $_
>}
>print "> Last line: $last_line\n";
>
>--Ben Kennedy
>
your above example do have a valid usage to get the last line of a file. But if
the file is large, then it's going to take some time to reach to the bottom of
the file.
What i have used is File::ReadBackwards which is available at CPAN. It uses seek
instead of reading line by line.
Anyway, thanks for info.
Johnny Lim
------------------------------
Date: Thu, 31 Oct 2002 04:51:19 GMT
From: "techcog@acme.N3T" <techcog@acme.N3T>
Subject: Re: setreuid on AIX 5.1 with perl 5.6.1
Message-Id: <3247777.0y2mpYEHPQ@gryphon>
Villy Kruse wrote:
> On Tue, 29 Oct 2002 16:28:11 GMT,
> techcog@acme.N3T <techcog@acme.N3T> wrote:
>
>
>>I don't get it? The perl programmers are already involved and it's
>>broken.
>>
>
>
> Get involved in this thread of discussion, of course. It would be
> interesting for me why that was implemented the way it was.
As to the implementation....
Well it may be because there are a total of 48 people
in the world using perl on AIX.
>
>
>
> Villy
------------------------------
Date: Wed, 30 Oct 2002 23:21:33 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: significance of 42 for perl, any?!?
Message-Id: <cbq0susl8q907gtu7farqqekma7040lv7m@4ax.com>
Dave Cross wrote:
>>> is there any particular significance of
>>> 42 for perl or is it just my impression?
>>
>> You need to read "Hitch Hikers Guide to the Galaxy" by Douglas Adams.
>
>Or, better, listen to the original radio series.
I really loved the TV series.
--
Bart.
------------------------------
Date: Wed, 30 Oct 2002 15:40:07 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: significance of 42 for perl, any?!?
Message-Id: <3DC06DD7.9040508@vpservices.com>
Bart Lateur wrote:
> Dave Cross wrote:
>
>
>>>>is there any particular significance of
>>>>42 for perl or is it just my impression?
>>>>
>>>You need to read "Hitch Hikers Guide to the Galaxy" by Douglas Adams.
>>>
>>Or, better, listen to the original radio series.
>>
>
> I really loved the TV series.
>
>
And let's not forget the infocom game, still available for play online
(or download) at:
http://www.douglasadams.com/creations/infocomjava.html
It is pitch black ...
--
Jeff
------------------------------
Date: Thu, 31 Oct 2002 01:02:35 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: significance of 42 for perl, any?!?
Message-Id: <Pine.LNX.4.40.0210310101210.6026-100000@lxplus071.cern.ch>
On Oct 30, Bart Lateur inscribed on the eternal scroll:
> Dave Cross wrote:
>
> >Or, better, listen to the original radio series.
>
> I really loved the TV series.
Nah, the pictures were so much better on the radio.
------------------------------
Date: Wed, 30 Oct 2002 15:56:01 -0800
From: Ed Kulis <ekulis@apple.com>
Subject: UTF-8 translation?
Message-Id: <B9E5B191.40C1%ekulis@apple.com>
Hi all,
We've got an Oracle database in UTF-8 and we build records that travel
either in files Unix-to-Unix/Mac/PD or in Oracle to Oracle communication.
Oracle stores the data in multi-octet UTF-8 format so our Unix files end up
with multi-octet representations when someone has entered a non ASCII 7
character say an accented character or an NO BREAK SPACE. So, the recipients
of the files get errors in record length, column postions, and
uninterpretable characters.
In perl, (and of course being perl it's not too hard at all) I'm writing a
translator that will take multi-octet characters like an umlated-o and turn
it into a safe corresponding character like plain-old-lower-case-o.
But, my experience with the perl news group is that if I have a problem
someone has already solved it.
Question:
Is there a module/reference that already maps all the UTF-8 codes to "safe"
ASCII and vice-versa.?
In our Oracle to Oracle interfaces we can use a function that looks like
this
convert(swstatus,'WE8ISO8859P1','UTF8')
which converts between our UTF-8 coding and a recipient's 2-octet ISO885
coding.
Which enlarges the perl question. ASCII 7 might just be considered another
coding scheme
Question:
Are there module/references that generally map one character coding scheme
to another?
-ed
------------------------------
Date: 31 Oct 2002 04:10:02 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: UTF-8 translation?
Message-Id: <1036037401.505789@elaine.furryape.com>
In article <B9E5B191.40C1%ekulis@apple.com>,
Ed Kulis <ekulis@apple.com> wrote:
>In perl, (and of course being perl it's not too hard at all) I'm writing a
>translator that will take multi-octet characters like an umlated-o and turn
>it into a safe corresponding character like plain-old-lower-case-o.
Are you going to translate the 'u's to 'v's, the 'i's to 'j's and the
'1's to 'l's too?
Accented characters aren't 'plan-old' characters with extra ink. They
are different letters. By removing the accent you are corrupting the
word.
------------------------------
Date: 30 Oct 2002 17:33:46 -0800
From: jan_may2002_fure@attbi.com (Jan Fure)
Subject: Re: while vs. foreach
Message-Id: <e47a84bf.0210301733.31f892eb@posting.google.com>
"Bill Smith" <wksmith@optonline.net> wrote in message news:<kMIv9.19776$TH6.4572@news4.srv.hcvlny.cv.net>...
> Your fix does work correctly, but a loop is not necessary at all. You can
> use the OUTPUT_RECORD_SEPARATOR ($,) to supply
> newlines if they are not in the array.
>
> {
> local $, = "\n";
> print CURRENT @tempdata;
> }
Thanks to everybody who replied, I will take the warning about not
shooting myself in the foot seriously.
I will not modify the foreach argument inside the loop.....
I will not modify the foreach argument inside the loop.....
My method of using a loop was questioned. let me explain my
objectives:
1. The code where I asked about while vs. foreach exists deep into
nested loops.
2. The overall functionallity is to intelligently divide a file into
smaller volumes.
3. The array being written to the filehandle gets used repeatedly, so
it is necessary that the value is reset after each dumping to file.
The options I know about are:
print FILEHANDLE @tempdata;
@tempdata = ();
or
while (@tempdata) {
print CURRENT (shift @tempdata);
}
Does it matter which implementation is used, or is there a better way?
Jan Fure
------------------------------
Date: Thu, 31 Oct 2002 02:52:42 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: while vs. foreach
Message-Id: <3DC09AED.5B2E5E9@acm.org>
Jan Fure wrote:
>
> My method of using a loop was questioned. let me explain my
> objectives:
> 1. The code where I asked about while vs. foreach exists deep into
> nested loops.
> 2. The overall functionallity is to intelligently divide a file into
> smaller volumes.
> 3. The array being written to the filehandle gets used repeatedly, so
> it is necessary that the value is reset after each dumping to file.
>
> The options I know about are:
> print FILEHANDLE @tempdata;
> @tempdata = ();
>
> or
>
> while (@tempdata) {
> print CURRENT (shift @tempdata);
> }
>
> Does it matter which implementation is used, or is there a better way?
Don't forget the ever popular:
print FILEHANDLE splice @tempdata;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 31 Oct 2002 14:14:24 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: while vs. foreach
Message-Id: <uw2w9.16$gG5.74227@vicpull1.telstra.net>
"Luther Barnum" <Spam_Sucks@rr.com> wrote in message
news:NmIv9.28826$fa.573116@twister.tampabay.rr.com...
> >
> How about:
>
> open(CURRENT,">>$name" . "_" . "$n3" . ".txt");
> foreach $line (@tempdata) {
> chomp($line);
> print CURRENT ("$line\n");
Why chomp the newline just to add it back again?
Wyzelli
--
$j='on the job';$h='hacker';$p='Perl';for(reverse(1..100)){
$s=($_!=1)?'s':'';$t=($_!=1)?'one of those':'that';
print"$_ $h$s of $p $j,\n$_ $h$s of $p.\nIf $t $h$s should code a bug,\n";
$_--;$s=($_==1)?'':'s';print"There'd be $_ $h$s of $p $j!\n\n";}print"*use
strict*";
------------------------------
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.
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 4050
***************************************