[9363] in Perl-Users-Digest
Perl-Users Digest, Issue: 2958 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 24 11:37:24 1998
Date: Wed, 24 Jun 98 07:01:53 -0700
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, 24 Jun 1998 Volume: 8 Number: 2958
Today's topics:
Re: a bit confused about seek <quednauf@nortel.co.uk>
Re: a bit confused about seek <quednauf@nortel.co.uk>
Re: a bit confused about seek (M.J.T. Guy)
Re: a bit confused about seek <tchrist@mox.perl.com>
Re: Changing GID / EGID does *not* work! <rootbeer@teleport.com>
Decoding of data from form (xholf03)
Re: Decoding of data from form <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: Decoding of data from form <quednauf@nortel.co.uk>
Re: Decoding of data from form <rootbeer@teleport.com>
Re: Flames.... (Chris Nandor)
Re: Have we got a good free Perl manual? (Michael J Gebis)
Re: Losing ' round commands (M.J.T. Guy)
Re: Losing ' round commands <rootbeer@teleport.com>
newbie Location: syntax help wanted (Joost Kraaijeveld)
Re: newbie Location: syntax help wanted <rootbeer@teleport.com>
Re: Parsing <tags> chrishabs@my-dejanews.com
Re: Passing a method to another <quednauf@nortel.co.uk>
Re: Passing a method to another <quednauf@nortel.co.uk>
Perl for Win32 and background process (Francois Dagorn)
print <<STRING; <james@soft.net.uk>
Re: print <<STRING; <rootbeer@teleport.com>
Re: print <<STRING; <tchrist@mox.perl.com>
Re: print <<STRING; (Stuart McDow)
Re: print <<STRING; (Tad McClellan)
Re: print and the . operator ?? <eschult.NOSPAM@squonk.net>
Print from Win32 <mosthavm@plcman.siemens.co.uk>
Re: Q:How to flush output in perl? (Jeffrey R. Drumm)
Re: Q:How to flush output in perl? <rootbeer@teleport.com>
Re: Sending files via mail in perl <jdporter@min.net>
Re: Sending files via mail in perl <mosthavm@plcman.siemens.co.uk>
Re: Simple, efficient way of checking whether $VAR is a <tturton@cowboys.anet-dfw.com>
Re: Simple, efficient way of checking whether $VAR is a <jdporter@min.net>
Re: sort getpwent() by group? (Mike Stok)
Re: split(); <barnett@houston.Geco-Prakla.slb.com>
Re: system() and security again <tchrist@mox.perl.com>
Re: system() and security again (M.J.T. Guy)
Re: Testing perl knowledge (Chris Nandor)
Re: What does this error mean? <quednauf@nortel.co.uk>
Re: What does this error mean? <rootbeer@teleport.com>
Re: What does this error mean? (Tad McClellan)
Re: What does this error mean? (Joost Kraaijeveld)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 24 Jun 1998 12:39:16 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: a bit confused about seek
Message-Id: <3590E563.C4E06C5B@nortel.co.uk>
Ah, special thanks to Guy Decoux. Patience is an asset!
------------------------------
Date: Wed, 24 Jun 1998 12:38:08 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: a bit confused about seek
Message-Id: <3590E520.D1A5B431@nortel.co.uk>
Stupido mio, la m... de dios, quelle affrant, damned slow neurones of mine!!!
I got it now. Somehow I was believing that seek would seek for LINES, hitting
the beginning of each line. DOH!
open FILE, "< /u/quednauf/temp/testfile.txt" or die "didn't happen: $!";
for ($i =0; $i <=8; $i++) {
seek FILE, $i, 0 or die "Jumped off the cliff: $!";
print <FILE>;
print "\n";
}
--> TEST FILE <--
012345
--> TEST FILE END <--
Output:
012345
12345
2345
345
45
5
Of course, I say now. Interesting also that seek never dies, say, when you
access a point which is beyond EOF.
Well, it is not so much a problem for the program in which I'd like to use seek,
but out of curiosity. Anyone knows a way to jump to line 21? It looks like there
is no way to do that, apart from maybe running through the file and counting the
occurrences of \n. Hmm...
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: 24 Jun 1998 12:41:15 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: a bit confused about seek
Message-Id: <6mqs5b$c7m$1@pegasus.csx.cam.ac.uk>
F.Quednau <quednauf@nortel.co.uk> wrote:
>
> Interesting also that seek never dies, say, when you
>access a point which is beyond EOF.
That's the Unix file model for you. It just acts as if there were
arbitrarily many zero bytes added to the end of the file.
Mike Guy
------------------------------
Date: 24 Jun 1998 12:42:19 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: a bit confused about seek
Message-Id: <6mqs7b$664$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"F.Quednau" <quednauf@nortel.co.uk> writes:
:Of course, I say now. Interesting also that seek never dies, say, when you
:access a point which is beyond EOF. Well, it is not so much a problem for
:the program in which I'd like to use seek, but out of curiosity. Anyone
:knows a way to jump to line 21? It looks like there is no way to do that,
:apart from maybe running through the file and counting the occurrences
:of \n. Hmm...
The filesystem metadata does not store newline points. There's
nothing you can do.
But you might check the DB_File manpage for its $RECNO bindings.
--tom
--
When the dinosaurs are mating, climb a tree. --Steve Johnson
------------------------------
Date: Wed, 24 Jun 1998 09:39:59 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Changing GID / EGID does *not* work!
Message-Id: <Pine.GSO.3.96.980624023339.16155J-100000@user2.teleport.com>
On Tue, 23 Jun 1998, Matt Murdock wrote:
> I have tried posting on this subject before to no avail.
That sounds as if you're having trouble with your newsreader. :-)
> I have a SUID root CGI script in which the GID and UID are changed to
> the REMOTE_USER's ID. My UID bit works by setting $< and $> to the new
> uid, but changing the GID / EGID does *not* work!
The order of operations is significant. Once you've changed the UID,
you're no longer root. So changing the GID may no longer be possible!
Having said that, there are other things which could be causing the
problem. If this doesn't solve it, you should cook up a short example
(under a dozen or so lines, please), and post it here. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 24 Jun 1998 11:10:53 GMT
From: xholf03@vse.cz (xholf03)
Subject: Decoding of data from form
Message-Id: <6mqmrt$ii4@vse470.vse.cz>
hello,
could you help me with this please? I want to recieve text from form and need
to decode it. Now special symbols are coded like this: %XX.
I thaught that this routine is made for that:
sub decode {
local ($value) = @_;
$value =~ s /\+/ /g;
$value =~ s/%([0-9A-H] {2})/pack('C',hex($1))/eg;
return $value;
}
isn't it? So whats wrong?
Thanks much.
filip
------------------------------
Date: 24 Jun 1998 13:40:47 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Decoding of data from form
Message-Id: <7xlnqn2fk0.fsf@beavis.vcpc.univie.ac.at>
Re: Decoding of data from form, xholf03 <xholf03@vse.cz>
said:
xholf03> hello, could you help me with this please? I want
xholf03> to recieve text from form and need to decode
xholf03> it. Now special symbols are coded like this: %XX.
xholf03> I thaught that this routine is made for that: sub
xholf03> decode { local ($value) = @_; $value =~ s /\+/ /g;
xholf03> $value =~ s/%([0-9A-H] {2})/pack('C',hex($1))/eg;
xholf03> return $value; } isn't it?
Why re-invent the wheel?
use CGI;
all your problems go away,
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/
"You see? You see? Your stupid minds! Stupid! Stupid!" ~ Eros, Plan9 fOS.
------------------------------
Date: Wed, 24 Jun 1998 12:42:29 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Decoding of data from form
Message-Id: <3590E625.C4CEDFD6@nortel.co.uk>
xholf03 wrote:
>
> hello,
> could you help me with this please? I want to recieve text from form and need
> to decode it.
Don't reinvent fire if you can get a combined flame-thrower, toaster and
microwave oven. Use CGI.pm.
------------------------------
Date: Wed, 24 Jun 1998 12:38:06 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Decoding of data from form
Message-Id: <Pine.GSO.3.96.980624053556.16155P-100000@user2.teleport.com>
On 24 Jun 1998, xholf03 wrote:
> I want to recieve text from form and need
> to decode it.
Use a module, such as CGI.pm, to help you decode that. It'll be easier
than using this code...
> sub decode {
> local ($value) = @_;
> $value =~ s /\+/ /g;
> $value =~ s/%([0-9A-H] {2})/pack('C',hex($1))/eg;
> return $value;
> }
...and, besides being easier to use, it does the decoding correctly! :-)
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 24 Jun 1998 12:57:07 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Flames....
Message-Id: <pudge-2406980854210001@dynamic448.ply.adelphia.net>
In article <6mq0gk$aer@newsserver.trl.OZ.AU>,
ac1@fspc.netsys.itg.telecom.com.au (nobody) wrote:
# Are these roman dates correct? I read the following as:
# 1754 September 1993.
use Date::Parse;
use Roman;
print scalar localtime(
str2time(sprintf('Sep 1, %s', arabic('MCMXCIII')))
+ 86400 * arabic('MDCCLIV')
);
__END__
Sun Jun 21 00:00:00 1998
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: 24 Jun 1998 06:18:57 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Have we got a good free Perl manual?
Message-Id: <6mq5oh$q6j@mozo.cc.purdue.edu>
abigail@fnx.com (Abigail) writes:
}Give it up Pudge. Hasn't it been clear to you those GNU/FSF people
}can't read?
Dear Mike Gebis:
This a note to yourself, which you can retrieve via dejanews. The
next time somebody claims that comp.lang.perl.misc doesn't have any
unnecessary flamage, please reference this post. Have a nice day.
--Mike Gebis
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: 24 Jun 1998 12:36:54 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Losing ' round commands
Message-Id: <6mqrt6$c5g$1@pegasus.csx.cam.ac.uk>
Deborah Barclay <barclayd@nortel.ca> wrote:
>I have installed a perl wrapper scipt round some tools. For eg sed. When
>we run sed it runs the wrapper which
>will execute the sed command from this line in the script:
>system "$path @ARGV";
>
>The path has been set up in the script and the argv comes from the input
>after the sed
>for eg
>sed '/^$/d' filename - where@argv is '/^$/d' filename
>
>This command should delete all blank lines in the file and print the
>rest.
>What is happening though is that the argv deletes the ' and runs
>sed /^$/d filename
>which results in errors.
Use the multi-argument form of system:
system $path, @ARGV;
In addition to being more efficient because it doesn't use the shell,
it also avoids possible security problems. Consider what happens
if one of the arguments was "x; rm -rf /".
Mike Guy
------------------------------
Date: Wed, 24 Jun 1998 12:25:41 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Losing ' round commands
Message-Id: <Pine.GSO.3.96.980624050431.16155N-100000@user2.teleport.com>
On Wed, 24 Jun 1998, Deborah Barclay wrote:
> I have installed a perl wrapper scipt round some tools. For eg sed.
Why would you want to run sed when you have perl? But, okay... :-)
> When we run sed it runs the wrapper which will execute the sed command
> from this line in the script:
> system "$path @ARGV";
> The path has been set up in the script and the argv comes from the input
> after the sed
> for eg
> sed '/^$/d' filename - where@argv is '/^$/d' filename
> What is happening though is that the argv deletes the ' and runs
> sed /^$/d filename
> which results in errors.
@ARGV isn't deleting the quote marks - it's never seeing them! Let's take
a closer look at what is happening.
First, some shell is given a command like this one.
yourprog '/^$/d' filename
The shell processes (and removes) those quote marks early on. Then it sees
that that line had a program name and two arguments. So, it runs your
program with those arguments.
Now your program is running. @ARGV has those two arguments as passed from
the shell. The first one is '/^$/d' - _without_ the quotes! That's not a
problem yet, though. (By the way, if you were calling sed directly from
the shell, it would be seeing the argument without quotes, just as perl
does.)
But now you put together the argument for system with a line like this:
> system "$path @ARGV";
Now the elements of @ARGV are interpolated with spaces in between, and the
lack of quotes is significant. Perl sees that there are shell
metacharacters in that single argument to system, so it starts _another_
shell to figure out what you wanted. But you don't get what you wanted,
you merely get what you asked for. :-)
One solution to this is to let perl start sed directly. It can do that if
it knows what the arguments are, and that's easy. When you pass a list of
values to system, perl won't start a shell to figure out what you wanted.
system $path, @ARGV;
Now the arguments are passed directly from perl to sed with no shell
involved. So, it's going to be more efficient, too.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 24 Jun 1998 13:23:11 GMT
From: JKraaijeveld@askesis.nl (Joost Kraaijeveld)
Subject: newbie Location: syntax help wanted
Message-Id: <3590fd05.2828375@news.telebyte.nl>
Hi,
Can anyone give me a working perl script that just returns the name of
a file that has to be displayed
I tried the following file (without the c style comments) :
/********************** start of file.pl ***************************/
#!/usr/bin/perl
Location: myfile.html
/********************** end of file.pl ***************************/
------------------------------
Date: Wed, 24 Jun 1998 13:52:45 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: newbie Location: syntax help wanted
Message-Id: <Pine.GSO.3.96.980624064924.16155T-100000@user2.teleport.com>
On Wed, 24 Jun 1998, Joost Kraaijeveld wrote:
> Can anyone give me a working perl script that just returns the name of
> a file that has to be displayed
Here's a simple one:
#!/usr/bin/perl
print "filename.txt\n";
But I see this in your attempt:
> Location: myfile.html
Hmmm... From the looks of that, you may actually want to do something with
HTTP or CGI, or both. If that's correct, the docs, FAQs, and newsgroups
about those and related topics should be able to answer your question.
Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 24 Jun 1998 12:04:49 GMT
From: chrishabs@my-dejanews.com
Subject: Re: Parsing <tags>
Message-Id: <6mqq11$4gp$1@nnrp1.dejanews.com>
In article <6mpuis$3k2$1@dinkel.civ.utwente.nl>,
Thomas van Gulick <melkor@Cal040031.student.utwente.nl> wrote:
>
> Tom Christiansen <tchrist@mox.perl.com> wrote:
> > [courtesy cc of this posting sent to cited author via email]
> >
> > In comp.lang.perl.misc,
> > Thomas van Gulick <melkor@Cal040031.student.utwente.nl> writes:
> > :I was wondering if this might be done using a faster routine.
> >
> > Is there some reason why you don't use the canned parsing
> > returns from LWP?
>
> I've checked it after you mentioned it, but I can't seem to find anythimg
> similar to parsing a HTML file for specific tags..
>
> Thomas
> --
> http://utumno.student.utwente.nl/
> melkor@utumno.student.utwente.nl
>
I don't know about LWP, but HTML::Parser should certainly do what you want.
Cheers
Chris H.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Wed, 24 Jun 1998 13:01:10 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Passing a method to another
Message-Id: <3590EA85.71ADD1B7@nortel.co.uk>
reesor@peoplescape.com wrote:
> Is there any way I can do
>
> $c = new cars;
> $e = new engines;
>
> $e->isSix($c);
>
> cars is in one module, engines is in another.
Check this out:
package cars;
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
bless $self, $class;
return $self;
}
sub engine {
my $self = shift;
return "SIX";
}
package engines;
@engines::ISA= qw( cars );
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
bless $self, $class;
return $self;
}
sub issix {
my $other = shift;
($other->engine() eq "SIX") ? 1 : 0;
}
package main;
$cars = cars->new;
$engines = engines->new();
print $engines->issix($cars);
The ISA array states in which packages to look for methods before complaining
(there are other safety nets, though). I <emphasis>strongly</emphasis> recommend
that you read the perltoot and perlobj. A lot is explained there about
inheritance and similar subjects.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Wed, 24 Jun 1998 13:06:21 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Passing a method to another
Message-Id: <3590EBBC.CFE7D4B2@nortel.co.uk>
F.Quednau wrote:
> print $engines->issix($cars);
Bollocks, just do print $engines->issix;
>
> sub issix {
> my $other = shift;
> ($other->engine() eq "SIX") ? 1 : 0;
> }
Also misleading, rather:
sub issix {
my $self = shift;
($self->engine eq "SIX") ? 1 : 0;
}
As engine is known by $engines. Period.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: 24 Jun 1998 13:57:42 GMT
From: dagorn@irisa.fr (Francois Dagorn)
Subject: Perl for Win32 and background process
Message-Id: <6mr0km$ru8$1@news.irisa.fr>
Hello all,
I wonder if there is a way to spawn background process when
using Perl for Win32 on W95. I've tried the following :
- fork exec (fork unimplemented !)
- system ("mycmd &"); (& not understood)
Any help would be appreciated.
Frangois Dagorn
Universiti de Rennes 1
France
------------------------------
Date: Wed, 24 Jun 1998 10:01:46 +0100
From: "James Lee" <james@soft.net.uk>
Subject: print <<STRING;
Message-Id: <01bd9f4e$aa51e080$4400a8a8@james.soft.net.uk>
Hi People
Just a quick one. I'm having a few problems with this
if ()
{
}
else
{
print <<STRING;
text
STRING
}
I'm getting error 'Can't find string terminator "STRING" anywhere before
EOF'.
Can anybody, shed some light.
James
Software Warehouse Bespoke
------------------------------
Date: Wed, 24 Jun 1998 12:40:34 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: print <<STRING;
Message-Id: <Pine.GSO.3.96.980624053850.16155Q-100000@user2.teleport.com>
On Wed, 24 Jun 1998, James Lee wrote:
> else
> {
> print <<STRING;
> text
> STRING
> }
>
> I'm getting error 'Can't find string terminator "STRING" anywhere before
> EOF'.
The terminator must be absolute alone on its line. Yours has spaces or
tabs in front. You may prefer to use qq{ } in place of the here-doc. Hope
this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 24 Jun 1998 12:36:50 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: print <<STRING;
Message-Id: <6mqrt2$664$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"James Lee" <james@soft.net.uk> writes:
:if ()
:{
:}
:else
:{
: print <<STRING;
: text
: STRING
:}
:
:I'm getting error 'Can't find string terminator "STRING" anywhere before
:EOF'.
:
:Can anybody, shed some light.
The perldata manpage indicates this clearly. I don't suppose
you knew you had that, though, did you? You're on a Microsoft
system, right, and didn't even know you had manpages, or weren't
used to looking, right? Just a guess. Am I accurate?
Here's an entry from the updated FAQ (see perlfaq4):
--tom
=head2 Why don't my <<HERE documents work?
Check for these three things:
=over
=item 1. There must be no space after the << part.
=item 2. There (probably) should be a semicolon at the end.
=item 3. You can't (easily) have any space in front of the tag.
=back
If you want to indent the text in the here document, you
can do this:
# all in one
($VAR = <<HERE_TARGET) =~ s/^\s+//gm;
your text
goes here
HERE_TARGET
But the HERE_TARGET must still be flush against the margin.
If you want that indented also, you'll have to quote
in the indentation.
($quote = <<' FINIS') =~ s/^\s+//gm;
...we will have peace, when you and all your works have
perished--and the works of your dark master to whom you
would deliver us. You are a liar, Saruman, and a corrupter
of men's hearts. --Theoden in /usr/src/perl/taint.c
FINIS
$quote =~ s/\s*--/\n--/;
A nice general-purpose fixer-upper function for indented here documents
follows. It expects to be called with a here document as its argument.
It looks to see whether each line begins with a common substring, and
if so, strips that off. Otherwise, it takes the amount of leading
white space found on the first line and removes that much off each
subsequent line.
sub fix {
local $_ = shift;
my ($white, $leader); # common white space and common leading string
if (/^\s*(?:([^\w\s]+)(\s*).*\n)(?:\s*\1\2?.*\n)+$/) {
($white, $leader) = ($2, quotemeta($1));
} else {
($white, $leader) = (/^(\s+)/, '');
}
s/^\s*?$leader(?:$white)?//gm;
return $_;
}
This works with leading special strings, dynamically determined:
$remember_the_main = fix<<' MAIN_INTERPRETER_LOOP';
@@@ int
@@@ runops() {
@@@ SAVEI32(runlevel);
@@@ runlevel++;
@@@ while ( op = (*op->op_ppaddr)() ) ;
@@@ TAINT_NOT;
@@@ return 0;
@@@ }
MAIN_INTERPRETER_LOOP
Or with a fixed amount of leading white space, with remaining
indentation correctly preserved:
$poem = fix<<EVER_ON_AND_ON;
Now far ahead the Road has gone,
And I must follow, if I can,
Pursuing it with eager feet,
Until it joins some larger way
Where many paths and errands meet.
And whither then? I cannot say.
--Bilbo in /usr/src/perl/pp_ctl.c
EVER_ON_AND_ON
--
I have a different view of the world. --Andrew Hume. Show&Tell '87
------------------------------
Date: 24 Jun 1998 12:52:55 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: print <<STRING;
Message-Id: <6mqsr7$imc$1@ns1.arlut.utexas.edu>
"James Lee" <james@soft.net.uk> writes:
>
> STRING
perldoc perldata
STRING
# note the string 'STRING' starts at column 0.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"Look for beauty in roughness, unpolishedness"
------------------------------
Date: Wed, 24 Jun 1998 08:15:50 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: print <<STRING;
Message-Id: <66uqm6.vbl.ln@localhost>
James Lee (james@soft.net.uk) wrote:
: Just a quick one. I'm having a few problems with this
: print <<STRING;
: text
: STRING
: I'm getting error 'Can't find string terminator "STRING" anywhere before
: EOF'.
: Can anybody, shed some light.
The answer is in a file that is very likely already on your
hard disk.
Please just get your answer there rather than clutter the newsgroup
with questions that have been asked and answered hundreds of
times already.
from 'perlfaq4":
"Why don't my <<HERE documents work?"
You have a problem with the #3 listed there...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 22 Jun 1998 23:57:14 -0400
From: "Eschult" <eschult.NOSPAM@squonk.net>
Subject: Re: print and the . operator ??
Message-Id: <6mqv34$k60$1@duke.squonk.net>
$line includes the line termination character, which you are appending to
$grades{student}. The print is printing it, yielding the extra blanks in
your output.
Try adding 'chop $line;' as your first line after the 'while ($line......)
{' line.
As to why '.=' behaves like '=', in your sample data there are no duplicates
of student names. If there were '.=' would append the grades, whereas "="
would replace the 1st grade with the 2nd.
Which is 'right' depends on what you're trying to accomplish.
Seo Choi wrote in message ...
>#!/usr/bin/perl
>
>open(GRADES, "grades") || die "Can't open grades: $!\n";
>while($line = <GRADES>) {
> ($student, $grade) = split(" ", $line);
> $grades{$student} .= $grade . " ";
> $gList{$student} = $grade . " ";
>}
>
>foreach $student (%grades) {
> print "$grades{$student}\n";
>}
>
>print "-" x 25, "\n";
>foreach $student (%gList) {
> print "$grades{$student}\n";
>}
>
>from the code above I have two questions. the first is why in the line
> $grades{$student} .=
>behaves the same way as
> $grades{$student} = without the dot
>
>
>the second question is why I have the output when using the attachment as
>the input file as:
>3
>
>5
>
>4
>
>1
>
>2
>
>-------------------------
>3
>
>5
>
>4
>
>1
>
>2
>
>because when i take the "\n" from the two foreach loops the out pout is
>only two lines long??
------------------------------
Date: Wed, 24 Jun 1998 13:34:51 +0100
From: "Marc Mosthav" <mosthavm@plcman.siemens.co.uk>
Subject: Print from Win32
Message-Id: <6mqv8m$sj2$1@manip6rt.ipv6.siemens.co.uk>
Does anybody know how I can print to a network printer with perl/Win32? I'm
using the Gurusamy stuff...
TIA,
Marc
------------------------------
Date: Wed, 24 Jun 1998 11:06:52 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: Q:How to flush output in perl?
Message-Id: <3590dcd7.425681257@news.mmc.org>
[posted and mailed]
On Wed, 24 Jun 1998 09:59:50 GMT, slshen@usa.net wrote:
>Hi,
>Why is the string "mdscopy Please Wait..." not displayed on browser when
>mdscopy command has not been completed?
>
>David
(code fragment deleted)
Most likely because your web server is doing the buffering. Check your web
server documentation for information on nph (non-parsed header) scripts.
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center - Medical Information Systems Group
drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me
------------------------------
Date: Wed, 24 Jun 1998 11:02:33 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Q:How to flush output in perl?
Message-Id: <Pine.GSO.3.96.980624040056.16155L-100000@user2.teleport.com>
On Wed, 24 Jun 1998 slshen@usa.net wrote:
> Why is the string "mdscopy Please Wait..." not displayed on browser when
> mdscopy command has not been completed?
If you're following the proper protocol but some browser or server doesn't
cooperate, then it's the other program's fault. If you're not following
the protocol, then it's your fault. If you aren't sure about the protocol,
you should read the protocol specification. If you've read it and you're
still not sure, you should ask in a newsgroup about the protocol.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 24 Jun 1998 12:59:41 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Sending files via mail in perl
Message-Id: <3590F9BE.434E@min.net>
John Stanley wrote:
>
> It is simply too much useless work to be forced to upgrade every machine
> on a net to the latest version of sendmail every time a new security
> hole is found in it. Run it as a daemon on one system and upgrade that when
> needed. Let the others be daemon-less and you don't have to worry about
> missing one system -- and learning too late that the spammers didn't
> miss it.
Maybe I'm just hopelessly behind the times, but -- people who exploit
security holes in sendmail are called hackers (or rather, crackers),
not spammers. Right?
--
John Porter
------------------------------
Date: Wed, 24 Jun 1998 14:35:34 +0100
From: "Marc Mosthav" <mosthavm@plcman.siemens.co.uk>
Subject: Re: Sending files via mail in perl
Message-Id: <6mr2qi$363$1@manip6rt.ipv6.siemens.co.uk>
>Maybe I'm just hopelessly behind the times, but -- people who exploit
>security holes in sendmail are called hackers (or rather, crackers),
>not spammers. Right?
That was in the good old times ;-) Nowadays security holes are also used by
spammers to make their crap look like it came from you.
Marc
------------------------------
Date: Wed, 24 Jun 1998 08:15:17 -0500
From: Tom Turton <tturton@cowboys.anet-dfw.com>
To: Charles Roten <croten@big.aa.net>
Subject: Re: Simple, efficient way of checking whether $VAR is an element of set @LIST ?
Message-Id: <3590FBE5.12028990@cowboys.anet-dfw.com>
Charles Roten wrote:
> Yeah, it's probably a _really_ dumb question ... but while a subroutine
> for such would be quite simple to write, I hate to reinvent the wheel ..
> and I'd bet two dollars ot a donut that this is probably already done
> _properly_, in some standard callable routine.
>
> I am really thinking in set-theoretic terms here. And that's the sort
> of test I want.
>
> What I'm _really_ after will look like this ...
>
> @LIST = keys (%hash);
> if ( $VAR is an element of @LIST ) {
> do stuff ;
> } else {
> scream bloody murder .. the other shoe just dropped ;
> }
>
Try:
if ( exists($LIST->{$VAR}) ) {
---Tom Turton
------------------------------
Date: Wed, 24 Jun 1998 13:29:25 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Simple, efficient way of checking whether $VAR is an element of set @LIST ?
Message-Id: <359100D3.1BA0@min.net>
Tom Turton wrote:
>
> Charles Roten wrote:
>
> > @LIST = keys (%hash);
> > if ( $VAR is an element of @LIST ) {
> > do stuff ;
> > }
>
> Try:
>
> if ( exists($LIST->{$VAR}) ) {
Why don't you try it yourself, Tom T?
Or maybe your perl was in use at the time,
so you had to post without testing.
In that case:
% cat t.pl
my %hash = ( 'name' => 'fred' );
my $VAR = 'name';
my @LIST = keys (%hash);
if ( exists($LIST->{$VAR}) ) {
print "key '$VAR' exists\n";
} else {
print "key '$VAR' doesn't exist\n";
}
% perl -w t.pl
Name "main::LIST" used only once: possible typo at t.pl line 4.
key 'name' doesn't exist
No, what you meant was:
if ( exists $hash{$VAR} ) {
--
John Porter
------------------------------
Date: 24 Jun 1998 13:07:07 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: sort getpwent() by group?
Message-Id: <6mqtlr$62t@news-central.tiac.net>
In article <6mpfga$9fk$1@nnrp1.dejanews.com>, <matt@msg.ucsf.edu> wrote:
>I can't figure this out. I want to:
>
>1.) Read password entries with getpwent()
>2.) Sort entries by GID
>3.) Substitute a groupname for GID
>4.) Print out login, name, groupname as in:
>
>matt Matt Harrington Admin
>joe Joe User Admin
>fj Fred Jones Engineer
>bs Bob Smith Math
>
>etc.
>
>I want to use getpwent() because I use NIS.
>
>Should I store lines in an array and then print it out? Or should I use a
>hash?
You might consider getting password entries and storing them in a hash
indexed by group id (maybe an array, depends on how sparse your gids are)
e.g.
while (@entry = getpwent) {
push @{$stash{$entry[3]}}, [@entry[0, 6]]; # just login & gcos
}
then once you've got %stash populated its keys will be numeric group IDs
and you can use getgrgid to convert them to strings. Then it's a matter
of iterating over the values in %stash, which are lists of lists and
ordering them.
One thing you can do is use the debugger to see what happens e.g.
$ perl -de 1
Loading DB routines from perl5db.pl version 1.01
Emacs support available.
Enter h or `h h' for help.
main::(-e:1): 1
DB<1> while (@entry = getpwent) { push @{$stash{$entry[3]}}, [@entry[0, 6]] }
DB<2> X stash
The perllol and perldsc man pages may be useful, as might perlfaq4. All
of these can be read with the perldoc command.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Wed, 24 Jun 1998 08:24:15 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
To: "Vincent M. Probasco" <probavm@h8mail.laf.cat.com>
Subject: Re: split();
Message-Id: <3590FDFF.6FE81C0B@houston.Geco-Prakla.slb.com>
[courtesy cc to cited author]
Vincent M. Probasco wrote:
>
> I know there must be a simple solution to this but it's beyond my scope.
> I've looked at the manual
> again and again and I can't see what's wrong with this.
>
> $theline contains
>
> 981269|<TD> <A
> HREF="mailto:probavm@h8mail.laf.cat.com">probavm@h8mail.laf.cat.c
> om</A></TD>|<TD> 5555 </TD>|<TD> Minor: test </TD>|2|pending
<snip>
> ($number,$user,$dept,$descript,$time,$category)=split(/|/, $theline);
<snip>
Well, this line is your problem. Read the documentation on split again
(perldoc -f split). The thing inside the //'s is a regular expression.
The pipe (|) character is a special which means a|b. Your telling split
to split on nothing, or nothing. It is the same as if you had typed //,
which means to split between every character, thus you get 9 for number,
8 for user, etc.
Change the split to:
split(/\|/, $theline)
and it should work just fine.
HTH.
Dave
--
"Security through obscurity is no security at all."
-comp.lang.perl.misc newsgroup posting
----------------------------------------------------------------------
Dave Barnett U.S.: barnett@houston.Geco-Prakla.slb.com
DAPD Software Support Eng U.K.: barnett@gatwick.Geco-Prakla.slb.com
Schlumberger Geco-Prakla (281) 596-1434 (Office Number)
1325 S. Dairy Ashford #7051 (281) 556-7615 (Fax)
Houston, TX 77077
----------------------------------------------------------------------
------------------------------
Date: 24 Jun 1998 12:24:23 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: system() and security again
Message-Id: <6mqr5n$664$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Marc.Haber-usenet@gmx.de (Marc Haber) writes:
:And I have to be sure that this command does not contain
:metacharacters :-). Is it possible to pass a list with a single string
:element?
What does that mean? You mean a list of one element?
@cmds = "who";
system { $cmds[0] } @cmds;
--tom
--
It's all magic. :-) --Larry Wall in <7282@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 24 Jun 1998 13:17:16 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: system() and security again
Message-Id: <6mqu8s$dml$1@pegasus.csx.cam.ac.uk>
Marc Haber <Marc.Haber-usenet@gmx.de> wrote:
>Russ Allbery <rra@stanford.edu> wrote:
>>So you want to *always* pass system a list unless you're executing a
>>simple command with no arguments.
>
>And I have to be sure that this command does not contain
>metacharacters :-). Is it possible to pass a list with a single string
>element?
Not AFAIK. But depending on the particular command, you may be able
to get away with
system $command, '';
Mike Guy
------------------------------
Date: Wed, 24 Jun 1998 12:47:16 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Testing perl knowledge
Message-Id: <pudge-2406980844300001@dynamic448.ply.adelphia.net>
In article <6mps7g$l52$1@news.NERO.NET>, stanley@skyking.OCE.ORST.EDU
(John Stanley) wrote:
# In article <pudge-2306982254300001@dynamic448.ply.adelphia.net>,
# Chris Nandor <pudge@pobox.com> wrote:
# >I am a Certified Perl Engineer (CPE). I sent e-mail to a guy who
# >certified me. I also certified myself.
#
# You should be careful with this. Many states assign special legal status
# to the title "engineer".
Good, does that mean I can get a tax break or something?
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Wed, 24 Jun 1998 12:03:23 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: What does this error mean?
Message-Id: <3590DCFB.9AEAB0A2@nortel.co.uk>
Joost Kraaijeveld wrote:
> #!/usr/local/bin/perl
> #
> print "Content-type: text/html\n\n" ;
>
> # Print the HTML response page to STDOUT
> print <<EOF ;
> <html>
> <head><title>CGI Results</title></head>
> <body>
> <h1>File will be returned.</h1>
> </body>
> </html>
> EOF
>
> exit ;
Your script works fine on
This is perl, version 5.003 with EMBED
built under hpux at Nov 21 1996 13:03:00
+ suidperl security patch
Very weird...
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Wed, 24 Jun 1998 12:35:47 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: What does this error mean?
Message-Id: <Pine.GSO.3.96.980624052652.16155O-100000@user2.teleport.com>
On Wed, 24 Jun 1998, Joost Kraaijeveld wrote:
> Newsgroups: comp.lang.perl.misc, comp.lang.perl
If your news administrator still carries comp.lang.perl, please let him
or her know that that newsgroup has not existed since 1995. If you
have such an outdated newsgroup listing, you are probably missing out
on many other valid newsgroups as well. You'll be doing yourself and
many others a favor to use only comp.lang.perl.misc (and other valid
Perl newsgroups) instead.
> Subject: What does this error mean?
When you get an unfamiliar error message from Perl, the perldiag manpage
may have a helpful explanation of what is going on.
> Can't find string terminator "EOF" anywhere before EOF at file.pl line
> 12.
The fact that 'EOF' is used twice in that message is a little confusing.
But Perl is telling you that you don't have 'EOF' (those three characters
without the quotes) on a line all by itself before EOF (end of file).
Those three characters must be the only ones on the line - no spaces,
tabs, semicolons, or any other characters may be there. (The exception is
the required newline character at the end of the line, of course.)
> On Windows NT all is fine
Well, then, the problem must not be any of the ordinary characters. When
you transferred the program from NT to Unix, did you use a text or ASCII
transfer mode? It seems likely that you've got invisible extra characters
on every line, left over from the DOS/Windows file format. Because of
those unwanted characters, the 'EOF' isn't all alone on the line. Try
transferring the file again, being sure to use the proper text mode, and
see whether that's it.
Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 24 Jun 1998 08:20:34 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: What does this error mean?
Message-Id: <2fuqm6.vbl.ln@localhost>
Joost Kraaijeveld (JKraaijeveld@askesis.nl) wrote:
: I have a simple script that return this error if run on a UNIX
: commandline:
: Can't find string terminator "EOF" anywhere before EOF at file.pl line
: 12.
: On Windows NT all is fine
Use ASCII mode when transfering files between different OSes.
You probably have carriage return chars for line endings, pull
the script into vi on your Unix system and see if there are
'^M' sequences displayed (vi uses that to indicate CRs).
Or, just fix up the line endings on the Unix box:
perl -p -i -e 'tr/\r//d' my_script
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 24 Jun 1998 13:31:06 GMT
From: JKraaijeveld@askesis.nl (Joost Kraaijeveld)
Subject: Re: What does this error mean?
Message-Id: <3590ff62.3433312@news.telebyte.nl>
Hi Frank,
Found the sollution. It had something to do with cr/lf translation
between Windows NT (my development platform) and UNIX (my provider)
Joost
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 2958
**************************************