[18229] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 397 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 2 14:05:39 2001

Date: Fri, 2 Mar 2001 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)
Message-Id: <983559911-v10-i397@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 2 Mar 2001     Volume: 10 Number: 397

Today's topics:
        command line <rafiqmateen@netscape.net>
    Re: command line (Peter L. Berghold)
    Re: command line <godzilla@stomp.stomp.tokyo>
    Re: Convert dates in format "3/1/2001" to dd-Month-yy <wells@cedarnet.org>
        Convert macintosh file to unix <aleister@nomade.fr>
    Re: Convert macintosh file to unix <todd@designsouth.net>
    Re: Convert macintosh file to unix <shanem@ll.mit.edu>
    Re: Display Delay in Perl? (Anno Siegel)
    Re: Display Delay in Perl? (Rafael Garcia-Suarez)
    Re: Display Delay in Perl? (Anno Siegel)
    Re: FAQ 4.61:   How do I reset an each() operation part (Anno Siegel)
    Re: flock and close   with  empty read strangeness (Randal L. Schwartz)
    Re: flock and close   with  empty read strangeness (Anno Siegel)
    Re: flock and close   with  empty read strangeness <godzilla@stomp.stomp.tokyo>
    Re: How the CLPM turns <mischief@velma.motion.net>
    Re: Look at browser-sent request headers with Perl prog (Peter Scott)
    Re: milliseconds (Tad McClellan)
    Re: more regex (Tad McClellan)
    Re: Opening STDERR for input <bernie@fantasyfarm.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 2 Mar 2001 13:37:13 -0500
From: "Rafiq Mateen" <rafiqmateen@netscape.net>
Subject: command line
Message-Id: <97oogu$54g$1@info.usuhs.mil>

I want to use the following command line argument       perl /tmp/html/pl
/tmp/html.fax2.html
inside of another program but I am stuck.  Please help.




------------------------------

Date: Fri, 02 Mar 2001 18:45:03 GMT
From: peter@uboat.berghold.net (Peter L. Berghold)
Subject: Re: command line
Message-Id: <slrn99vqhe.1n3.peter@uboat.berghold.net>

On Fri, 2 Mar 2001 13:37:13 -0500, 
	Rafiq Mateen <rafiqmateen@netscape.net> wrote:
>I want to use the following command line argument       perl /tmp/html/pl
>/tmp/html.fax2.html
>inside of another program but I am stuck.  Please help.
>
>
???? Inside of what kind of program? 

-- 
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           


------------------------------

Date: Fri, 02 Mar 2001 10:58:19 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: command line
Message-Id: <3A9FED4B.D009F354@stomp.stomp.tokyo>

Rafiq Mateen wrote:
 
> I want to use the following command line argument
> perl /tmp/html/pl/tmp/html.fax2.html
> inside of another program but I am stuck.
> Please help.


 * from her Perl Perl Land throne, she motions *
* dismissal with a quick wave of her right hand * 


You have my permission to do this.
You may proceed.

Godzilla!
-- 
@©=(a .. z);@®=qw(7 15 4 26 9 12 12 1 18 15 3 11 19);
$Ñ="\n";srand(time()^($$+($$<<15)));for($§=$®[$®[0]];
$§<$®[2];$§++){sub G{rand($®[8])<$®[4]?"\u$1":"\l$1";}
foreach$¿(@®){$¢=$©[$¿-1];$¢=~s¡([a-z])¡G($1)¡gie;
$Ø="$Ø$¢";}$Ø="$Ø! ";$ø=substr($Ø,$®[12]-$®[11],0," ");
$Ø=~s¯(a)(r)¯$1 $2¯i;push (@Ø,$Ø);}print"$Ñ$ÑC:\\>",
"$©[22]$©[$®[0]]$©[14] $©[$®[8]-$®[7]]o$©[$®[2]/2]ks",
" $©[24]o?$©[$®[8]]";undef$z;$Ø="\b";select$z,$z,$z,.5;
print$Ø;select$z,$z,$z,.5;print$Ø;select$z,$z,$z,.75;
print"$©[$®[12]+$®[7]]";select$z,$z,$z,.75;print"?";
select$z,$z,$z,1;print"$Ñ$Ñ";$Ø=.05;foreach$¡(@Ø)
{@©=split(//,$¡);foreach$§(@©){print$§;select$z,$z,$z,
$Ø;}print$Ñ;}@¶=reverse(@Ø);foreach$¶(@¶){@®=split(//,$¶);
foreach$¢(@®){print$¢;select$z,$z,$z,$Ø;}print $Ñ;}exit;


------------------------------

Date: Fri, 02 Mar 2001 10:20:10 -0600
From: Steve Wells <wells@cedarnet.org>
Subject: Re: Convert dates in format "3/1/2001" to dd-Month-yy
Message-Id: <3A9FC83A.D6918E5E@cedarnet.org>

John Smith wrote:
> 
> Does anyone know the most efficient way to convert dates in the > format "m/d/yyyy" to dd-Month-yy using pattern matching?
> 
> thanks in advance.

How's this?
--------------------
#!/usr/bin/perl -w
use strict;

use constant MONTHS => [qw('' 
             January Feburary March April May June
             July August September October November
             December)];

my $date = "4/1/2001";

print "$date\nconverts to\n";

   my $count = 0;
   $date = join ("-",
                (map !$count++ ? MONTHS->[$_] : /(\d\d)$/,
                  unpack('A2A2A4',
                   sprintf("%02d%02d%04d",
                    split(/\//, $date))))[1,0,2]);

print "$date\n";
-----------------------------------

HTH,
STEVE


------------------------------

Date: Fri, 2 Mar 2001 16:15:32 +0100
From: "TcN" <aleister@nomade.fr>
Subject: Convert macintosh file to unix
Message-Id: <mMOn6.1623$I4.189558@e420r-sjo3.usenetserver.com>

Hello,

I'll try to convert a macintosh text file in Unix Format.
My problem is with the accent (I'm french..sorry ;-)
Do you a script to do that ??

Thanks very much for your help

--
Thierry C




--
Thierry Conesa
DNS - Groupe Dauphiné Libéré

04 76 50 45 62





------------------------------

Date: Fri, 02 Mar 2001 17:53:09 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: Convert macintosh file to unix
Message-Id: <96Rn6.1822$YF4.327773@news1.rdc1.tn.home.com>

open it up with vi in unix and type :set fileformat=unix

(or it might be 'filemode'?)

"TcN" <aleister@nomade.fr> wrote in message
news:mMOn6.1623$I4.189558@e420r-sjo3.usenetserver.com...
> Hello,
>
> I'll try to convert a macintosh text file in Unix Format.
> My problem is with the accent (I'm french..sorry ;-)
> Do you a script to do that ??
>
> Thanks very much for your help
>
> --
> Thierry C
>
>
>
>
> --
> Thierry Conesa
> DNS - Groupe Dauphiné Libéré
>
> 04 76 50 45 62
>
>
>




------------------------------

Date: Fri, 02 Mar 2001 13:03:14 -0500
From: Shane McDaniel <shanem@ll.mit.edu>
Subject: Re: Convert macintosh file to unix
Message-Id: <3A9FE062.78D0AF2C@ll.mit.edu>

Is this a one time only thing or are you trying to write a program to do
it on any text file.  If you just need to convert a single file then you
can just ascii ftp it from the current formatted system to the desired
formated system.  There's also a mac utility, NetStrip I believe, that
will convert unix and dos files to mac.

TcN wrote:
> 
> Hello,
> 
> I'll try to convert a macintosh text file in Unix Format.
> My problem is with the accent (I'm french..sorry ;-)
> Do you a script to do that ??
> 
> Thanks very much for your help
> 
> --
> Thierry C
> 
> --
> Thierry Conesa
> DNS - Groupe Dauphiné Libéré
> 
> 04 76 50 45 62


------------------------------

Date: 2 Mar 2001 14:23:52 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Display Delay in Perl?
Message-Id: <97oado$4gs$1@mamenchi.zrz.TU-Berlin.DE>

According to Martien Verbruggen <mgjv@tradingpost.com.au>:
> On 1 Mar 2001 11:56:26 GMT,
> 	Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> > 
> > Come to think of it, I seem to remember there is a simple way to tell
> > if a builtin can be overridden, short of testing if it works.  Can
> > someone remind me, or am I dreaming?
> 
> > Anno
> 
> End of last year, Tom Christiansen posted an article, with a reference
> to the Cookbook, on how to do that. Interestingly enough, he was
> responding to you, and the question asked was very similar :)

Oh.  That must be why it left any trace at all in my erratic
memory.

I found the cookbook reference.  In essence, it says:
Look into toke.c in the perl source and find if the function
keyword() returns a positive or negative value.  Negative
means it can be overridden, positives can't.

Now this is all well if you *have* the source, but not everybody
does.  Below is a script that retrieves that value from the
living perl.  Note that what was keyword() when the Cookbook was
written is now Perl_keyword().  Note also that the first call
to that script must compile C-code.  This takes some time, and
it will also create a directory named blib_I (usually in your
current directory) for that purpose.

Anno

#!/usr/bin/perl
use strict; use warnings; $| = 1;

print "$_ -> ", keyword( $_), "\n" for qw( open print);

#############################################################

sub keyword {
    my $name = shift;
    get_keyword( $name, length $name);
}

use Inline C => <<'END_OF_CODE';

int get_keyword( char * name, int len) {
    return Perl_keyword( name, len);
}
END_OF_CODE


------------------------------

Date: Fri, 02 Mar 2001 15:04:41 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Display Delay in Perl?
Message-Id: <slrn99vdjm.7n1.rgarciasuarez@rafael.kazibao.net>

Martien Verbruggen wrote in comp.lang.perl.misc:
> On 1 Mar 2001 11:56:26 GMT,
> 	Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> > 
> > Come to think of it, I seem to remember there is a simple way to tell
> > if a builtin can be overridden, short of testing if it works.  Can
> > someone remind me, or am I dreaming?
> 
> > Anno
> 
> End of last year, Tom Christiansen posted an article, with a reference
> to the Cookbook, on how to do that. Interestingly enough, he was
> responding to you, and the question asked was very similar :)

You can also check perldoc -f prototype.
(Nothing's better than a good'ol RTFM.)

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


------------------------------

Date: 2 Mar 2001 15:17:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Display Delay in Perl?
Message-Id: <97odhm$4gs$3@mamenchi.zrz.TU-Berlin.DE>

According to Rafael Garcia-Suarez <rgarciasuarez@free.fr>:
> Martien Verbruggen wrote in comp.lang.perl.misc:
> > On 1 Mar 2001 11:56:26 GMT,
> > 	Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> > > 
> > > Come to think of it, I seem to remember there is a simple way to tell
> > > if a builtin can be overridden, short of testing if it works.  Can
> > > someone remind me, or am I dreaming?
> > 
> > > Anno
> > 
> > End of last year, Tom Christiansen posted an article, with a reference
> > to the Cookbook, on how to do that. Interestingly enough, he was
> > responding to you, and the question asked was very similar :)
> 
> You can also check perldoc -f prototype.
> (Nothing's better than a good'ol RTFM.)

Ah... that's it.   $overridable{ $name} = defined prototype "CORE::$name";

Anno


------------------------------

Date: 2 Mar 2001 18:50:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: FAQ 4.61:   How do I reset an each() operation part-way through?
Message-Id: <97oq17$bpf$2@mamenchi.zrz.TU-Berlin.DE>

According to Uri Guttman  <uri@sysarch.com>:
> >>>>> "RP" == Rudolf Polzer <rpolzer@web.de> writes:
>   RP> PerlFAQ Server <faq@denver.pm.org> schrieb Folgendes:

[interesting stuff snipped]

Allow me a meta-remark:  When this PerlFAQ Server was first
discussed I was rather sceptical, but I'm beginning to like it.
It spawns good thread regularly, which isn't seen often with
an auto-poster.  It serves its purpose to make the FAQ more
present on the group.

Anno, who wouldn'ta thunk


------------------------------

Date: 02 Mar 2001 06:41:06 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <m1bsrks071.fsf@halfdome.holdit.com>

>>>>> "Anno" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

Anno> In fact, I find it impossible to think of a scenario where you
Anno> would *want* to unlock a file at some point and go on using the
Anno> filehandle when the lock was necessary in the first place.  If
Anno> anything, these situations must be pretty peculiar.

It's reasonable when you have a shared file being used repeatedly in a
program, but that's pretty rare.  And you have to take extra
precaution to ensure that your buffers are flushed before you unlock,
and you refresh your buffers after you lock again, or else you get
hosed by things changing out from under you.

Since it's rare, and it's tough, we tend to tell the beginners "just
do this..." for that really common case of "open, lock, update,
close".

print "Just another Perl hacker,";

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: 2 Mar 2001 14:56:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <97ocbf$4gs$2@mamenchi.zrz.TU-Berlin.DE>

According to Randal L. Schwartz <merlyn@stonehenge.com>:
> >>>>> "Anno" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
> 
> Anno> In fact, I find it impossible to think of a scenario where you
> Anno> would *want* to unlock a file at some point and go on using the
> Anno> filehandle when the lock was necessary in the first place.  If
> Anno> anything, these situations must be pretty peculiar.
> 
> It's reasonable when you have a shared file being used repeatedly in a
> program, but that's pretty rare.  And you have to take extra
> precaution to ensure that your buffers are flushed before you unlock,
> and you refresh your buffers after you lock again, or else you get
> hosed by things changing out from under you.

In many of these cases you may still get away with open/locking and
closing the file as needed.  Only if that causes too much overhead
(meaning that the intervals are rather short) you'd want to keep
the file open.  Typically this would be done it the (late) optimizing
phase of a project, not right from the start.

[...]

Anno


------------------------------

Date: Fri, 02 Mar 2001 09:19:05 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <3A9FD609.F27BF5CF@stomp.stomp.tokyo>

Anno Siegel wrote:
 
> Alan J. Flavell wrote:
> > Anno Siegel wrote:
> > > ZepHead wrote:

(snippage)

> In fact, I find it impossible to think of a scenario where you
> would *want* to unlock a file at some point and go on using the
> filehandle when the lock was necessary in the first place.  If
> anything, these situations must be pretty peculiar.


This is a common practice for experienced programmers when
writing high efficiency message boards, threaded boards
and chat line scripts. I have been using this technique
for years. 

Sequence of events is to open a file for read and append.
A partial read of "old" data is perform with a mathematically
based seek and read. A lock is made, new user input data is
appended and the file is unlocked. A 'tail end' seek and read is
performed grabbing new data written by multiple instances
of a program. Finally the file is closed. This allows gathering
of all "new" data written via multiple instances of a program
along with a calculated portion of old data for continuity.
This programming style also allows a user to 'scroll back'
through old data and yet capture new data at the same time.
This is a methodology of taking advantage of a race condition 
which would normally be a problem. This is a methodology of 
creating "real time" conversation via Perl programming.

Michael Fremont of the Internet Roundtable Society, later to
become the WBS chat system, recently taken over by the late
and great Walt Disney, has used this methodolgy as far back
as 1994 - 1995.


Godzilla!
-- 
@©=(a .. z);@®=qw(7 15 4 26 9 12 12 1 18 15 3 11 19);
$Ñ="\n";srand(time()^($$+($$<<15)));for($§=$®[$®[0]];
$§<$®[2];$§++){sub G{rand($®[8])<$®[4]?"\u$1":"\l$1";}
foreach$¿(@®){$¢=$©[$¿-1];$¢=~s¡([a-z])¡G($1)¡gie;
$Ø="$Ø$¢";}$Ø="$Ø! ";$ø=substr($Ø,$®[12]-$®[11],0," ");
$Ø=~s¯(a)(r)¯$1 $2¯i;push (@Ø,$Ø);}print"$Ñ$ÑC:\\>",
"$©[22]$©[$®[0]]$©[14] $©[$®[8]-$®[7]]o$©[$®[2]/2]ks",
" $©[24]o?$©[$®[8]]";undef$z;$Ø="\b";select$z,$z,$z,.5;
print$Ø;select$z,$z,$z,.5;print$Ø;select$z,$z,$z,.75;
print"$©[$®[12]+$®[7]]";select$z,$z,$z,.75;print"?";
select$z,$z,$z,1;print"$Ñ$Ñ";$Ø=.05;foreach$¡(@Ø)
{@©=split(//,$¡);foreach$§(@©){print$§;select$z,$z,$z,
$Ø;}print$Ñ;}@¶=reverse(@Ø);foreach$¶(@¶){@®=split(//,$¶);
foreach$¢(@®){print$¢;select$z,$z,$z,$Ø;}print $Ñ;}exit;


------------------------------

Date: Fri, 02 Mar 2001 17:35:15 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: How the CLPM turns
Message-Id: <t9vmejn83ofgdc@corp.supernews.com>

bernard.el-hagin@gdndev25.dev.lido-tech wrote:
> In article <t9qssmsflc4sb1@corp.supernews.com>, Chris Stith wrote:

> [snip]

[snip]

>>While I'm at it, I'd like to thank Martien, Uri, nobull, Randal,
>>Anno, Abigail, and Ilmari for helping me grow as a Perl programmer.

> The people you mentioned, along with Tad McClellan, Larry Rosler, brian
> d foy, Mark-Jason Dominus, Bart Lateur, and a plethora of others on this
> group are directly responsible for 90% of my Perl knowledge so anytime I
> see someone criticise this newsgroup I just don't get it.

brian d foy, Tad, Larry, MJD, and Bart should be on my list as well. I knew
I'd leave someone out. Ilya should be on my list, too. Larry R. isn't around
much these days, though.

Most of my own learning has been around the posts of Martien, Uri, and Randal,
and Ilmari - just because we tend to end up in the same threads more often.

All these people and many others (sometimes even Kira -- quiet, Uri ;-) have
helped me in one way or another, even if it's only to make me stop to compare
and contrast ideas. The people on the list have done a lot more than that,
though.

I remember in my earlier days of learning Perl, I would search the groups
looking for the names of some of the aforementioned posters as well as Larry
himself (who doesn't seem to post much anywhere these days). Now, if I don't
have a specific question and just want to read some interesting point about
the language or how to use it, I have many names for which to search. I've
noticed a few newer names lately that look very promising, too. 

I post a lot more responses to questions than questions these days, but
mostly because I learn so much from the threads already in place.

Overall, I think the list is done well. It would be nice if it could include
some more of the people on the above list, but I realize the difficulty of
boiling down someone's posting style and keeping it from repeating someone
else's style.

Chris

-- 
Christopher E. Stith
People understand instinctively that the best way for computer programs to
communicate with each other is for each of the them to be strict in what they
emit, and liberal in what they accept. The odd thing is that people themselves
are not willing to be strict in how they speak, and liberal in how they listen.
 -- Larry Wall, 2nd State of the Onion Address, August 1998



------------------------------

Date: Fri, 02 Mar 2001 16:58:52 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Look at browser-sent request headers with Perl program?
Message-Id: <gjQn6.15048$V6.54572@news1.gvcl1.bc.home.com>

In article <97ndd7$lqv$1@news.chatlink.com>,
 "Scuttlebutt" <jbailey@cyberconnect.com> writes:
>How can I see the request headers from a request sent by my browser using
>Perl?  I'd like to recreate a POST request in a Perl program, but seem to be
>missing something (cookie info., hidden fields, ...).

Use LWP to recreate POST requests (perldoc lwpcook).  To see what it's sending/receiving,

	use LWP::Debug qw(+conns);

will print out everything that is transferred across a connection.

-- 
Peter Scott


------------------------------

Date: Fri, 2 Mar 2001 09:19:50 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: milliseconds
Message-Id: <slrn99vb06.oij.tadmc@tadmc26.august.net>

Arthur Wolst <awolst@lodderapplicaties.nl> wrote:

>Is there any other function available to get the exact time values with
>milliseconds?


Perl FAQ, part 8:

   "How can I measure time under a second?"


You are expected to check the Perl FAQ *before* posting to the
Perl newsgroup.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 2 Mar 2001 08:39:34 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: more regex
Message-Id: <slrn99v8km.oij.tadmc@tadmc26.august.net>

Ted Fiedler <tfiedler@zen.moldsandwich.com> wrote:
>I know the values of $line_one ond $line_sixteen are uninitialized, but
>how do I initialize them - I cant use while($line_one=<WEATHERFILE>) {
>so i am curious to see how I would do this - 

   if ( $. == 1 ) {       #   $. is a special varible
      # do line 1 stuff
   }
   elsif ( $. == 16 ) {
      # do line 16 stuff
   }

Perl's special variables are described in:

   perldoc perlvar


>im trying to remove the first
>16 lines of a file...


   while ( <WEATHERFILE> ) {
      print if $. > 16;
   }


>!/usr/bin/perl -w
 ^^
 ^^
Please do not type in code. Use copy/paste or your editor's "import"
function or something, else you'll just get a bunch of wise ass
comments about your typos instead of about your real problem.


>use strict;


Good. Very good.


>my ($info);
>my ($line);
>my ($line_one);
>my ($line_sixteen);


I think it is better practice to declare your variables near
where you use each variable rather than all at the top.


>open (WEATHERFILE, "+<weather.dat")
                     ^
                     ^
>                        || die "cannot open weather.dat\n";


Don't ask for write permission unless you are going to actually
do writing to that filehandle.

You should include the $! special variable in your die() message,
it will help with debugging.


>while ($line=<WEATHERFILE>) {
>        $line =~ s/\*|-//g;


s///g is good for working with strings or patterns, but you are
working with _characters_ there. tr/// is the Right Tool for
that job:

   $line =~ tr/*-//d;  # strip asterisk and hyphen characters
                       # many times faster than s///g


>        $line_one =~ m/welcome to the weather/i;
>        $line_sixteen =~ m/press return for menu/i;


I don't see that you need to do any pattern matching at all to
identify the line. You already said to use line numbers, not the
contents of the line, as the criterion.

If you are really sure that they are always the first 16 lines,
then you do not need to examine the line's content.

In any case, the code above should set off warning bells. A
scalar context pattern match should never be outside of a
conditional of some kind.

The only useful information that a scalar pattern match gives you
is the boolean result ( match/no match ). If you are not examining
that boolean result, then you are doing something wrong (executing
useless statements is "wrong").


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 02 Mar 2001 09:28:37 -0500
From: Bernard Cosell <bernie@fantasyfarm.com>
Subject: Re: Opening STDERR for input
Message-Id: <j4bv9t4g736m74qs4890f7k9gqeor4c282@4ax.com>

On 2 Mar 2001 07:25:02 GMT, ilya@math.ohio-state.edu (Ilya
Zakharevich) wrote:

} [A complimentary Cc of this posting was sent to Bernard Cosell 
} <bernie@fantasyfarm.com>],
} who wrote in article <bi2u9t035rfuia67hg0ia4a3ucn39qrn16@4ax.com>:
} > It is not passing data around inside the program -- it is a relatively
} > standard Unix hack [that I've used before, just never before from
} > Perl] for getting user input when you have a program that is running
} > as a proper filter.  you can't print out prompts and read responses
} > using stdin/stdout else you'll mess up the pipeline, so it was always
} > SOP to use stderr.
} 
} This is what Term::ReadLine is for.  At least you can use it (or just
} the ::Stub part) to get the i/o handles to the TTY.

Probably true, but that really feels like overkill.  It was always
traditional in Unix that STDERR/fd2 would stay pointed at the user's
tty even as stdin and stdout were piped around from here to there.
And beyond that, you can say that that's what Term::ReadLine is for,
but I'd counter and say "That's what /dev/tty is for" --- I remember
back when that was added to Unix *precisely* so that a proc could
easily obtain a path to its controlling TTY.

In the end, I think all of my troubles come down to what I think is a
bug in 5.004 [dunno about 5.6, can't easily check it]: that 
   open (TTY, "+</dev/tty")
doesn't get you a proper read/write stream to the TTY [at least it
doesn't seem to: in every test I tried, I got nothing but errors when
I tried to read from the stream].  If that had worked as I expected
[or its sibling, open (TTY, "+<&2")] then I wouldn't have had a
problem [as it is, it was easy to program around, of course: just use
two streams, one for reading one for writing].

  /Bernie\


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 397
**************************************


home help back first fref pref prev next nref lref last post