[10286] in Perl-Users-Digest
Perl-Users Digest, Issue: 3879 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 2 21:07:55 1998
Date: Fri, 2 Oct 98 18:00:30 -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 Fri, 2 Oct 1998 Volume: 8 Number: 3879
Today's topics:
Re: CGI to CGI <gellyfish@btinternet.com>
converting integers to bit vectors <tduffy@atl.com>
Re: Email parser <gellyfish@btinternet.com>
Re: Find NbOfCpu <gellyfish@btinternet.com>
Re: Find NbOfCpu (Matt Knecht)
Function calls <ankola@purdue.edu>
Getopt::Std <corey@virtual-impact.com>
Re: Hangs - Netscape Enterprise Server 3.51 / Sybase we (Alan Barclay)
Re: How do I remove a carriage return or space from a s <aqumsieh@tigre.matrox.com>
Re: How do I remove a carriage return or space from a s (John Moreno)
Re: HTTP_REFERER missing when it shouldn't be (catnip)
Re: Messages I never read (Tad McClellan)
Re: Need IP Address Sort Subroutine <gellyfish@btinternet.com>
Re: open2 and open3 errors (Charles DeRykus)
Re: Perl as solution? (Tad McClellan)
Re: Perl search engine problem <gellyfish@btinternet.com>
Re: Perl, LWP and NT 4.0 <gellyfish@btinternet.com>
Re: Poll: How Did You Learn Perl? <gellyfish@btinternet.com>
Processing Files to Make Table <flanker@sonnet.ru>
Processing Files <flanker@sonnet.ru>
Puzzling \( @blah ) behaviour <Paul.Makepeace@POBox.com>
Re: Question about getopt.pl subroutine <gellyfish@btinternet.com>
Re: Redirect STDOUT To a File (Temporarily) <ajohnson@gpu.srv.ualberta.ca>
Re: Redirect STDOUT To a File (Temporarily) (Larry Rosler)
Re: Redirect STDOUT To a File (Temporarily) (Douglas SEAY)
Script does not write to file <rob@ccsn.com>
Re: send geroge reese (was Re: Call for Participation: <zenin@bawdycaste.org>
Re: Solution found! (Ethan H. Poole)
Re: system() and `` on Win32 <gellyfish@btinternet.com>
Tutorial <wick@cablenet-va.com>
Re: Tutorial <dwatanab@uci.edu>
Re: Web crawler? <gellyfish@btinternet.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 2 Oct 1998 19:16:56 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: CGI to CGI
Message-Id: <6v38r8$19n$1@gellyfish.btinternet.com>
On 29 Sep 98 14:16:56 GMT Swetal Jariwala <swet@world.waena.edu> wrote:
> I have a web form that has only one parameter, a user ID. Once the
> user clicks on the Submit button my Perl CGI script is called. The
> problem now is that my script needs to send that user ID to another
> CGI script to do a lookup in a database. Get the record associated
> with user ID and inject that into a Notes database. Anyone have any
> idea how to go about doing this? The perl script is on a Win32
> platform. Thanks for all help.
You will probably find that the module LWP::UserAgent (from libwww-perl
available from CPAN) will allow you to do this. The basic idea is to
have your first script behave like a web browser which can be done without
the use of LWP however there use does make the whole thing a little
simpler and without wheel re-invention. Actually I remember that the LWP
suite is bundled with most recent Win32 Perls.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Thu, 1 Oct 1998 10:13:44 -0700
From: "Tom Duffy" <tduffy@atl.com>
Subject: converting integers to bit vectors
Message-Id: <6v0d7a$dh4@sunshine.atl.com>
Hi,
I'm attempting to convert integers to bit vectors so that I can access the
individual bits of the data words and I'm having trouble using pack, unpack,
vec. I've tried various templates (c, S, N, ...) and combinations of pack
and unpack. Here's an example:
$data = 0x2345;
$vecdata = pack("S*", $data);
# print out the bits to see what happened
for $i (0 .. 15) {
print(vec($vecdata, $i, 1) . " ");
}
print "\n";
This prints
1 1 0 0 0 1 0 0 1 0 1 0 0 0 1 0
# 4 5 2 3 (after reversing the bit order)
I'm trying to get the data in a bit vector format so that I can access the
bit by a bit index. I would expect the above code to put out something like
this (assuming the bits were being dumped out from high to low):
0010 0011 0100 0101
# 2 3 4 5
Thanks for any help,
Tom
------------------------------
Date: 2 Oct 1998 18:58:20 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Email parser
Message-Id: <6v37oc$19h$1@gellyfish.btinternet.com>
On 29 Sep 1998 06:29:12 GMT Phil C <phil-att@worldnet.att.net> wrote:
> Is there a way ot read Emails from a perl script and parse its
> informations. I'm trying to filter automatically some of my incoming
> Emails like a UNIX tool called "Filter" used to do.
> Does anyone know where I can get access to such a script?
A combination of procmail and Perl scripts using the MailTools suite of
modules available from CPAN should be able to do everything you wish.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 2 Oct 1998 19:19:15 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Find NbOfCpu
Message-Id: <6v38vj$19r$1@gellyfish.btinternet.com>
On Tue, 29 Sep 1998 11:24:34 -0400 Christopher Marquis
<Christopher.Marquis@fairchildsemi.com> wrote:
> Does anyone know of a module, function or some spawned shell trick to
> find the number of cpu's running on a Solaris or HP/UX box?
I have always found that a screwdriver helps :-P
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Fri, 02 Oct 1998 23:40:55 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Find NbOfCpu
Message-Id: <bwdR1.1401$7Q6.9068824@news2.voicenet.com>
Christopher Marquis <Christopher.Marquis@fairchildsemi.com> wrote:
>Does anyone know of a module, function or some spawned shell trick to
>find the number of cpu's running on a Solaris or HP/UX box?
A quick hack for Solaris:
perl -we '$_ = `/bin/mpstat`; print "Num CPU: ", (tr/\n// - 1), "\n";'
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: Fri, 02 Oct 1998 19:50:16 -0500
From: Atul Ankola <ankola@purdue.edu>
Subject: Function calls
Message-Id: <361574C8.265F7115@purdue.edu>
I was wondering how to call another function from antoher file. For
example: I am in FILE1 and I want to call a function that is in FILE2.
Is there a way to do that?
------------------------------
Date: Fri, 02 Oct 1998 23:39:01 GMT
From: Corey <corey@virtual-impact.com>
Subject: Getopt::Std
Message-Id: <Pine.LNX.3.95.981002120127.1624u-100000@rainier.devel.virtual-impact.com>
Hello there,
I've found myself at somewhat of a loss in implementing a
nice way of issuing a usage function under the circumstance
in which a correct option is specified ( as declared via
a 'getopts' statement ), but is lacking an argument.
As I have found, if a valid option ( $opt_e for demonstration
purposes ) is passed but does not contain an argument, rather
than issueing a syntax error ( such as 'Option requires
argument' or some such ) or even defining $opt_e as empty,
Getopt::Std seems to simply discard it completely, making it
very difficult to present a usage clause under the above
scenerio - because I can't say "present error if $opt_e
exists but is empty, otherwise process $opt_e as normal".
i.e., something similar to:
#!/usr/bin/perl
use Getopt::Std;
getopts('e:');
if (defined $opt_e) {
($opt_e eq "") and die "needs argument");
&do_stuff;
}
Instead what I have to do is manually scan @ARGV for instances
of valid getopts which are passed without an argument.
This seems kinda cheezy. But perhaps I'm just being petty
and excessively lazy ( or more likely, simply ignorant ).
e.g.
...
use Getopt::Std;
# ridiculous hack follows
#
($args="@ARGV")=~s/-/:-/g; ## allow for arguments which contain '-'
foreach (split /:/, "$args") {
SWITCH: {
/^-l$/ && (print("\'$_\' requires argument\n"), &usage);
/^-e$/ && (print("\'$_\' requires argument\n"), &usage);
}
}
getopts('e:vil:');
sub usage { print("Way lame.\n") }
$opt_e and &do_stuff;
$opt_l and &do_other_stuff;
...
While the above example works, I'd like to know whether
there is a 'better' way? Is there a more intelligent Getopt
of module that I'm not aware of?
Any clues are much appreciated - Thanks.
Beers,
Corey
corey@virtual-impact.com
Who's your leader, which is your flock.
-- Crass
------------------------------
Date: 2 Oct 1998 22:55:36 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Hangs - Netscape Enterprise Server 3.51 / Sybase web.sql 1.2 / Solaris 2.6
Message-Id: <907368932.571508@elaine.drink.com>
In article <36112D33.8D282585@mtnlake.com>,
Scott McIntosh <scott@mtnlake.com> wrote:
>Our problem is that the Netscape web server hangs in an unpredictable
>way. It doesn't seem to be related to a given page request, and doesn't
>happen at predictable intervals. SQL Server is generally behaving
>quite well. The one similarity, is that the pstack for ns-httpd looks
>about the same each time it hangs (see below). Perl_sv_grow() attempts
>to resize a string, and then blocks while trying to allocate more
>memory. After this, the web server won't respond to any more requests.
>We're not sure whether a web.sql thread is dead-locking with one of its
>own, or with something else. Perhaps we have a bad combination of
>Solaris patches and ns-httpd revs? We're stuck.
We had the exact same problem 18 months ago trying to get web.sql working
under Enterprise 2.0a/Solaris 2.5.1. After weeks talking to both Sybase &
Netscape, we eventually gave up and stuck to Netscape Commerce server until
the project was junked.
My own personal feeling is that web.sql's functionality should be
possible to replicate with freely available alternatives, and this
would probably be the way I'd go.
------------------------------
Date: 02 Oct 1998 17:30:54 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: How do I remove a carriage return or space from a string?
Message-Id: <x3yhfxmejn5.fsf@tigre.matrox.com>
Sergio Bernardo <sergio@mail.pt> writes:
>
> If there is always someting (' ' or '\n' or other char), you
> simply have to use chop:
>
> chop($hello);
>
> --> removes last character from string!
>
> if you are not shore there is always an extra char, it's better
> to use someting like this:
>
> $hello =~ s/^(\w+).*/$1/s || warn "Invalir Hello!\n";
Wow .. this is impressive!!
But, personally, I will stick to using chomp() instead of chop() or
your regexp.
--
Ala Qumsieh | No .. not Just Another
ASIC Design Engineer | Perl Hacker!!!!!
Matrox Graphics Inc. |
Montreal, Quebec | (Not yet!)
------------------------------
Date: Fri, 2 Oct 1998 18:30:35 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: How do I remove a carriage return or space from a string?
Message-Id: <1dga99l.5i8y4oyvehpxN@roxboro0-028.dyn.interpath.net>
Larry Rosler <lr@hpl.hp.com> wrote:
> [Posted to comp.lang.perl.misc and a copy mailed.]
>
> John Moreno <phenix@interpath.com> says...
-snip about $hello =~ s/\s*$//g; -
> > Right, TMTIWTDI - but using both is a waste.
>
> Heck, no. They are not related at all.
>
> Using '+' (or '*' less efficiently) is not superfluous. It is required
> by the problem specification ('remove all the whitespaces').
>
> Using 'g' is superfluous, because of the '$' anchor ('at end of string').
>
> 'using both' is not a waste -- it is a non sequitur.
You'd think that by now I'd have learned to test before posting - my
brain wasn't working and I thought that the $/g combo would work in a
way which it obviously doesn't.
--
John Moreno
------------------------------
Date: Fri, 02 Oct 1998 22:43:14 GMT
From: catnip8@geocities.com (catnip)
Subject: Re: HTTP_REFERER missing when it shouldn't be
Message-Id: <361556c5.5147241@news.nucleus.com>
On Fri, 2 Oct 1998 09:52:15 -0700, "Richard Waddell"
<richw3@ix.netcom.com> wrote:
>Greetings,
>
>This is really a CGI question, but I haven't found a CGI newsgroup.
There is one: It's comp.infosystems.www.authoring.cgi
Good luck.
catnip
------------------------------
Date: Fri, 2 Oct 1998 16:35:47 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Messages I never read
Message-Id: <jvg3v6.db3.ln@flash.net>
Elaine -HappyFunBall- Ashton (eashton@bbnplanet.com) wrote:
: Andy Lester wrote:
: > For all the novices out there, here are some sure ways to get the more
: > knowledgeable of us to ignore your message:
: Yeah, just put 'Hot Sex Here' in the title and I'm sure it will get read
: first :) *mwwahaahaa*
The males among us will read something sexual into that...
: /me just trying to lighten a friday afternoon :)
It worked.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 2 Oct 1998 19:48:02 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <6v3ali$19v$1@gellyfish.btinternet.com>
On 30 Sep 1998 12:03:45 -0400 Uri Guttman <uri@camel.fastserv.com> wrote:
> try this (tested):
> perl -MSocket -le 'print join( "\n", map{ inet_ntoa($_) } sort map
> {inet_aton $_ } <>)'
Now that was the one I was waiting for.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Fri, 2 Oct 1998 20:39:28 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: open2 and open3 errors
Message-Id: <F07w1s.I3H@news.boeing.com>
In article <6uovu3$8mc$1@nnrp1.dejanews.com>,
<mwwenzel@my-dejanews.com> wrote:
> When open2() or open3() fails because the exec of the program to run fails,
> is there a way to catch it?
>
> I have been using the following as a work-around:
> use open3()
> do a select on the error file handle with a 1 sec timeout
> if select returns 1 then there is an error
>
> I have tried $pid = open2(....) or die ....
>
> I have also tried it in an eval block ... nothing seems to work.
>
$pid = open3( \*WTRFH, \*RDRFH, \*ERRFH, "/path/program 2>&3")
or die ...
hth,
--
Charles DeRykus
------------------------------
Date: Fri, 2 Oct 1998 19:38:12 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl as solution?
Message-Id: <klr3v6.804.ln@flash.net>
Elaine -HappyFunBall- Ashton (eashton@bbnplanet.com) wrote:
: My neighbor has one of those darned car alarms that goes off every
: morning at 3am with that 'dive dive dive' sound.
: For hours.
: I would like to solve this annoying problem. Could perl help me develop
: a guidance system for the missile I would like to launch at it? Or
: should I just rely on my trusty tesla coil? Karo syrup in the oil? So
: many choices, so little sleep. Maybe I could stick one of those magnetic
: perl kits all over the hood?
Perhaps you could mention, in passing, to some street thugs
that the car alarm goes off at the same time every night.
Happens so often that nobody even looks out the window or
anything anymore.
With any luck, the car will be gone in the morning ;-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 2 Oct 1998 21:04:15 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Perl search engine problem
Message-Id: <6v3f4f$1ls$1@gellyfish.btinternet.com>
On Thu, 01 Oct 1998 17:40:51 -0500 Rick Payne <rickp@connect.ab.ca> wrote:
> Please help with code problem there seems to be a forever loop
> or something that is causing server overload.
> Please email me if you find the problem.
<snip>
> if ($ENV{'QUERY_STRING'} ne "") {
> @TempCheck = split (/=/, $ENV{'QUERY_STRING'});
<snip>
use CGI;
<snip>
> #######################
> # Parse Form Subroutine
> sub UnWeb {
> # Get the input
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> # Split the name-value pairs
> @pairs = split(/&/, $buffer);
<snip>
use CGI;
etc etc etc.
It might seem niggly but using a standard module such as CGI.pm does
start one off on the straight and narrow. It also makes it easier to
debug the code, easier to move between platforms and so on and so forth.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 2 Oct 1998 23:50:46 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Perl, LWP and NT 4.0
Message-Id: <6v3osm$1sg$1@gellyfish.btinternet.com>
On Thu, 01 Oct 1998 14:50:03 -0400 Erich L. Markert <erich@orator.usma.edu> wrote:
> I've got a web document mirror script that I've developed. It was originally designed to
> run on a UNIX box and I've successfully ported it to NT. I can run the program from the
> command line and all is well.
> The problem occurs when I try and schedule this program to run from the "at" command. The
> program IS executed (I know this because I receive an error message via email), but it
> isn't mirroring the web document that I specified (it does it fine from the command
> line). I know it's not an permission problem because I've given "Everyone" full access on
> the directory the mirrored document is being saved to and also the TEMP directory.
When running under the schedule service your program most likely is running as the
system user. You should check the users right to netwrok resources.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 2 Oct 1998 22:29:36 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <6v3k4g$1s3$1@gellyfish.btinternet.com>
On Tue, 29 Sep 1998 10:20:22 -0700 Phinneas G. Stone <phinneas@eskimo.com>
wrote:
> What does everybody think of Selena Sol's code?
$! = 1;
Need I say more.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 3 Oct 1998 02:35:04 +0300
From: "Michael Yevdokimov" <flanker@sonnet.ru>
Subject: Processing Files to Make Table
Message-Id: <6v3k0v$rqo$1@bison.rosnet.ru>
Hello Everyone!
Can anyone tell me how to...
So, I have a directory with a lot of .TXT and .ZIP files. I need in Perl
script, which will create a table with 3 rows (1: link to ZIP-archive, 2:
Description from TXT-file, 3: Archive's size). Note, that .TXT and .ZIP
files have equal filenames but different
extensions (.ZIP, .TXT) and we don't know the quantity of files in current
directory. Thus, we have to process unknown quantity of files!!!
Help me please to write this script! ;-)
Cheers,
Michael
--
Michael Yevdokimov (flanker@sonnet.ru)
--------------------------------------------------------------------------
Developers Support Site
Web: http://www.basicnet.sonnet.ru
E-mail: quests@basicnet.sonnet.ru
--------------------------------------------------------------------------
------------------------------
Date: Sat, 3 Oct 1998 02:24:30 +0300
From: "Michael Yevdokimov" <flanker@sonnet.ru>
Subject: Processing Files
Message-Id: <6v3jd6$rca$1@bison.rosnet.ru>
Hello
Can anyone tell me how to...
So, I have a directory with a lot of .TXT and .ZIP files. I need in Perl
script, which will create a table with
3 rows (1: link to ZIP-archive, 2: Description from TXT-file, 3: Archive's
size). Note, that .TXT and .ZIP files have equal filenames but different
extensions (.ZIP, .TXT).
Help me please to write this script! ;-)
Cheers,
Michael
--
Michael Yevdokimov (flanker@sonnet.ru)
--------------------------------------------------------------------------
Developers Support Site
Web: http://www.basicnet.sonnet.ru
E-mail: quests@basicnet.sonnet.ru
--------------------------------------------------------------------------
------------------------------
Date: Sat, 3 Oct 1998 00:04:37 +0100
From: "Paul Makepeace" <Paul.Makepeace@POBox.com>
Subject: Puzzling \( @blah ) behaviour
Message-Id: <6v3skh$5hs$1@statler.server.colt.net>
This is probably an easy one but I've been verbose.
Abstract: why does $a = \( @blah ) not always return scalar(@blah)?
perlref says:
Note that taking a reference to an enumerated list is
not the same as using square brackets--instead it's
the same as creating a list of references!
@list = (\$a, \@b, \%c);
I'm trawling through a large configuration file that contains large numbers
of frequently identical but long strings and storing them as part of another
data structure:
foreach my $id ($product->keys()) {
next unless $product->load($id)->RangeID eq $Range_ID;
my ($level, $element) = split ',', $product->Name;
$data{$level}{$element} = $product->IntervalList;
}
So $product->IntervalList is this
typically-large-and-oft-repeated-across-many-entries string. So, I cached it
and grabbed the reference: (why? hey, it's a late Friday night; better
suggestions welcome)
$data{$level}{$element} = \($time_cache{$product->IntervalList} = 1);
Now, why does this work? Surely, since \( ) is list of references of its
elements as per docs, when evaluated in a scalar context it would return the
number of elements? So why isn't my %data full of ones (i.e. length of list
in (), not the number 1 I have there) ?
paul:~$ perl -e '$b=1;$c=3; $a = \($b, $c); print $$a'
3
It's clearly (er, to me) not behaving like a normal list operator but
applying the scalar context to the thing _inside_ the \( ) which is
evaluating as a comma-operator rather than list separator. Why would it do
that? Where would I R about this in the FM?
Cheers,
Paul
--
Paul Makepeace, Independent Thinkers Ltd (UK)
0171 377 8668 / 0973 800436
"People are all monkeys, and I am Captain Banana"
-- Vincent Gallo
------------------------------
Date: 3 Oct 1998 00:02:18 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Question about getopt.pl subroutine
Message-Id: <6v3pia$1t9$1@gellyfish.btinternet.com>
On Thu, 01 Oct 1998 14:50:30 -0400 Steve Harrison <stevehar@newbridge.com> wrote:
> According to the Camel book, when the &Getopt subroutine is called with
> a switch, but no
> argument, the variable $opt_x (where x is the switch name) should take
> the value 1 (pg 404).
Ah, that'll be the Pink Camel (the first edition) which was written for
Perl 4. You would probably be served well by an upgrade to the Blue one
which is updated for Perl 5 (if you are still using Perl 4 you should
upgrade that for reasons that are so often rehearsed here I wont bother
with them).
You probably should be using Getopt::Std. The getopt subroutine will
take an optional hash reference to contain your switches.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Fri, 02 Oct 1998 16:55:01 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Redirect STDOUT To a File (Temporarily)
Message-Id: <36154BB5.58EEB20B@gpu.srv.ualberta.ca>
TERENCE MURPHY wrote:
! Hi,
!
! I would like to temporarily redirect STDOUT to a different file.
!
! So a program would be something like this:
!
! printf "a\n";
! # do some magic to redirect stdout to a different file
! # then...
! printf "b\n";
! # do some magic to restore stdout
! # then...
! printf "c\n";
!
! So, "a" and "c" would be written to stdout, and "b" would be
! written to some file. What's the best way to do this? Or should
! I just convert the "b" line to fprintf and open a file?
oh, you can try fprintf ... but when that doesn't seem to
work as expected you can take a look at the documentation for
the open() function ... it has an example for redirecting and
restoring STDOUT:
perldoc -f open
regards
andrew
------------------------------
Date: Fri, 2 Oct 1998 15:06:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Redirect STDOUT To a File (Temporarily)
Message-Id: <MPG.107eee3ccaab08dd9897de@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <6v3h2r$22k$1@vixen.cso.uiuc.edu> on 2 Oct 1998 21:37:31 GMT,
TERENCE MURPHY <tsmurphy@cs.uiuc.edu> says...
...
> I would like to temporarily redirect STDOUT to a different file.
...
> So, "a" and "c" would be written to stdout, and "b" would be
> written to some file. What's the best way to do this? Or should
> I just convert the "b" line to fprintf and open a file?
C-PROGRAMMER ALERT!!!
There is no 'fprintf' in Perl. You have the right idea, though. You
should open a file (and *test* that it opened correctly :-), and then do
printf FILE_HANDLE "b\n";
or whatever.
BTW, do you really want to use 'printf' when there are no conversion
specifiers in the first argument? 'print' is better (simpler and
faster). `perldoc -f print`.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 2 Oct 1998 22:15:00 GMT
From: doug@kittycat.france.seay (Douglas SEAY)
Subject: Re: Redirect STDOUT To a File (Temporarily)
Message-Id: <slrn71ak2u.nc.doug@kittycat.france.seay>
On 2 Oct 1998 21:37:31 GMT, TERENCE MURPHY <tsmurphy@cs.uiuc.edu> wrote:
>
>I would like to temporarily redirect STDOUT to a different file.
OK, this isn't that hard. It is described in the docs. Try
"perldoc -f open | less" to read how to do it.
>So a program would be something like this:
<snip>
>So, "a" and "c" would be written to stdout, and "b" would be
>written to some file. What's the best way to do this? Or should
>I just convert the "b" line to fprintf and open a file?
Well, fprintf() is C, not Perl. I think
print STDOUT "a";
print FILE "b";
print STDOUT "c";
is fairly readable and doesn't involve any voodoo.
>Thanks in advance.
No problem
- doug
------------------------------
Date: Fri, 2 Oct 1998 19:22:10 -0500
From: "Roberto Cerini" <rob@ccsn.com>
Subject: Script does not write to file
Message-Id: <6v3qoh$em8@nnrp1.farm.idt.net>
My script has the following lines in it:
open(testfile,"/home/user/public_html");
print testfile "This is a test\r\n";
close testfile
When I run the script, nothing happens to the testfile (which I have already
created).
Any suggestions?
--
Roberto Cerini
rob@ccsn.com
------------------------------
Date: 3 Oct 98 00:51:26 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: send geroge reese (was Re: Call for Participation: Python Conference)
Message-Id: <907376089.474707@thrush.omix.com>
Abigail <abigail@fnx.com> wrote:
: Jonathan Biggar (jon@floorboard.com) wrote on MDCCCLVIII September
: MCMXCIII in <URL:news:361435F6.702C6EDD@floorboard.com>:
: ++
: ++ Not to brag :-), but I am partly to blame for Perl 5, by pushing Larry
: ++ to add the OO stuff.
:
: So, it's you who I need to club over his head because of the ugly
: mess Perl OO is? ;)
:
: Luckely, there's a cleaner way: closures. With (multiple) inheritance and
: autoloading.
Luckely, there's a cleaner way: upgrade to 5.005+. With core
support for private fields, compile time field name checks, and
real exception object support.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: 2 Oct 1998 22:10:28 GMT
From: ehp@gte.net (Ethan H. Poole)
Subject: Re: Solution found!
Message-Id: <6v3j0k$f4g$1@news-2.news.gte.net>
[Posted and Emailed] In article <3615422B.FAC0A27@bbnplanet.com>,
eashton@bbnplanet.com says...
>
>Eric Von Zee wrote:
>
>> sub 12gauge_shotgun {
>> $planet =~ s/neighbor//;
>> } #end sub 12gauge_shotgun
>
>No, too violent. I'm a kind-hearted soul who just wants some sleep.
>
>Perl is going to help with this solution though :) A pilot with perl, a
>bit of sophisticated military tech from work and a radio to blast Celine
>Dion singing that damned Titanic song. I may start wretching but it
>should get the message across. If not, there is always the monster tesla
>coil that will have the mechanics scratching their heads. *mwaahaahaa*
>God I love working with engineers.
A 12-gauge shotgun is too violent, but a well directed missile isn't?
<chuckle>
How about a high energy microwave pulse -- it has much greater range than a
tesla coil and should equally confuse the mechanics.
--
Ethan H. Poole | Website Design and Hosting,
| CGI Programming (Perl & C)..
========Personal========= | ============================
* ehp @ gte . net * | --Interact2Day--
http://home1.gte.net/ehp/ | http://www.interact2day.com/
------------------------------
Date: 2 Oct 1998 22:15:19 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: system() and `` on Win32
Message-Id: <6v3j9n$1r6$1@gellyfish.btinternet.com>
On Fri, 02 Oct 1998 06:36:09 +0200 Martin Vorlaender <martin@RADIOGAGA.HARZ.DE> wrote:
> See my response on the thread "Help with system() on NT", and remember that
> PWS really is IIS2 (3?).
Apart from this "Option Pack" thing that comes with Visual InterDev which is
more like IIS4 of course.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Fri, 2 Oct 1998 18:06:54 -0400
From: "Chad S. Skiles" <wick@cablenet-va.com>
Subject: Tutorial
Message-Id: <6v3iod$7q7@enews2.newsguy.com>
Does anyone know where I can get a good offline tuorial for perl?
------------------------------
Date: Fri, 02 Oct 1998 16:38:51 -0700
From: dana watanabe <dwatanab@uci.edu>
To: "Chad S. Skiles" <wick@cablenet-va.com>
Subject: Re: Tutorial
Message-Id: <361563BD.C2B35A5@uci.edu>
Sitting right next to my keyboard is a book called "Learning Pearl, 2nd
Edition"
http://www.oreilly.com/catalog/lperl2/
Has more info.
I havent read it, but read the 1st edition which was incredibly helpful.
Make sure you get the 2nd edition with the blue (cyan) cover.
(i'm not sure why the picture at the above URL has magenta.)
Chad S. Skiles wrote:
> Does anyone know where I can get a good offline tuorial for perl?
------------------------------
Date: 3 Oct 1998 00:09:16 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Web crawler?
Message-Id: <6v3pvc$1tg$1@gellyfish.btinternet.com>
On Wed, 30 Sep 1998 22:56:24 +0100 Stewart Taylor <stewart.taylor@skt.co.uk> wrote:
> I need to produce a script which will get a document from a particular URL,
> read some data from specific lines, and save it to a file, several times
> over. Is there a source of scripts for this type of function?
If you have the libwww-perl (LWP) library of modules then you should have
the script lwp-request which will do this.
If you dont have the modules it is available from CPAN.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3879
**************************************