[21939] in Perl-Users-Digest
Perl-Users Digest, Issue: 4161 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 22 14:06:01 2002
Date: Fri, 22 Nov 2002 11:05:12 -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 Fri, 22 Nov 2002 Volume: 10 Number: 4161
Today's topics:
[ADMIN:] re-posted usenet articles <flavell@mail.cern.ch>
comment on 2 or 4 spaces indentation <gfu@saicmodis.com>
Re: comment on 2 or 4 spaces indentation <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: comment on 2 or 4 spaces indentation <BROWNHIK@Syntegra.Bt.Co.Uk>
Re: comment on 2 or 4 spaces indentation <pinyaj@rpi.edu>
Re: comment on 2 or 4 spaces indentation <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Re: comment on 2 or 4 spaces indentation ctcgag@hotmail.com
Re: comment on 2 or 4 spaces indentation <jurgenex@hotmail.com>
Re: disambiguating print (was Re: Basic syntax question <dtweed@acm.org>
Re: disambiguating print (was Re: Basic syntax question <usenet@dwall.fastmail.fm>
Re: Format a one line file to get two columns (ebchang)
Re: Format a one line file to get two columns <usenet@dwall.fastmail.fm>
Re: Missing ..\Perl\lib\auto\Mail\Internet\autosplit.ix <No_Mail_Address@cox.net>
multiple processes accessing a named pipe (Stephen Wylie)
Re: multiple processes accessing a named pipe <nobull@mail.com>
OT: Tabs in vi (was: comment on 2 or 4 spaces indentati <tassilo.parseval@post.rwth-aachen.de>
Perl/Tk install directories <pa@panix.com>
Re: Perl/Tk install directories <gongwm@163.net>
print the next 5 lines <tedtdhoang@hotmail.com>
Re: print the next 5 lines <ian@WINDOZEdigiserv.net>
Re: print the next 5 lines <tedtdhoang@hotmail.com>
Re: print the next 5 lines (Tad McClellan)
Re: print the next 5 lines <ian@WINDOZEdigiserv.net>
Re: print the next 5 lines <nobull@mail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 22 Nov 2002 16:01:33 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: [ADMIN:] re-posted usenet articles
Message-Id: <Pine.LNX.4.40.0211221553470.9178-100000@lxplus076.cern.ch>
I happened to notice in Google Groups that someone or something at
24.69.255.206 has re-posted at least three of my old articles, with
their original message-id but a re-written date line of Fri, 22 Nov
2002. The original postings of the re-posted articles which I've seen
so far were all on the 10th Nov. I've no idea whether it's just me
that's affected.
I've reported it to their abuse address, but I thought I'd just drop a
brief heads-up into the group here.
[I've suggested f'up to poster - please feel free to adjust...]
------------------------------
Date: Fri, 22 Nov 2002 09:44:27 -0500
From: Gary Fu <gfu@saicmodis.com>
Subject: comment on 2 or 4 spaces indentation
Message-Id: <3DDE42CB.415D34CD@saicmodis.com>
Hi,
My colleague uses emacs and had hard time to modify Perl program with 2 spaces
indentation. He told me that 4 spaces indentation is standard for Perl and the
tab in
emacs will do that automatically. However, I'm a vi user, don't use tab (may be
expanded
to different number of spaces on different editors), prefer with 2 spaces
indentation
(to save stroke and line spaces).
Any comment why 4 spaces indentation is standard or better than 2 spaces for
Perl ?
Thanks.
Gary
------------------------------
Date: Fri, 22 Nov 2002 14:56:34 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: comment on 2 or 4 spaces indentation
Message-Id: <arlgj2$t4d$1@korweta.task.gda.pl>
In article <3DDE42CB.415D34CD@saicmodis.com>, Gary Fu wrote:
> Hi,
>
> My colleague uses emacs and had hard time to modify Perl program with 2 spaces
> indentation. He told me that 4 spaces indentation is standard for Perl and the
In that case your colleague is an idiot. You can quote me on that.
> tab in
> emacs will do that automatically. However, I'm a vi user, don't use tab (may be
> expanded
> to different number of spaces on different editors), prefer with 2 spaces
> indentation
> (to save stroke and line spaces).
> Any comment why 4 spaces indentation is standard or better than 2 spaces for
> Perl ?
There is no such standard.
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Fri, 22 Nov 2002 15:09:26 -0000
From: "Kevin Brownhill" <BROWNHIK@Syntegra.Bt.Co.Uk>
Subject: Re: comment on 2 or 4 spaces indentation
Message-Id: <arlhn4$bi9$1@pheidippides.axion.bt.co.uk>
"Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
message news:arlgj2$t4d$1@korweta.task.gda.pl...
> In article <3DDE42CB.415D34CD@saicmodis.com>, Gary Fu wrote:
> > Hi,
> >
> > My colleague uses emacs and had hard time to modify Perl program with 2
spaces
> > indentation. He told me that 4 spaces indentation is standard for Perl
and the
>
>
> In that case your colleague is an idiot. You can quote me on that.
>
>
> > tab in
> > emacs will do that automatically. However, I'm a vi user, don't use tab
(may be
> > expanded
> > to different number of spaces on different editors), prefer with 2
spaces
> > indentation
> > (to save stroke and line spaces).
> > Any comment why 4 spaces indentation is standard or better than 2 spaces
for
> > Perl ?
>
>
> There is no such standard.
>
>
> Cheers,
> Bernard
perlstyle - the Perl style guide recommends:
Regarding aesthetics of code lay out, about the only thing Larry cares
strongly about is that the closing curly bracket of a multi-line BLOCK
should line up with the keyword that started the construct. Beyond that, he
has other preferences that aren't so strong:
·
4-column indent.
·
Opening curly on same line as keyword, if possible, otherwise line up.
·
Space before the opening curly of a multi-line BLOCK.
etc, etc, etc....
------------------------------
Date: Fri, 22 Nov 2002 10:12:19 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Gary Fu <gfu@saicmodis.com>
Subject: Re: comment on 2 or 4 spaces indentation
Message-Id: <Pine.A41.3.96.1021122101054.104578A-100000@cortez.sss.rpi.edu>
[posted & mailed]
On Fri, 22 Nov 2002, Gary Fu wrote:
>My colleague uses emacs and had hard time to modify Perl program with 2
>spaces indentation. He told me that 4 spaces indentation is standard for
>Perl and the tab in emacs will do that automatically. However, I'm a vi
>user, don't use tab (may be expanded to different number of spaces on
>different editors), prefer with 2 spaces indentation (to save stroke and
>line spaces). Any comment why 4 spaces indentation is standard or better
>than 2 spaces for Perl ?
Bah. The only standards you need are your own. Meaning, BE CONSISTENT in
your coding style. It's ok if it evolves over time, but don't do weird
stuff like
if( condition ){
this;
that;}
elsif (this) {
other stuff;
}
else
{
print;
}
Pick a style and use it.
I use two-space indents, because I don't want my code to run off the edge
of the screen. ;)
--
Jeff "japhy" Pinyan RPI Acacia Brother #734 2002 Acacia Senior Dean
"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: Fri, 22 Nov 2002 16:14:05 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: comment on 2 or 4 spaces indentation
Message-Id: <newscache$hzgz5h$ll8$1@news.emea.compuware.com>
Gary Fu wrote (Friday 22 November 2002 15:44):
> Hi,
>
> My colleague uses emacs and had hard time to modify Perl program with 2
> spaces
He should widen his view then.
> indentation. He told me that 4 spaces indentation is standard for
> Perl
I don't even know what the "Koos Pol" standard is. My editor does all
that for me. And as it does that farely well, I have never
needed to count them.
> and the tab in
> emacs will do that automatically.
Cool! My editor does that too!
> However, I'm a vi user, don't use tab
> (may be expanded
> to different number of spaces on different editors), prefer with 2 spaces
> indentation
> (to save stroke and line spaces).
Good for you! Keep vi'ing (masochist :-))
> Any comment why 4 spaces indentation is standard or better than 2 spaces
> for Perl ?
Perlhaps for the eyes. But I would argue that it is a tasty matter.
> Thanks.
>
> Gary
--
KP
------------------------------
Date: 22 Nov 2002 16:31:20 GMT
From: ctcgag@hotmail.com
Subject: Re: comment on 2 or 4 spaces indentation
Message-Id: <20021122113120.447$gh@newsreader.com>
Gary Fu <gfu@saicmodis.com> wrote:
> Hi,
>
> My colleague uses emacs and had hard time to modify Perl program with 2
> spaces indentation. He told me that 4 spaces indentation is standard for
> Perl and the tab in
> emacs will do that automatically. However, I'm a vi user, don't use tab
> (may be expanded
> to different number of spaces on different editors), prefer with 2 spaces
> indentation
> (to save stroke and line spaces).
> Any comment why 4 spaces indentation is standard or better than 2 spaces
> for Perl ?
4 spaces is better because it makes it very obvious what level of
indentation you are on. 2 spaces can be hard to visually align over a
large page of text. 2 spaces is better because 4 spaces per indent often
leaves you with very little line left to code on if code is highly nested,
which is common. Line wrap is ugly.
I find the line wrap problem more severe than the alignment problem,
so I use usually use 2 spaces.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Fri, 22 Nov 2002 16:49:45 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: comment on 2 or 4 spaces indentation
Message-Id: <JetD9.66$Ho2.38@nwrddc04.gnilink.net>
Gary Fu wrote:
> My colleague uses emacs and had hard time to modify Perl program with
> 2 spaces indentation. He told me that 4 spaces indentation is
> standard for Perl and the tab in
> emacs will do that automatically. However, I'm a vi user, don't use
> tab (may be expanded
> to different number of spaces on different editors), prefer with 2
> spaces indentation
> (to save stroke and line spaces).
> Any comment why 4 spaces indentation is standard or better than 2
> spaces for Perl ?
In the very old days for C or Fortran programs 8 characters were used
because that's what typewriters used to do.
Then people began to notice that code tended to run off the right edge of
the screen and with the advance of better editors they decided that probably
a tab stop every 4 coloumns would be better.
Some people say that's still too much, their programs still run off the
right edge. I think in that case they should use a sub function and divide
the function into two. But that's just my personal feeling.
As with emacs luckily emacs is even smarter than that. It will automatically
indent a line when you hit <enter> to move to the next line, so you don't
ever have to type any indentation yourself, neither spaces nor tab. A very
valuable help to find unbalanced quotes or brackets or forgotten semicolons
or ....
And of course, emacs being what it is, the amount of the indentation can be
configured (sorry, you will have to look up the variable name yourself).
But the cherry on top of the cream pie is that emacs has a whole bunch of
"indent-" functions, including "indent-region". That means if you are not
happy with the current indentation then just let emacs fix it for you to
your preference.
jue
------------------------------
Date: Fri, 22 Nov 2002 18:25:14 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: disambiguating print (was Re: Basic syntax question on using arrays returned from function)
Message-Id: <3DDE70E9.6802D484@acm.org>
Tad McClellan wrote:
> I feel it is much easier to remember (and to recall) if I
> just choose to put parens around my arg list in the few
> cases where I otherwise have the above pattern that
> triggers guessing by the parser:
>
> print( (), ... ); # now the guess turns out to be what I intended
I still find it confusing that this doesn't work as I expect if the first
argument is a function call that the parser doesn't know about yet. In
other words, given
perl -we "print (foo ('x')); sub foo {'Hi'}"
the parser still thinks that foo is meant to be a filehandle, while
perl -we "print +(foo ('x')); sub foo {'Hi'}"
works as I intended, as do all of:
perl -we "sub foo {'Hi'} print foo ('x');"
perl -we "print +foo ('x'); sub foo {'Hi'}"
perl -we "print &foo ('x'); sub foo {'Hi'}"
perl -we "print foo('x'); sub foo {'Hi'}"
Note the lack of whitespace after the first "foo" in that last one.
I understand why this is, but that doesn't mean I have to like it...
Would it break things horribly if print(f) worked as follows?
print LIST # OK
print (LIST) # OK
print FILEHANDLE LIST # OK
print FILEHANDLE (LIST) # OK
print {BLOCK} LIST # OK (BLOCK returns filehandle)
print {BLOCK} (LIST) # OK (BLOCK returns filehandle)
print (FILEHANDLE LIST) # disallowed, FILEHANDLE treated as the first
# part of the LIST, with the usual syntax rules
-- Dave Tweed
------------------------------
Date: Fri, 22 Nov 2002 18:42:19 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: disambiguating print (was Re: Basic syntax question on using arrays returned from function)
Message-Id: <Xns92CE8B6B5704Cdkwwashere@216.168.3.30>
Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com> wrote on 22 Nov
2002:
[ using print +( ... ) ]
>
> Truth be told Tad, I actuallay never have seen it implemented that
> way or used it myself either. But is saw it in the docs as a
> alternative. So I thought, what the heck, "Go ahead, make my
> post..." And I just knew clpm would be *all* over me for posting
> weird stuff :-) Thanks for the excellent clarification.
The only place I've actually seen it used was in one of Randal
Schwartz' articles on his web site. (but of course) It sent me
scurrying to the docs to figure out what the hell he was doing.
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Fri, 22 Nov 2002 15:39:26 GMT
From: echang@netstorm.net (ebchang)
Subject: Re: Format a one line file to get two columns
Message-Id: <Xns92CE6C75AB2FCechangnetstormnet@207.106.93.86>
"David K. Wall" <usenet@dwall.fastmail.fm> wrote in
<Xns92CDAA18522DCdkwwashere@216.168.3.30>:
>I put that 2.71828 in there make the number of parts odd. (e is a bit
>"odd", isn't it? :-)
I'd say e transcends such notions as even or odd, though it's a natural
mistake to think they seem integral to all numbers. Or is that not rational
in the real world? These complex notions are beyond me.
--
EBC
------------------------------
Date: Fri, 22 Nov 2002 16:12:53 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Format a one line file to get two columns
Message-Id: <Xns92CE721578D46dkwwashere@216.168.3.30>
John W. Krahn <krahnj@acm.org> wrote on 21 Nov 2002:
> "David K. Wall" wrote:
>>
>> Here's a longer way that that doesn't slurp the whole file.
>>
>> Yeah, the OP said it was all on one line, but I was pleased with
>> this idea. I'm sure it's much slower than your way (all that
>> splitting, pushing, and shifting), but for a large file with lots
>> of relatively short lines it uses less memory, right?
>
> Ah, but if it _is_ all on one line then undefining $/ is redundant
> and your method would read the whole file as well.
Oh, granted -- I was just pleased to find One More Way To Do It. :-)
> This will only read blocks of 1K
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> $/ = \1024;
That's a feature of $/ I hadn't noticed before. I'll have to
remember it. What's the advantage over sysread()?
> while ( <> ) {
> s/\s+/--$| ? ' ' : "\n"/eg;
> s/\D*\z/\n/ if eof ARGV;
> print;
> }
>
> __END__
Very clever. I like that much better than my little kluge or even
the slurping way.
I just had to play with it a little and get $| out of it. Switching
the flushing on and off like that bothers me somehow.
my $flipflop = 0;
while ( <> ) {
s/\s+/($flipflop = ++$flipflop % 2) ? ' ' : "\n"/eg;
s/\S*\z/\n/ if eof ARGV;
print;
}
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Fri, 22 Nov 2002 17:26:56 GMT
From: Fred <No_Mail_Address@cox.net>
Subject: Re: Missing ..\Perl\lib\auto\Mail\Internet\autosplit.ix
Message-Id: <3DDE691D.6D8AEBA@cox.net>
Benjamin Goldberg wrote:
>
> Fred wrote:
> >
> > I am trying to use MIME::Parser in Win98SE in a script.
> > But I get an error
> >
> > "Cant' locate auto/Mail/Internet/autosplit.ix in @inc"
> > at C:/../Perl/lib/Autoloader.pm line 146
> > at C:/../Perl/lib/Mail/Internet.pm line 14
> >
> > Execution is not aborted.
> >
> > I cannot find auto/Mail/Internet/autosplit.ix anywhere on
> > http://www.activestate.com/ or on http://cpan.valueclick.com/modules/
> > or with Google-search.
>
> This is because auto/.../autosplit.ix is a file created when you run the
> installation procedudure for the Mail-Internet. If you had properly
> installed that distribution (using the 'install' command from any of
> PPM, or the CPAN shell, or the CPANPLUS shell), then the file would
> exist.
>
Thank you. All OK after a proper install.
--- Fred
------------------------------
Date: 22 Nov 2002 07:53:42 -0800
From: stephen.wylie@xko.co.uk (Stephen Wylie)
Subject: multiple processes accessing a named pipe
Message-Id: <31b7fc43.0211220753.529a8f2c@posting.google.com>
What happens when two processes write to a named pipe?
My reader is printing the stuff to a network terminal server with
serial printer attached, it does:
while () {
#blocks til someone writes to it
open (FIFO, $Fifo) or die "cannot open fifo $!";
$Message = <FIFO>;
while () {
$Reply = '';
socket(TO_SERVER, PF_INET, SOCK_STREAM, getprotobyname('tcp'))
or die "cannot create socket $!\n";
$IPadd = inet_aton($Host) or die "cannot resolve host\n";
$IPpacked = sockaddr_in($Port, $IPadd)or die "cannot create
packed host\n";
connect(TO_SERVER, $IPpacked) or die "cannot connect to server
$!\n";
$OldDefault = select(TO_SERVER);
$| = 1;
select ($OldDefault);
print TO_SERVER $Message or die "cannot write to $Host:$Port\n";
eval {
$Reply = '';
local $SIG{__DIE__} = 'IGNORE';
$SIG{ALRM} = sub {die "read timed out\n";};
alarm ($Timeout);
$Reply = <TO_SERVER>;
alarm (0);
};
if ($@) {print LOGFILE "$@";}
if ($Reply =~ m/Selected hunt group busy/) {
$Time = localtime(time);
close (TO_SERVER);
sleep (30);
next;
}
while ($Message = <FIFO>) {
print TO_SERVER $Message or die "failed writing to specialix
$!";
}
close (TO_SERVER);
close FIFO;
last;
}
}
I've removed bits of logging and stuff for succinctness. It's printing
to a serial port terminal server over the network.
I've tried to follow the Perl Cookbook. But I'm not sure what will
happen when I do close FIFO after the while loop gets the EOF from the
first process exitting. Could this SIGPIPE both writing processes? Is
there a better way?
The 'hunt group' message is due to the dotty behaviour of the terminal
server! It's weird but seems reliable, problems occur only when many
people print in quick succession on one machine, the mechanism handles
people printing simultaneously from more than one machine OK.
The printing to the FIFO is done by the AIX enqueuing system, which
spawns a separate process for each print request.
TIA,
Steve
------------------------------
Date: 22 Nov 2002 17:29:37 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: multiple processes accessing a named pipe
Message-Id: <u9adk1qzr2.fsf@wcl-l.bham.ac.uk>
stephen.wylie@xko.co.uk (Stephen Wylie) writes:
> What happens when two processes write to a named pipe?
This is a question about your OS not Perl.
> But I'm not sure what will happen when I do close FIFO after the
> while loop gets the EOF from the first process exitting.
The reader of a FIFO doesn't get EOF until all writers close.
> Could this SIGPIPE both writing processes?
IMHO what should happen is that once all writers have closed and thus
an EOF condition exists for any existing readers then any new writers
should hang on open() until a new reader comes along. This would mean
nobody would get a SIGPIPE. Unfortunately on one Unix-like OS I have
to hand (Linux) this isn't how it works.
This is purely a question about named pipe semantics - it has nothing
to do with Perl. Unfortunately The Single UNIX Specification, Version
2 doesn't seem to define FIFO behaviour to this degree of detail.
Best bet - have the reader process hold a writer FD on the FIFO too.
That way you never get any EOF conditions.
BTW: Did I mention this has nothing to do with Perl?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 22 Nov 2002 17:00:24 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: OT: Tabs in vi (was: comment on 2 or 4 spaces indentation)
Message-Id: <arlnr8$clq$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Gary Fu:
> My colleague uses emacs and had hard time to modify Perl program with
> 2 spaces indentation. He told me that 4 spaces indentation is
> standard for Perl and the tab in emacs will do that automatically.
> However, I'm a vi user, don't use tab (may be expanded to different
> number of spaces on different editors), prefer with 2 spaces
> indentation (to save stroke and line spaces).
You can actually tell vi (or at least vim which most people mean anyway
when mentioning vi) to replace a <TAB> with the number of spaces you
prefer. I have in my vimrc:
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set smarttab
I had the same problem with my edited files: They looked odd on other
editors or in viewcvs while now they look exactly as in vim everywhere.
> Any comment why 4 spaces indentation is standard or better than 2 spaces for
> Perl ?
It's a compromise between readability (4 spaces is more readable than 2,
8 probably more than 4) and available space on your screen. I started
with 8 spaces then changed to 4. I think the available line-length,
though, affects your coding-style as well. The less you have for each
line the more you break statements apart which some might find more
readable. If you have long lines you start doing things like this:
@list = map { ... } grep { /.../ && ! /:::/ } reverse sort { ... } @list;
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Fri, 22 Nov 2002 17:46:45 +0000 (UTC)
From: Pierre Asselin <pa@panix.com>
Subject: Perl/Tk install directories
Message-Id: <arlqi2$o8l$1@reader1.panix.com>
I noticed that Perl/Tk 800.024 tries to install in /usr/local/lib/*
instead of /usr/local/lib/perl5/* like the other CPAN modules. Is
this intentional?
For what it's worth, forcing the install to lib/perl5/* produces a
perfectly functional module.
------------------------------
Date: Sat, 23 Nov 2002 02:53:43 +0800
From: "Kurt Gong" <gongwm@163.net>
Subject: Re: Perl/Tk install directories
Message-Id: <arluea$18ia$2@mail.cn99.com>
Pierre Asselin <pa@panix.com> wrote in message
news:arlqi2$o8l$1@reader1.panix.com...
> I noticed that Perl/Tk 800.024 tries to install in /usr/local/lib/*
> instead of /usr/local/lib/perl5/* like the other CPAN modules. Is
> this intentional?
>
> For what it's worth, forcing the install to lib/perl5/* produces a
> perfectly functional module.
>
------------------------------
Date: Fri, 22 Nov 2002 10:25:51 -0600
From: "NeTedix" <tedtdhoang@hotmail.com>
Subject: print the next 5 lines
Message-Id: <D904076907AEC790.DFB718B72EAE2A57.D44C8122E95B3225@lp.airnews.net>
Hi,
I'm new with Perl and need your help.
Please give me an example how to print the next 5 lines after matching a
variable from stdin. Here is an example:
std-input:
1
2
3
4
5
6
7
8
9
I search for number 3 and print the next 5 lines after that. I wish to have
a result:
3
4
5
6
7
8
Thanks in advance,
TH
------------------------------
Date: Fri, 22 Nov 2002 16:41:42 GMT
From: Ian.H <ian@WINDOZEdigiserv.net>
Subject: Re: print the next 5 lines
Message-Id: <v9nstu8onn8ei8siruc5bvddj2pmi2sk8j@4ax.com>
Keywords: Remove WINDOZE to reply
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In a fit of excitement on Fri, 22 Nov 2002 10:25:51 -0600, "NeTedix"
<tedtdhoang@hotmail.com> managed to scribble:
> Hi,
> I'm new with Perl and need your help.
> Please give me an example how to print the next 5 lines after
> matching a variable from stdin. Here is an example:
> std-input:
> 1
[...]
> 8
> 9
>
> I search for number 3 and print the next 5 lines after that. I wish
> to have a result:
> 3
[...]
> 8
What code have you tried? what/where have you searched for research?
$stdin_value = 3;
for ($stdin_value..($stdin_value + 5)) {
print $_ . "\n";
}
I'll leave you to research on how to get teh $stdin_value frm the
commandline rather than hardcoded.
HTH.
Regards,
Ian
-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3
iQA/AwUBPd5ejmfqtj251CDhEQIyBgCgpZ2xgifnZyh6T125EG0ztFP/V9oAoK7W
8ngXsuCoagaV8SPCbKkuOsi8
=wWEP
-----END PGP SIGNATURE-----
--
Ian.H (Design & Development)
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Scripting, Web design, development & hosting.
------------------------------
Date: Fri, 22 Nov 2002 10:54:06 -0600
From: "NeTedix" <tedtdhoang@hotmail.com>
Subject: Re: print the next 5 lines
Message-Id: <2FCF2F8DB11D2ECA.8560085AF21D4B63.DE2E9054F3A61C1D@lp.airnews.net>
Hi Ian,
I mean the next 5 lines not 5 numbers. Sorry for my example isn't clear. Let
me give you another ex.
Dallas
San Jose
Austin
NewYork
Houston
Baltimore
New Jersey
London
Bangkok
Paris
Clinton
Bush
Gore
I search for Austin and print the next 5 lines. Here is the expected reult:
Austin
NewYork
Houston
Baltimore
New Jersey
London
Thanks,
TH
"Ian.H" <ian@WINDOZEdigiserv.net> wrote in message
news:v9nstu8onn8ei8siruc5bvddj2pmi2sk8j@4ax.com...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> In a fit of excitement on Fri, 22 Nov 2002 10:25:51 -0600, "NeTedix"
> <tedtdhoang@hotmail.com> managed to scribble:
>
> > Hi,
> > I'm new with Perl and need your help.
> > Please give me an example how to print the next 5 lines after
> > matching a variable from stdin. Here is an example:
> > std-input:
> > 1
> [...]
> > 8
> > 9
> >
> > I search for number 3 and print the next 5 lines after that. I wish
> > to have a result:
> > 3
> [...]
> > 8
>
> What code have you tried? what/where have you searched for research?
>
> $stdin_value = 3;
>
> for ($stdin_value..($stdin_value + 5)) {
> print $_ . "\n";
> }
>
>
> I'll leave you to research on how to get teh $stdin_value frm the
> commandline rather than hardcoded.
>
> HTH.
>
>
> Regards,
>
> Ian
>
> -----BEGIN xxx SIGNATURE-----
> Version: PGP Personal Privacy 6.5.3
>
> iQA/AwUBPd5ejmfqtj251CDhEQIyBgCgpZ2xgifnZyh6T125EG0ztFP/V9oAoK7W
> 8ngXsuCoagaV8SPCbKkuOsi8
> =wWEP
> -----END PGP SIGNATURE-----
>
> --
> Ian.H (Design & Development)
> digiServ Network - Web solutions
> www.digiserv.net | irc.digiserv.net | forum.digiserv.net
> Scripting, Web design, development & hosting.
------------------------------
Date: Fri, 22 Nov 2002 11:14:28 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: print the next 5 lines
Message-Id: <slrnatspfk.47g.tadmc@magna.augustmail.com>
NeTedix <tedtdhoang@hotmail.com> wrote:
> Please give me an example how to print the next 5 lines after matching a
> variable from stdin.
while ( <STDIN> ) {
next unless /^$ARGV[0]$/;
print;
print scalar <STDIN> for 1..5;
last;
}
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 22 Nov 2002 17:38:47 GMT
From: Ian.H <ian@WINDOZEdigiserv.net>
Subject: Re: print the next 5 lines
Message-Id: <mppstu0omdf49i7t2u8hl1ln29c5tishjf@4ax.com>
Keywords: Remove WINDOZE to reply
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In a fit of excitement on Fri, 22 Nov 2002 10:54:06 -0600, "NeTedix"
<tedtdhoang@hotmail.com> managed to scribble:
> Hi Ian,
> I mean the next 5 lines not 5 numbers. Sorry for my example isn't
> clear. Let me give you another ex.
> Dallas
[...]
> Gore
>
> I search for Austin and print the next 5 lines. Here is the expected
> reult: Austin
> NewYork
> Houston
> Baltimore
> New Jersey
> London
>
> Thanks,
Fair enough. Have you had any thoughts as to what you might do even
from the example I've shown already?
You need to specify more information to get a sensible answer I think.
Such as "is the list being held in an array?" "is the list being held
in a file or database?"
Regards,
Ian
-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3
iQA/AwUBPd5r9Gfqtj251CDhEQJGngCg3ijb5yDINYByigiogCPB9F3qFh4AnRUp
VMw344jW+axWVBpq7w+V9w+t
=wngz
-----END PGP SIGNATURE-----
--
Ian.H (Design & Development)
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Scripting, Web design, development & hosting.
------------------------------
Date: 22 Nov 2002 17:40:50 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: print the next 5 lines
Message-Id: <u93cptqz8d.fsf@wcl-l.bham.ac.uk>
"NeTedix" <tedtdhoang@hotmail.com> is a rude/ignorant person who
writes TOFU:
> I mean the next 5 lines not 5 numbers. Sorry for my example isn't clear. Let
> me give you another ex.
> Dallas
> San Jose
> Austin
> NewYork
> Houston
> Baltimore
> New Jersey
> London
> Bangkok
> Paris
> Clinton
> Bush
> Gore
>
> I search for Austin and print the next 5 lines. Here is the expected reult:
> Austin
> NewYork
> Houston
> Baltimore
> New Jersey
> London
my $counter;
while (<>) {
$counter = 6 if /^Austin$/;
print if $counter-- > 0;
}
BTW: Please cut the TOFU - it is very rude. Very rude people soon
find that some of the most knowledgible people stop trying to help
them.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
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 4161
***************************************