[25972] in Perl-Users-Digest
Perl-Users Digest, Issue: 8191 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 22 09:05:36 2005
Date: Wed, 22 Jun 2005 06:05:06 -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 Wed, 22 Jun 2005 Volume: 10 Number: 8191
Today's topics:
Re: [OT] Re: "use CGI " hangs "CGI time out " <bart.lateur@pandora.be>
Re: [OT] Re: "use CGI " hangs "CGI time out " <tassilo.von.parseval@rwth-aachen.de>
Re: [OT] Re: "use CGI " hangs "CGI time out " <bart.lateur@pandora.be>
Activestate: how to read from a file or default to STDI <lawshouse.public@btconnect.com>
Re: Activestate: how to read from a file or default to (Anno Siegel)
Re: Activestate: how to read from a file or default to <lawshouse.public@btconnect.com>
Re: what's the right way to encode this? <sun_tong@users.sourceforge.net>
Re: what's the right way to encode this? <do-not-use@invalid.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 22 Jun 2005 07:47:07 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: [OT] Re: "use CGI " hangs "CGI time out "
Message-Id: <rg5ib1tb3f3sp59osft9i9pmsi0oll5d6j@4ax.com>
Eric Bohlman wrote:
>"int *a, b;" reads to me unambiguously as "both the
>thingy a points to and b are integers" without implying that b is a
>pointer.
You've gotten used to it, then.
The you can declare both a pointer and an integer in the same combined
line is, IMHO, a major design flaw in C. Delaring an integer and a
pointer to an integer are two totally dissimilar tasks. Less similar
than declaring a double and an integer, and you can't combine those two
declarations.
--
Bart.
------------------------------
Date: Wed, 22 Jun 2005 10:14:25 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: [OT] Re: "use CGI " hangs "CGI time out "
Message-Id: <slrndbi7f1.1p7.tassilo.von.parseval@localhost.localdomain>
Also sprach Bart Lateur:
> Eric Bohlman wrote:
>
>>"int *a, b;" reads to me unambiguously as "both the
>>thingy a points to and b are integers" without implying that b is a
>>pointer.
>
> You've gotten used to it, then.
>
> The you can declare both a pointer and an integer in the same combined
> line is, IMHO, a major design flaw in C. Delaring an integer and a
> pointer to an integer are two totally dissimilar tasks. Less similar
> than declaring a double and an integer, and you can't combine those two
> declarations.
Strictly speaking, C doesn't say: "Variable p is of type 'pointer to
int'". Instead it says: "Variable p, when dereferenced, is an int".
That's why the dereference operator is used for declaring pointers:
int *p;
Hence your analogy to declaring both a double and and int in the same
statement is not applicable. In:
int a, *p;
both 'a' and '*p' are integers.
Tassilo
--
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
------------------------------
Date: Wed, 22 Jun 2005 09:01:31 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: [OT] Re: "use CGI " hangs "CGI time out "
Message-Id: <56aib1tlo2dbgur5jokbt4n9s4afv4srm8@4ax.com>
Tassilo v. Parseval wrote:
>Hence your analogy to declaring both a double and and int in the same
>statement is not applicable. In:
>
> int a, *p;
>
>both 'a' and '*p' are integers.
But it doesn't declare *p, it declares p. That's what it's for. *p does
actually even exist yet, as p is NULL.
--
Bart.
------------------------------
Date: Wed, 22 Jun 2005 13:00:35 +0100
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Activestate: how to read from a file or default to STDIN
Message-Id: <1mkib1honfsaqtg9pb95hs6gfqbcqaggt8@4ax.com>
(Googled a lot for this without success; a good search string eluded
me).
I have a Perl program running under ActiveState Perl which needs to
read in a number of control statements before it gets to work. I want
to be able to specify the name of the file containing the control
statements (myprog.pl -f filename), but have it default to STDIN if no
name is supplied (myprog.pl). I can't find a neat way of coding it.
This works (aside from an ActiveState problem I'll come to):
#! C:\Perl\bin\Perl.exe
use strict;
use warnings;
use Getopt::Std;
our $opt_f;
getopts('f:');
my @control_commands;
if (defined $opt_f) {
open (COMMANDS,$opt_f) or
die "Couldn't open command file '$opt_f'$!";
@control_commands = <COMMANDS>;
} else {
print "Enter control commands, Ctrl-D to finish:";
@control_commands = <STDIN>; # See problem described later
}
print for (@control_commands);
__END__
But it requires me to slurp the whole control file in at one go; there
won't ever be more than a dozen or so statements so it'll work OK, but
it's inelegant. What I'd like to do is (lapsing into pseudocode here
and there as I really can't work out how to code this ...)
if (defined $opt_f) {
open ($file_handle,$opt_f) or
die "Couldn't open command file '$opt_f'$!";
} else {
open ($file_handle,STDIN); # doesn't compile
}
while (my $command = <$file_handle> ) {
do_stuff_with_single_command;
}
... there must be a "usual" way of doing this; could someone point me
in the right direction?
In passing, I can't find the ActiveState equivalent of Ctrl-D to
terminate STDIN - and it's not in the html manual as far as I can see.
Can someone help with that?
--
Henry Law <>< Manchester, England
------------------------------
Date: 22 Jun 2005 12:39:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Activestate: how to read from a file or default to STDIN
Message-Id: <d9bm5g$nn8$1@mamenchi.zrz.TU-Berlin.DE>
Henry Law <news@lawshouse.org> wrote in comp.lang.perl.misc:
> (Googled a lot for this without success; a good search string eluded
> me).
>
> I have a Perl program running under ActiveState Perl which needs to
> read in a number of control statements before it gets to work. I want
> to be able to specify the name of the file containing the control
> statements (myprog.pl -f filename), but have it default to STDIN if no
> name is supplied (myprog.pl). I can't find a neat way of coding it.
>
> This works (aside from an ActiveState problem I'll come to):
>
> #! C:\Perl\bin\Perl.exe
> use strict;
> use warnings;
>
> use Getopt::Std;
> our $opt_f;
> getopts('f:');
> my @control_commands;
>
> if (defined $opt_f) {
> open (COMMANDS,$opt_f) or
> die "Couldn't open command file '$opt_f'$!";
> @control_commands = <COMMANDS>;
> } else {
> print "Enter control commands, Ctrl-D to finish:";
> @control_commands = <STDIN>; # See problem described later
> }
>
> print for (@control_commands);
> __END__
>
> But it requires me to slurp the whole control file in at one go; there
> won't ever be more than a dozen or so statements so it'll work OK, but
> it's inelegant. What I'd like to do is (lapsing into pseudocode here
> and there as I really can't work out how to code this ...)
>
> if (defined $opt_f) {
> open ($file_handle,$opt_f) or
> die "Couldn't open command file '$opt_f'$!";
> } else {
> open ($file_handle,STDIN); # doesn't compile
> }
>
> while (my $command = <$file_handle> ) {
> do_stuff_with_single_command;
> }
>
> ... there must be a "usual" way of doing this; could someone point me
> in the right direction?
You would use a "lexical filehandle". In the case of a specified
file, you get it through open. If you need STDIN, you can assign
a globref to STDIN, which works as a filehandle through magic.
use Getopt::Std;
getopts( 'f:', \ my %opt); # I prefer a single lexical hash
my $fh;
if (defined $opt{ f}) {
open ( $fh, $opt{ f}) or
die "Couldn't open command file '$opt{ f}'$!";
} else {
print "Enter control commands, Ctrl-D to finish:";
$fh = \ *STDIN;
}
my @control_commands = <$fh>; # could be done line-wise now
__END__
Anno
------------------------------
Date: Wed, 22 Jun 2005 13:53:46 +0100
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: Activestate: how to read from a file or default to STDIN
Message-Id: <smnib15pd39a4hips1ek6lmmk69t8c016r@4ax.com>
On 22 Jun 2005 12:39:12 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:
>You would use a "lexical filehandle". In the case of a specified
>file, you get it through open. If you need STDIN, you can assign
>a globref to STDIN, which works as a filehandle through magic.
Aha ... magic is the bit I need to learn more of!
> my $fh;
> if (defined $opt{ f}) {
> open ( $fh, $opt{ f}) or
> die "Couldn't open command file '$opt{ f}'$!";
> } else {
> print "Enter control commands, Ctrl-D to finish:";
> $fh = \ *STDIN;
...etc. Thank you.
And of course as soon as I'd posted I found a way of googling for the
right way to terminate STDIN on Windows - Ctrl-Z, followed by Enter.
--
Henry Law <>< Manchester, England
------------------------------
Date: Tue, 21 Jun 2005 21:11:38 -0400
From: * Tong * <sun_tong@users.sourceforge.net>
Subject: Re: what's the right way to encode this?
Message-Id: <1119402704.d24d5a591f701b8cad1649704c14e8c6@teranews>
Thanks for the input, I notice that I make a mistake stripping the test
case, I'll post a correct test case which will duplicate the exact result
of my OP.
thanks.
--
Tong (remove underscore(s) to reply)
*niX Power Tools Project: http://xpt.sourceforge.net/
- All free contribution & collection
------------------------------
Date: 22 Jun 2005 09:39:15 +0200
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: what's the right way to encode this?
Message-Id: <yzdslzazvq4.fsf@invalid.net>
* Tong * <sun_tong@users.sourceforge.net> writes:
> µÜÒÝ•"£¨·½
> ^^^^^^^
> Notice the extreme big number pointed by ^^^?
I'm sorry I can't help you with your question, but note that letting
one line to point at another like you do with "^^^^" only works
reliably if both poster and reader use the same font metrics, which in
practice means that only fixed-width font is useful (tabs should be
avoided too). For me, the number pointed out is not 8226, but 183.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8191
***************************************