[18508] in Perl-Users-Digest
Perl-Users Digest, Issue: 676 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 11 14:11:13 2001
Date: Wed, 11 Apr 2001 11:10:28 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <987012628-v10-i676@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 11 Apr 2001 Volume: 10 Number: 676
Today's topics:
foreach() passes reference? (Christian Nadolle)
Re: foreach() passes reference? (Christian Nadolle)
Forking a process <seppy@chartermi.net>
Re: Forking a process <seppy@chartermi.net>
Re: Forking a process (Logan Shaw)
Re: Forking a process <ren@tivoli.com>
Re: Forking a process <seppy@chartermi.net>
Re: GD newbie (Chris Fedde)
Glob::EXPORT_TAGS <scott.rutherford@cern.ch>
Help! Problem getting the value of a variable. (Andrew Isherwood)
Re: Help! Problem getting the value of a variable. (Rafael Garcia-Suarez)
Re: How does one access path/command in perl (i.e., equ (Martien Verbruggen)
How to redirect between STDOUT and a file? <sg@loralskynet.com>
Re: How to redirect between STDOUT and a file? <mkuin@globalrangers.com>
Re: How to redirect between STDOUT and a file? (Logan Shaw)
Re: How to redirect between STDOUT and a file? (Arek P)
Re: How to redirect between STDOUT and a file? nobull@mail.com
Re: How to redirect between STDOUT and a file? nobull@mail.com
Re: How to redirect between STDOUT and a file? nobull@mail.com
Re: How to redirect between STDOUT and a file? (Logan Shaw)
Re: How to redirect between STDOUT and a file? nobull@mail.com
Re: How to redirect between STDOUT and a file? nobull@mail.com
Re: How to redirect between STDOUT and a file? <rick.delaney@home.com>
Re: How to redirect between STDOUT and a file? (Chris Fedde)
Re: How to send a formatted string through a socket? (Chris Fedde)
HTTP_X_FORWARDED_FOR??? <chris.hess@intel.com>
Re: inheritance within one file? <uri@sysarch.com>
Re: LWP - HTTPS (Peter Scott)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 11 Apr 2001 19:11:42 +0200
From: cnadolle@metadesign.de (Christian Nadolle)
Subject: foreach() passes reference?
Message-Id: <1erpr7o.1wvatu199doogN%cnadolle@metadesign.de>
Hi,
maybe I got too little sleep these days... ;-)
...but I thought foreach() would pass values, not references.
But now this code:
>-- snip
$SQL{'delete'} = [
'DELETE FROM rule where id = :1',
];
sub foo {
my($self, $id) = @_;
my($sqlAR) = $SQL{'delete'};
my($sql)
foreach $sql (@{$sqlAR}) {
$sql =~ s/:1/$id/g;
$rc = $self->doSQL($sql);
}
}
>-- snap
the second time, foo() is called, $sql contains already the id from the
first call, so it seems that foreach passes a reference and the s///
changes the contents of the Array itself.
Is that correct and meant to be?
Do I miss anything here?
Did this behaviour change with Perl 5.6.0 ?
Thanks for any hints
Christian
------------------------------
Date: Wed, 11 Apr 2001 19:45:12 +0200
From: cnadolle@metadesign.de (Christian Nadolle)
Subject: Re: foreach() passes reference?
Message-Id: <1erpthq.189dhqsymu60cN%cnadolle@metadesign.de>
ok, it was the missing sleep.
sorry for bothering you and thanks for the answers.
Christian Nadolle <cnadolle@metadesign.de> wrote:
> Hi,
>
> maybe I got too little sleep these days... ;-)
>
> ...but I thought foreach() would pass values, not references.
>
> But now this code:
>
> >-- snip
>
> $SQL{'delete'} = [
> 'DELETE FROM rule where id = :1',
> ];
>
>
> sub foo {
> my($self, $id) = @_;
> my($sqlAR) = $SQL{'delete'};
> my($sql)
> foreach $sql (@{$sqlAR}) {
> $sql =~ s/:1/$id/g;
> $rc = $self->doSQL($sql);
> }
> }
>
> >-- snap
>
> the second time, foo() is called, $sql contains already the id from the
> first call, so it seems that foreach passes a reference and the s///
> changes the contents of the Array itself.
>
> Is that correct and meant to be?
> Do I miss anything here?
> Did this behaviour change with Perl 5.6.0 ?
>
> Thanks for any hints
> Christian
------------------------------
Date: Wed, 11 Apr 2001 10:24:38 -0400
From: Brian Seppanen <seppy@chartermi.net>
Subject: Forking a process
Message-Id: <3AD46926.8A0D97BD@chartermi.net>
Hi:
I'm trying to write a simple script that cycles through, a directory
listing of zone records and
for each zone name it forks a new process (I only want to fork a single
process), the new process
does a whois lookup on the zone, and hands the data back to the parent
process. The parent process works its mojo on the data returned and I
sort the data into different file's listing which registrar for each
zone. I have to correct the information for zones registered with
certain registrars, and this script would be a good first step.
I'm very much a new perl programmer who has no experience with creating
forked processes. please comment on whether this is advisable, wise,
how I could go about it. I'd apprectiate it.
So far I have
use strict 'vars';
use Cwd 'chdir';
chdir "/Configs/Bind/Zones";
my ($entry,$domainname);
my @zones=`ls -1 [a-zA-z]* | grep -v TEMPLATE.TLD.hosts`;
foreach $entry(@zones) {
chomp $entry;
($domainname)=split(/.hosts/,$entry);
print "$domainname\n";
}
Thanks,
Brian Seppanen
seppy@chartermi.net
------------------------------
Date: Wed, 11 Apr 2001 12:30:47 -0400
From: Brian Seppanen <seppy@chartermi.net>
Subject: Re: Forking a process
Message-Id: <3AD486B7.1B3868D9@chartermi.net>
I've expanded upon the original that I included in the previous post,
and I get the following error
Use of uninitialized value in split at ./registrars line 14, <WHOIS>
line 151.
Use of uninitialized value in split at ./registrars line 14, <WHOIS>
line 152.
Use of uninitialized value in concatenation (.) at ./registrars line 12,
<WHOIS> line 152.
How can I parse the output of the whois to only include the REGISTRAR:
line? I believe that is what these errors are indicating?
#!/usr/bin/perl -w
use strict 'vars';
use Cwd 'chdir';
chdir "/Configs/Bind/Zones";
my ($entry,$domainname,$registrar);
my @zones=`ls -1 [a-zA-z]* | grep -v TEMPLATE.TLD.hosts`;
foreach $entry(@zones) {
chomp $entry;
($domainname)=split(/.hosts/,$entry);
open WHOIS, "whois $_\n |" or die "can't fork: $!";
while (<WHOIS>) {
($registrar)=split(/Registrar:/,$registrar);
CASE: {
if (/^NETWORK SOLUTIONS, INC./) {
open (NSI,">>nsi.domains");
print NSI "$_\n";
close NSI;
last CASE;
}
if (/^REGISTER.COM, INC./) {
open (REGISTER,">>register.domains");
print REGISTER "$_\n";
close REGISTER;
last CASE;
}
else {
open (OTHER,">>other.domains");
print OTHER "$_\n";
close OTHER;
last CASE;
}
}
}
}
------------------------------
Date: 11 Apr 2001 11:38:25 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Forking a process
Message-Id: <9b21a1$sup$1@charity.cs.utexas.edu>
In article <3AD486B7.1B3868D9@chartermi.net>,
Brian Seppanen <seppy@chartermi.net> wrote:
>I've expanded upon the original that I included in the previous post,
>and I get the following error
>Use of uninitialized value in split at ./registrars line 14, <WHOIS>
>line 151.
>Use of uninitialized value in split at ./registrars line 14, <WHOIS>
>line 152.
>Use of uninitialized value in concatenation (.) at ./registrars line 12,
><WHOIS> line 152.
>
>How can I parse the output of the whois to only include the REGISTRAR:
>line? I believe that is what these errors are indicating?
No, they're indicating that you've used an initialized value,
meaning that you're reading a variable's value before you set it.
>#!/usr/bin/perl -w
>
>use strict 'vars';
>use Cwd 'chdir';
>
>chdir "/Configs/Bind/Zones";
>my ($entry,$domainname,$registrar);
>my @zones=`ls -1 [a-zA-z]* | grep -v TEMPLATE.TLD.hosts`;
>foreach $entry(@zones) {
> chomp $entry;
> ($domainname)=split(/.hosts/,$entry);
> open WHOIS, "whois $_\n |" or die "can't fork: $!";
You shouldn't be using "$_" here; you haven't set it to anything yet.
> while (<WHOIS>) {
> ($registrar)=split(/Registrar:/,$registrar);
You shouldn't be using "$registrar" on the righthand side of your
assignment statement here; you haven't set it to anything.
Hope that helps.
- Logan
--
my your his her our their _its_
I'm you're he's she's we're they're _it's_
------------------------------
Date: 11 Apr 2001 10:23:31 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Forking a process
Message-Id: <m34rvvbguk.fsf@dhcp9-172.support.tivoli.com>
On Wed, 11 Apr 2001, seppy@chartermi.net wrote:
> I'm trying to write a simple script that cycles through, a directory
> listing of zone records and for each zone name it forks a new
> process (I only want to fork a single process), the new process does
> a whois lookup on the zone, and hands the data back to the parent
> process. The parent process works its mojo on the data returned and
> I sort the data into different file's listing which registrar for
> each zone. I have to correct the information for zones registered
> with certain registrars, and this script would be a good first step.
From this description it doesn't sound like you need to explicitly
fork at all. If you are going to have the parent process wait for
each child in sequence, then you can simply use the qx// operator
(a.k.a. backticks) to run the whois command and collect the output.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Wed, 11 Apr 2001 13:48:25 -0400
From: Brian Seppanen <seppy@chartermi.net>
Subject: Re: Forking a process
Message-Id: <3AD498E9.1001D076@chartermi.net>
> You shouldn't be using "$_" here; you haven't set it to anything yet.
>
> > while (<WHOIS>) {
> > ($registrar)=split(/Registrar:/,$registrar);
>
> You shouldn't be using "$registrar" on the righthand side of your
> assignment statement here; you haven't set it to anything.
>
You are right on all accounts, Thank you.
Now can someone guide me on parsing the ouput of the whois to only
include the Registrar: line?
open WHOIS, "whois $domainname\n | grep Registrar: |" or die "can't
fork: $!";
doesn't work. I get the following
Use of uninitialized value in concatenation (.) at ./registrars line 15,
<WHOIS> line 139.
#!/usr/bin/perl -w
use strict 'vars';
use Cwd 'chdir';
chdir "Configs/Bind/Zones";
my ($entry,$domainname,$registrar,$line);
my @zones=`ls -1 [a-zA-z]* | grep -v TEMPLATE.TLD.hosts`;
foreach $entry(@zones) {
chomp $entry;
($domainname)=split(/.hosts/,$entry);
open WHOIS, "whois $domainname\n | grep Registrar: |" or die
"can't fork: $!";
while (<WHOIS>) {
($line,$registrar)=split(/Registrar:/,$_);
print "Domain: $domainname:\tRegistrar: $registrar\n";
CASE: {
if (/^NETWORK SOLUTIONS, INC./) {
open (NSI,">>nsi.domains") or die "can't open file:
$!\n";
print NSI "$domainname\n";
close NSI;
last CASE;
}
if (/^REGISTER.COM, INC./) {
open (REGISTER,">>register.domains") or die "can't open
file: $!\n";
print REGISTER "$domainname\n";
close REGISTER;
last CASE;
}
else {
open (OTHER,">>other.domains") or die "can't open file:
$!\n";
print OTHER "$domainname\n";
close OTHER;
last CASE;
}
}
}
}
Thanks for the assistance.
Brian Seppanen
seppy@chartermi.net
------------------------------
Date: Wed, 11 Apr 2001 17:50:00 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: GD newbie
Message-Id: <cP0B6.818$T3.192824320@news.frii.net>
In article <9b11f3$domh$1@as121.tel.hr>,
Bosko Mirkic <bosko.mirkic@zg.tel.hr> wrote:
>O.K. say what you want, but I'm stuck at the very beginning. I'm trying to
>use GD under win32 distribution of ActivePerl but I don't know how to do
>this. Can somebody tell me what to do (please in plain English "copy to dir,
>install to, configure this, etc").
>
>Thanks
>
IIRC GD is one of the modules that comes pre-installed with ActiveState.
But if I'm wrong you can install it easily from one of the ppm sets
available at the ActiveState site.
As for using it, you need only look so far as the example in the GD manual
page. Also IIRC there is a reasonably good documentation browser that
comes with ActiveState. Some fortitude and a few well placed clicks will
take you far. The section of the GD manual page you are looking
for has the title "A Simple Example".
If this is not enough to get you going, then I'd recommend looking further at
the documentation that comes with ActiveState and the ActiveState website.
then run a few canned examples that you are sure to find laying around in
the distribution.
If this is still not enough to get you going, I recommend packing your
computer back in it's original packaging, taking it back to your place
of purchase and ask for a full refund. ;-)
Good Luck
chris
--
This space intentionally left blank
------------------------------
Date: Wed, 11 Apr 2001 15:19:39 +0200
From: Scott RUTHERFORD <scott.rutherford@cern.ch>
Subject: Glob::EXPORT_TAGS
Message-Id: <3AD459EB.33125B31@cern.ch>
Hi, does anybody have any idea what this means
Default die handler restored.
Loading DB routines from perl5db.pl version 1.07
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
"globally" is not defined in %File::Glob::EXPORT_TAGS at
/usr/local/lib/perl5/5.6.0/Exporter/Heavy.pm line 75
Exporter::heavy_export('File::Glob', 'main', ':globally') called
at /usr/local/lib/perl5/5.6.0/Exporter.pm line 50
Exporter::import('*File::Glob::EXPORT', ':globally') called at
betbot.pl line 178
main::BEGIN() called at
/usr/local/lib/perl5/5.6.0/i686-linux-thread/File/Glob.pm line 178
require 0 called at
/usr/local/lib/perl5/5.6.0/i686-linux-thread/File/Glob.pm line 178
Can't continue after import errors at betbot.pl line 178
BEGIN failed--compilation aborted at betbot.pl line 178.
------------------------------
Date: Wed, 11 Apr 2001 14:02:20 GMT
From: aai@aber.ac.uk (Andrew Isherwood)
Subject: Help! Problem getting the value of a variable.
Message-Id: <3ad46398.5526616@news.aber.ac.uk>
I have a variable called $collectionid.
I assign a numeric value to $collectionid at the start of the program.
At one point in the program I have:
$type = "collection";
$find = '$' . $type . 'id';
Then I need to use $find in an SQL query as the value to be found. The
only problem is $find actually equals the string '$collectionid'. How
can I get $find to equal the numeric value of $collectionid, rather
than the string.
Make sense? I hope so
Thanks very much
Andrew
------------------------------
Date: 11 Apr 2001 14:38:39 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Help! Problem getting the value of a variable.
Message-Id: <slrn9d8r4f.pbk.rgarciasuarez@rafael.kazibao.net>
Andrew Isherwood wrote in comp.lang.perl.misc :
} I have a variable called $collectionid.
}
} I assign a numeric value to $collectionid at the start of the program.
}
}
} At one point in the program I have:
}
} $type = "collection";
}
} $find = '$' . $type . 'id';
}
} Then I need to use $find in an SQL query as the value to be found. The
} only problem is $find actually equals the string '$collectionid'. How
} can I get $find to equal the numeric value of $collectionid, rather
} than the string.
It is possible (using soft references, see perlref), but it's not
considered good practice.
An idea would be to use a hash :
my %id = ( 'collection' => $somenumericvalue );
$find = $id{'collection'};
This would probably be cleaner.
Hope this helps.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Wed, 11 Apr 2001 23:20:56 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: How does one access path/command in perl (i.e., equiv to C/C++ argv[0])
Message-Id: <slrn9d8mho.fn5.mgjv@martien.heliotrope.home>
On Wed, 11 Apr 2001 07:50:36 -0500,
Ron Flory <ron.flory@adtran.com> wrote:
> hi-
>
> I'm a C/C++ person, but I work with a Perl guy who needs to determine
> the directory path that reflects where the executable was loaded/run
> from.
>
> This is because we have other programs that are related to the primary
> app located in this same directory, which we need to launch from the
> primary app. We need to know this 'path' when launching the other apps
> (which may be in different places on different users systems).
>
> In C/C++ this is -always- available in argv[0], but he says this is not
> the case in Perl. How can we work around this issue?
It is just as available in $0 in Perl as it is available in argv[0] in C
or C++. That is to say: You can often use that variable to find out, but
sometimes you can't. And that has very little to do with the programming
language, and much more with the platform.
$ cat /tmp/foo
#!/usr/local/bin/perl -wl
print $0
$ /tmp/foo
/tmp/foo
$ perl /tmp/foo
/tmp/foo
The following C program does exactly the same thing:
#include <stdio.h>
int main (int argc, char *argv[])
{
puts(argv[0]);
return 0;
}
The Perl FAQ, section 8 has a question which is probably related to what
you want to do:
'How do I add the directory my program lives in to the module/library
search path?'
It depends a lot on your application, and whether it is likely to change
cwd while running, and other things whether ir not you need to use
FindBin, but the Perl guy is probably slightly confused about why $0
can't always simply be used to find out where the original binary lives.
One big problem you may run into is symbolic links. Your real program,
and all its related material lives, say, in /opt/mystuff. The main
binary is /opt/mystuff/runme. There is a symbolic link /usr/bin/runme to
/opt/mystuff/runme.
When people run /usr/bin/runme, there is no way in the world that you
will be able to find out that the real binary run was actually
/opt/mystuff/runme. Well, there is, but no longer if it is a hard link.
This goes for both the perl and C program above.
People normally use a configuration file or environment variable to get
around these problems.
> I do not usually haunt this group, so an email response would really be
> appreciated.
Sorry, I don't usually email responses to people, so it would be
appreciated if you read this group.
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: Wed, 11 Apr 2001 11:31:58 -0400
From: Stephan Gross <sg@loralskynet.com>
Subject: How to redirect between STDOUT and a file?
Message-Id: <avt8dt07firdjhk4f3187in53durkqmnqu@4ax.com>
I wrote a lengthy script that creates an output HTML file:
$OUTFILE = "C:\\BRP_Summary.html";
open(OUT, "> $OUTFILE") || die "Cannot open $OUTFILE for output:
$!\n";
print OUT "<TITLE>$type Report<\/TITLE>\n";
etc.
Now I want the output to appear in a web browser, so I need to
redirect OUT to be STDOUT. I can edit the file and remove the OUT
filehandle, but if I want to go back to producing the standalone html
file, I have to re-edit the code. Is there a simple way to redefine
OUT to be STDOUT?
------------------------------
Date: Wed, 11 Apr 2001 17:54:22 +0200
From: "Mark Kuin" <mkuin@globalrangers.com>
Subject: Re: How to redirect between STDOUT and a file?
Message-Id: <9b1uo2$sh4$1@news1.xs4all.nl>
> Is there a simple way to redefine OUT to be STDOUT?
I don't know if it's possible what you are asking, but you can do it the
other way around....
It's easy to redirect STDOUT to a file, so you can just print this in the
beginning of your script and remove all the references to OUT. When you want
to send it to the web-browser, just comment this line.
$OUTFILE = "C:\\BRP_Summary.html";
open(STDOUT, "> $OUTFILE") || die "Cannot open $OUTFILE for output: $!\n";
print "<TITLE>$type Report<\/TITLE>\n";
etc.
------------------------------
Date: 11 Apr 2001 10:56:10 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How to redirect between STDOUT and a file?
Message-Id: <9b1uqq$skn$1@charity.cs.utexas.edu>
In article <avt8dt07firdjhk4f3187in53durkqmnqu@4ax.com>,
Stephan Gross <sg@loralskynet.com> wrote:
>Now I want the output to appear in a web browser, so I need to
>redirect OUT to be STDOUT. I can edit the file and remove the OUT
>filehandle, but if I want to go back to producing the standalone html
>file, I have to re-edit the code. Is there a simple way to redefine
>OUT to be STDOUT?
Sure:
open (OUT, '>&STDOUT');
"perldoc -f open" will explain that syntax.
A cleaner solution would be to use the FileHandle module. Then, you
can create a variable which holds a filehandle, and you can pass this
to some function that prints out your HTML.
It might look like this:
use FileHandle;
sub print_the_html
{
my ($fh) = @_;
$fh->print "<B>blahblahblah</B>";
}
if (i_am_a_cgi())
{
my $html_out = new FileHandle ('>&STDOUT');
}
else
{
my $html_out = new FileHandle ('>foo.html');
}
print_the_html ($html_out);
$fh->close;
Hope that helps.
- Logan
--
my your his her our their _its_
I'm you're he's she's we're they're _it's_
------------------------------
Date: Wed, 11 Apr 2001 12:27:01 EDT
From: Arek@nospam.tv (Arek P)
Subject: Re: How to redirect between STDOUT and a file?
Message-Id: <9b20kl$msv$1@earth.superlink.net>
On Wed, 11 Apr 2001 11:31:58 -0400, Stephan Gross <sg@loralskynet.com>
wrote:
>I wrote a lengthy script that creates an output HTML file:
>
>$OUTFILE = "C:\\BRP_Summary.html";
>open(OUT, "> $OUTFILE") || die "Cannot open $OUTFILE for output:
>$!\n";
>print OUT "<TITLE>$type Report<\/TITLE>\n";
>etc.
>
>Now I want the output to appear in a web browser, so I need to
>redirect OUT to be STDOUT. I can edit the file and remove the OUT
>filehandle, but if I want to go back to producing the standalone html
>file, I have to re-edit the code. Is there a simple way to redefine
>OUT to be STDOUT?
>
this is what U are looking for
*OUT=*STDOUT;
check perldoc perldata for more info on f handles and typeglobes
ArekP
------------------------------
Date: 11 Apr 2001 17:40:53 +0100
From: nobull@mail.com
Subject: Re: How to redirect between STDOUT and a file?
Message-Id: <u9ofu38k4q.fsf@wcl-l.bham.ac.uk>
Stephan Gross <sg@loralskynet.com> writes:
> I wrote a lengthy script that creates an output HTML file:
>
> $OUTFILE = "C:\\BRP_Summary.html";
> open(OUT, "> $OUTFILE") || die "Cannot open $OUTFILE for output:
> $!\n";
> print OUT "<TITLE>$type Report<\/TITLE>\n";
> etc.
>
> Now I want the output to appear in a web browser, so I need to
> redirect OUT to be STDOUT. I can edit the file and remove the OUT
> filehandle, but if I want to go back to producing the standalone html
> file, I have to re-edit the code.
To go back you would not need to re-edit every print, just select(OUT).
>Is there a simple way to redefine OUT to be STDOUT?
*OUT = *STDOUT{IO};
Note, this is simple but is not a good idea (not least because
close(OUT) will now close(STDOUT)).
Alternatively change "print OUT" to "print $out" and set $out=\*OUT or
$out=\*STDOUT.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 11 Apr 2001 17:44:50 +0100
From: nobull@mail.com
Subject: Re: How to redirect between STDOUT and a file?
Message-Id: <u9k84r8jy5.fsf@wcl-l.bham.ac.uk>
Arek@nospam.tv (Arek P) writes:
> On Wed, 11 Apr 2001 11:31:58 -0400, Stephan Gross <sg@loralskynet.com>
> wrote:
> >Is there a simple way to redefine OUT to be STDOUT?
> this is what U are looking for
> *OUT=*STDOUT;
Pedantically better to say:
*OUT = *STDOUT{IO};
Just in case the OUT symbol has any other bindings.
However this is still probably not the best way - see other branhes of
this thread.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 11 Apr 2001 17:54:01 +0100
From: nobull@mail.com
Subject: Re: How to redirect between STDOUT and a file?
Message-Id: <u9hezv8jiu.fsf@wcl-l.bham.ac.uk>
logan@cs.utexas.edu (Logan Shaw) writes:
> use FileHandle;
FileHandle is deprecated in favour of IO::File
> sub print_the_html
> {
> my ($fh) = @_;
>
> $fh->print "<B>blahblahblah</B>";
Parentheses around method arguments are not optional.
> }
>
> if (i_am_a_cgi())
> {
> my $html_out = new FileHandle ('>&STDOUT');
> }
Indirect object syntax for constructors is deprecated.
Your my() is in the wrong place.
$html_out = IO::File->new('>&STDOUT');
> print_the_html ($html_out);
>
> $fh->close;
You meant to say
$html_out->close;
But that's redundant anyhow, it will automatically be closed as soon
as $html_out goes out of scope.
> Hope that helps.
It would probably have helped more it there were fewer careless mistakes.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 11 Apr 2001 12:10:23 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How to redirect between STDOUT and a file?
Message-Id: <9b235v$t3m$1@charity.cs.utexas.edu>
In article <u9hezv8jiu.fsf@wcl-l.bham.ac.uk>, <nobull@mail.com> wrote:
>logan@cs.utexas.edu (Logan Shaw) writes:
>
>> use FileHandle;
>
>FileHandle is deprecated in favour of IO::File
[ etcetera ]
>> Hope that helps.
>
>It would probably have helped more it there were fewer careless mistakes.
Oops, that's what I get for posting in a hurry. Sorry about that...
- Logan
--
my your his her our their _its_
I'm you're he's she's we're they're _it's_
------------------------------
Date: 11 Apr 2001 17:57:46 +0100
From: nobull@mail.com
Subject: Re: How to redirect between STDOUT and a file?
Message-Id: <u9eluz8jcl.fsf@wcl-l.bham.ac.uk>
> print OUT "<TITLE>$type Report<\/TITLE>\n";
>
> Now I want the output to appear in a web browser, so I need to
> redirect OUT to be STDOUT. I can edit the file and remove the OUT
> filehandle, but if I want to go back to producing the standalone html
> file, I have to re-edit the code.
TIMTOWTDI.
Other people have already mentioned most ways but not yet the one
argument form of select().
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 11 Apr 2001 18:16:50 +0100
From: nobull@mail.com
Subject: Re: How to redirect between STDOUT and a file?
Message-Id: <u966gb8igt.fsf@wcl-l.bham.ac.uk>
nobull@mail.com writes:
> > print OUT "<TITLE>$type Report<\/TITLE>\n";
> >
> > Now I want the output to appear in a web browser, so I need to
> > redirect OUT to be STDOUT. I can edit the file and remove the OUT
> > filehandle, but if I want to go back to producing the standalone html
> > file, I have to re-edit the code.
>
> TIMTOWTDI.
>
> Other people have already mentioned most ways but not yet the one
> argument form of select().
Like, duh! I already mentioned that one myself.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 11 Apr 2001 17:31:25 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: How to redirect between STDOUT and a file?
Message-Id: <3AD4982A.FFDFBD8B@home.com>
nobull@mail.com wrote:
>
> Indirect object syntax for constructors is deprecated.
Sez who?
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Wed, 11 Apr 2001 17:38:24 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: How to redirect between STDOUT and a file?
Message-Id: <kE0B6.817$T3.193881600@news.frii.net>
In article <3AD4982A.FFDFBD8B@home.com>,
Rick Delaney <rick.delaney@home.com> wrote:
>nobull@mail.com wrote:
>>
>> Indirect object syntax for constructors is deprecated.
>
>Sez who?
>
Depricated might be too strong a word. Maybe contra-indicated would be
better. From perlobj...
WARNING
While indirect object syntax may well be appealing to
English speakers and to C++ programmers, be not seduced!
It suffers from two grave problems.
YMMV
chris
--
This space intentionally left blank
------------------------------
Date: Wed, 11 Apr 2001 18:00:10 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: How to send a formatted string through a socket?
Message-Id: <KY0B6.819$T3.191130624@news.frii.net>
In article <9b11gi$g22$1@nets3.rz.RWTH-Aachen.DE>,
Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
>Hi!
>
>I've recently come to hit a problem that is really puzzling me and does
>not seem to be covered very well by any documentation.
>Assuming I have a function that shall print a well formatted table using
>printf running a for-loop and with a header coming on top of the table:
>
[...]
>
>This actually prints the table on the machine running the server and is
>doing fine. But as the request comes from a client the output must go to
>it as well.
It looks to me that something is missing from your explanation. I expect
that you are using Term::ANSIColor which eplains the "BLUE, GREEN" stuff.
You don't describe what sort of socket we are talking about or, unless I
missed it, what os you are running under. More data and a small but
comlete bit of test code that exibits the problem would help us help you.
Have a good day
chris
--
This space intentionally left blank
------------------------------
Date: Wed, 11 Apr 2001 10:43:04 -0700
From: "Chris Hess" <chris.hess@intel.com>
Subject: HTTP_X_FORWARDED_FOR???
Message-Id: <9b253b$8va@news.or.intel.com>
I'm trying to write a perl/cgi page that gets the client's ip address
through a proxy server. But for some reason I can not retrieve the correct
environment variables.
HTTP_VIA
HTTP_X_FORWARDED_FOR
Is there anything special you have to do to Apache to get it to pass these
to the CGI scripts?
What reasons could prevent me from retrieving these like any other
environment variable?
Chris
------------------------------
Date: Wed, 11 Apr 2001 17:21:43 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: inheritance within one file?
Message-Id: <x7wv8rnyhk.fsf@home.sysarch.com>
>>>>> "A" == Abigail <abigail@foad.org> writes:
A> I was more thinking something like:
A> use Exporter;
A> @EXPORT = qw /constructor/;
A> sub new {
A> ... yada, yada, yada ...
A> bless $obj => $class;
A> }
A> sub constructor {
A> __PACKAGE__ -> new (@_)
A> }
A> Inheritors can call new(), or SUPER::new(), users can call constructor().
that was similar to what i thought you meant. the problem i see is with
constructor name collision. that is why naming constructors 'new' and
using the direct method call with the class name never has a name space
problem or any ambiguity:
$obj = FOO->new() ;
can mean only one thing.
$obj = constructor( blah ... ) ;
is not clear what it is constructing. so the name needs to reflect the
class anyway and needs to be unique enough to not collide with other
similar names.
so i would stay clear of exporting constructors. i feel it is more
trouble than it's worth.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Wed, 11 Apr 2001 16:44:25 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: LWP - HTTPS
Message-Id: <JR%A6.60265$V6.400175@news1.gvcl1.bc.home.com>
In article <9b0p7n$cqg$1@newsx.cc.uic.edu>,
"Enrico Ng" <ng@fnmail.com> writes:
>I want to use LWP to get a https page.
>when I use get, I get nothing, I am assuming this is because of https
>does anyone know what option I need to use to get it to work?
Check out the lwpcook file that came with LWP, the cook book:
URLs with https scheme are accessed in exactly the same way as
with http scheme, provided that an SSL interface module for
LWP has been properly installed (see the README.SSL file
found in the libwww-perl distribution for more details). If no SSL
interface is installed for LWP to use, then you will get ``501
Protocol scheme 'https' is not supported'' errors when accessing
such URLs.
README.SSL says:
Encryption support is obtained through the use of Crypt::SSLeay or
IO::Socket::SSL, which can both be found from CPAN. While libwww-perl
has "plug-and-play" support for both of these modules (as of v5.45),
the recommended module to use is Crypt::SSLeay. In addition to
bringing SSL support to the LWP package, IO::Socket::SSL can be used
as an object oriented interface to SSL encrypted network sockets.
Any time you want to do something that many other people will also have
wanted to do, it's likely to have been documented already.
--
Peter Scott
------------------------------
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 676
**************************************