[16612] in Perl-Users-Digest
Perl-Users Digest, Issue: 4024 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 15 14:05:32 2000
Date: Tue, 15 Aug 2000 11:05:16 -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: <966362715-v9-i4024@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 15 Aug 2000 Volume: 9 Number: 4024
Today's topics:
Re: [Perl] invalud method (Colin Keith)
Re: [Perl] offline mode (Helgi Briem)
Re: Accessing ODBC data using PERL (Colin Keith)
Re: Array Printing <lr@hpl.hp.com>
Re: being able to change the name of a file on the serv <star@sonic.net>
Re: CHOMP not working (Colin Keith)
Re: Compilation error for 5.6 under win32 (Colin Keith)
Re: date and time in perl (Colin Keith)
edit multiple files with vi <lilyfu@bestedeal.com>
Re: edit multiple files with vi <care227@attglobal.net>
Re: edit multiple files with vi (Decklin Foster)
Re: edit multiple files with vi <lilyfu@bestedeal.com>
Re: edit multiple files with vi (Mike Stok)
Re: edit multiple files with vi <newsposter@cthulhu.demon.nl>
Re: Get ip from visitor nobull@mail.com
Re: Help a little needed from regex expert please (Colin Keith)
Re: Multiline regexp search and replace? <lr@hpl.hp.com>
Re: Passwords (Abigail)
Perl - Blinking Text (Louis)
Re: Perl - Blinking Text (Steven M. O'Neill)
Re: Perl - Blinking Text (Greg Bacon)
Re: Perl - Blinking Text <tony_curtis32@yahoo.com>
Re: Perl - Blinking Text (BUCK NAKED1)
Re: Perl - Blinking Text (fvw)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 15 Aug 2000 17:40:26 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: [Perl] invalud method
Message-Id: <egfm5.134$DT4.3750014@nnrp2.clara.net>
In article <8na9q6$bc$1@nnrp1.deja.com>, bolero92@my-deja.com wrote:
>I am writing a CGI Perl script for users to change their e-mail
>forwarding settings the script will change /etc/mail/aliases and run /usr/bin/newaliases
>this script is setuid to root
Please read the FAQ's on security.
>when the script runs until the following lines, error was shown in
>Apache error_log:
>system("/usr/bin/cp /etc/mail/aliases.save /etc/mail/aliases");
>system("/usr/bin/newaliases");
Er, don't mess about with the system aliases file, get a mail server
that supports .forward files so users can set those.
>1) What does the error "Invalid method in request quit" means?
Your web server is being sent a request 'quit' it should be sent a valid
HTTP request such as "GET / HTTP/1.0" I.e. you get it if you:
telnet www.myserver.com 80
quit
>2) When I change to:
>`/usr/bin/cp /etc/mail/aliases.save /etc/mail/aliases`;
>`/usr/bin/newaliases`;
use File::Copy;
if(copy($file1, $file2)){ ... }
>the first line can be executed, but the second line can't be executed,
>Why?
*shrug* catch the output. If you don't see how, look at the man page for
perlop in the `STRING` qx/STRING/ section, or open it with open(), if you
use system() you'll get the exit code. You should also look at the
description given in perlfaq8
"What's wrong with using backticks in a void context?"
and you'll learn why what you're doing is making your program do more work
than it has to. (perldoc -f backticks will turn up a few related articles)
>3) What is the difference between ` and system()?
See the above perlfaq entry and more importantly the entry for 'system' in
the perlfunc docs. In summary `` returns the output of the executed program,
system() returns the exit code of the program, but I'll leave you and other
interested parties to look at these :)
> Sent via Deja.com http://www.deja.com/
Why's everyone send through Deja, but not use its search facilities?
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Tue, 15 Aug 2000 16:49:24 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: [Perl] offline mode
Message-Id: <39997260.111072964@news.itn.is>
On Tue, 15 Aug 2000 01:27:56 GMT, bolero92@my-deja.com
wrote:
>I'm writing CGI Perl script
>I found that Apache error logs generate the following error message
>while running this script:
>
Apache error logs don't generate anything, but errors
generated by the Apache web server get written to
them.
>(offline mode: enter name=value pairs on standard input)
>
This is not an error message and I don't see offhand
how it can end up in your Apache error log. This
is what you see when you run a properly written
CGI script from the command line rather than
through a web browser/server.
>What does this line mean?
>
It means that you are running a CGI script in
offline mode and that you should enter
name=value pairs on standard input
What could possibly be clearer?
If you enter, for example (this depends on
the script parameters):
NAME="bolero92"<ENTER>
SERVER="deja.com"<ENTER><ctrl-D>
your script should run.
PS Incidentally, your subject line is worng. This
question has nothing whatsoever to do with
Perl.
Regards and good luck,
Helgi Briem
------------------------------
Date: Tue, 15 Aug 2000 17:49:19 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Accessing ODBC data using PERL
Message-Id: <zofm5.135$DT4.3751163@nnrp2.clara.net>
In article <8n9bto$3sd$1@newsg3.svr.pol.co.uk>, "DAWallace" <darwal@altavista.net> wrote:
>Hello Everybody,
>I'm trying to extract information from a Microsoft Access database using
>PERL. Here's the code...
>
> print "Content-Type: text/html\n\n";
> print "Hello World<br>";
> use OLE;
> $cnKwiz = CreateObject OLE "ADODB.Connection" or die "Create Object :
>$!";
> $cnKwiz->Open('kwizCom');
> $sql = "Select * from TKC~1~01";
> $rsKwiz = $cnKwiz->Execute($sql);
> $out = $rsKwiz->FIELDS('Question')->VALUE;
> print $out;
>
>and I'm receiving the following error...
>
> Can't call method "FIELDS" on an undefined value at "odbc_test.pl" line
>8.
That means that the object you're making the query on ($rsKwiz - nice naming
convention :) isn't an object. I would guess that what's happened is
that your Execute() failed. You should *always* check the return value from
your sub routines if they can return more than one value. So in this case
try something like:
if(!($rsKwiz = $cnKwiz->Execute($sql)){
print "Error executing SQL code ";
}
But you'd need to check the OLE docs to see what the return value is (undef
or 0 is most likely) and how to query the error status from the OLE ob.
Maybe something like:
print $cnKwiz->errstring();
But, see the docs:)
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Tue, 15 Aug 2000 09:23:59 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Array Printing
Message-Id: <MPG.14030e756697d05498ac7d@nntp.hpl.hp.com>
In article <8nb3ci$5u5$1@provolone.cs.utexas.edu>, logan@cs.utexas.edu
says...
> In article <MPG.14026795b4b5d36598ac7b@nntp.hpl.hp.com>,
> Larry Rosler <lr@hpl.hp.com> wrote:
...
> >Also, the many calls to print do *not* translate to many system calls to
> >write, because of buffering in the stdio library.
...
> Second, though, I have to point out that, according to tests I just
> did, a system call actually will be made for each line of output, at
> least if the output is a terminal. (This is with perl 5.6.0 on
> Solaris 8.) This turns out to be the case whether you pass a list
> to print or whether you call print once for each item in the list.
When output is to a terminal, the performance is determined by the line
speed. Buffering concerns and the number of system calls are
essentially irrelevant.
When benchmarking code with printed output, always write to a file, or
to /dev/null for Unix or NUL for Windows/DOS.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 15 Aug 2000 17:48:26 GMT
From: arthur <star@sonic.net>
Subject: Re: being able to change the name of a file on the server,(here is the script)
Message-Id: <B5BE27B9.5C41%star@sonic.net>
in article B5BD1A3D.5687%star@sonic.net, arthur at star@sonic.net wrote on
8/14/00 2:38 PM:
> Hi all,
>
> Suppose there is a file that runs in a learning application on a server and
> I want different people to be able to change that file and save the version
> they changed as their own but not erase the other peoples version?
#!/usr/bin/perl -w
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use IO File;
use strict;
use File::Copy;
print header;
print start_html('A Simple Example'),
hr,
start_form,
"The name of your game is: ",textfield('$name'),
p,
"What are your questions? ",textfield('$question'),
p,
"What are your answers? ",textfield('$answer'),
p,
submit,
end_form,
hr;
if (param()) {
print
"The name of your game is: ",em(param('$name')),
p,
"Your questions are: ",em(param('$question')),
p,
"The answers are: ",em(param('$answer')),
p,
print end_html;
p,
open (HOPE, ">/home/www_pages/star/dat.html") || die print "cant open:$!\n";
open (YES, ">/home/www_pages/star/dot.html") || die print "cant open: $!\n";
print (HOPE (param('$question')));
print (YES (param('$answer')));
p;
close HOPE;
close YES;
hr;
print end_html;
symlink("name","dat.html") || die "cannot symlink to dat.html";
}
------------------------------
Date: Tue, 15 Aug 2000 15:13:25 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: CHOMP not working
Message-Id: <p6dm5.130$DT4.3737915@nnrp2.clara.net>
In article <3998A1C8.33DEC691@mail.com>, vrillusions@mail.com wrote:
>Notice how the </FONT></TD> is on a new line? Thats what I am trying to
Of course, you do realise that it doesn't make the slightest bit of
difference in HTML, multiple white spaces are folded into just 1 unless
you're inside <PRE> or <XMP> tags.
>I tried the chomp function in both places to see if it made a
>difference, and it didn't. Here is the datafile:
>
>1|Todd|1|vrillusions@mail.com|Geoto|Streetsboro, OH
>1|Lenny|1|mack@thehdcafe.com|FuzzyLogix|Akron, OH
>0|Jim|1|jim@aol.com|GymSlayer|Somewhere, IN
>1|Conan|0|Conan@aol.com|Conan the Barbarian|Unknown, CA
# do header bit making the header/tables
open(FH, "<datafile") || die "Content-Type: text/html\n\n Ack - $!";
my($td_font) = ' <TD><FONT FACE="Verdana, Arial" SIZE=2>';
my($font_td) = '</FONT></TD>';
while(<FH>){
/^\d\|(\w+)\|\d\|(.+)\@([a-zA-Z0-9\.-]+)\|([^\|]+)\|(.+?)\s*$/;
print "<TR ALIGN=\"LEFT\">\n",
"$td_font<A HREF=\"mailto:$2\@$3\">$1</A>$font_td\n",
"$td_font$4$font_td\n",
"$td_font$5$font_td\n</TR>\n\n";
}
or:
while(<FH>){
@_ = (split('\|', $_))[1,3,4,5];
next if($#_ != 3); # for any spaces/broken lines
$_[3] =~ s/\s+$//; # strip training CR/LF/space/fish
print "<TR ALIGN=\"LEFT\">\n",
"$td_font<A HREF=\"mailto:$_[1]\">$_[0]</A>$font_td\n",
"$td_font$_[2]$font_td\n",
"$td_font$_[3]$font_td\n</TR>\n\n";
}
Cus its hot and I'm lazy :)
The ([^|]+) is because I've seen some weird stuff in people's call signs,
also note the \|'s because | in a regexp means to 'or', so a|b 'a' or 'b'
(which is why its such a pain that everyone uses it as a separating
character) Note also that this does *no* checking for validity of the data
(there is a .+ and [^|] in the regexp, so people can put dodgy code in
there+. (See, whoever it was that picked me up on this, I haven't
forgotten:)
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Tue, 15 Aug 2000 15:18:27 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Compilation error for 5.6 under win32
Message-Id: <7bdm5.131$DT4.3737945@nnrp2.clara.net>
In article <8n97a0$55s$1@nnrp1.deja.com>, kyberneticist@my-deja.com wrote:
>A quick search through the archives didn't show anything similar, so
>here goes.
Be more thorough cus this looks like an answer. Hopefully its the answer :)
http://x70.deja.com/getdoc.xp?AN=614641530&CONTEXT=966352502.
1436680210&hitnum=9
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Tue, 15 Aug 2000 15:25:57 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: date and time in perl
Message-Id: <9idm5.132$DT4.3738686@nnrp2.clara.net>
In article <spgpu228kn9129@corp.supernews.com>, "Lithium" <lithium@ev1.net> wrote:
>I've been busting my brains out trying to figure this one out...
Then your friend should be a good book or the perldoc command you will be
able to find out something in there that should give you a 'pointer' to
where to look. If you don't, check the FAQ's they contain a lot of little
gems of code.
>I'm trying to timestamp events in a script, but I can't find any way to get
>a good date or time. I know how to read the "time", but it's an
>incomprehensible large number that I can't sort anything out of. As for the
Er.. okay, so you must have missed localtime() I.e.:
print scalar(localtime(time()));
Nicely formatted in a standard fashion. Note the scalar(). This is used here
because print() will happily play with array context's and in an array
context localtime() gives the elements that make up the time and date -
hours, mins, secs, month, year ... etc.In a scalar format it prints the
nicely formatted string.
The date is part of this. Also look in the Time::* modules that come as part
of the standard install of Perl and I think CPAN has extra modules that do
funky things like julian calendars and so on <http://www.cpan.org/modules/>
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Tue, 15 Aug 2000 11:50:51 -0400
From: Lily Fu <lilyfu@bestedeal.com>
Subject: edit multiple files with vi
Message-Id: <399966DB.49EF0C3E@bestedeal.com>
Hi,
I want to write a program to automatic
edit multiples with vi, insert the same
text to multiple files.
How can I write a perl program to
accomplish this task?
The procedure is:
open file1 with vi
insert text
quit vi
go to another dir
open file2 with vi
insert text
quit vi
since vi takes input from STDIN and write to STDOUT,
is there a way todo this?
Thanks,
Lily
------------------------------
Date: Tue, 15 Aug 2000 11:53:55 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: edit multiple files with vi
Message-Id: <39996793.AB2BE803@attglobal.net>
Lily Fu wrote:
>
> Hi,
>
> I want to write a program to automatic
> edit multiples with vi, insert the same
> text to multiple files.
>
Why add vi to the mix? You can edit files right from Perl...
------------------------------
Date: Tue, 15 Aug 2000 16:08:15 GMT
From: decklin+usenet@red-bean.com (Decklin Foster)
Subject: Re: edit multiple files with vi
Message-Id: <PVdm5.20$CW2.704@news1.rdc1.ct.home.com>
Lily Fu <lilyfu@bestedeal.com> writes:
> since vi takes input from STDIN and write to STDOUT,
> is there a way todo this?
I think you are confusing vi and ed/ex, since vi is a screen editor.
What is it that you can do in vi that you cannot do in Perl?
--
There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)
------------------------------
Date: Tue, 15 Aug 2000 12:56:26 -0400
From: Lily Fu <lilyfu@bestedeal.com>
Subject: Re: edit multiple files with vi
Message-Id: <3999763A.3858FFA5@bestedeal.com>
OK, I use CVS to check in, out and commit
programs in a team environment.
I made a massive change on a bunch of files,
and I need to make cvs commit for each of the files.
from command, when I type in
cvs commit filename
it opens a vi window and ask me to type in some
comment.
That is the reason I want to write a perl
to automatically insert some comment
into each CVS commit log using vi.
Lily
Decklin Foster wrote:
> Lily Fu <lilyfu@bestedeal.com> writes:
>
> > since vi takes input from STDIN and write to STDOUT,
> > is there a way todo this?
>
> I think you are confusing vi and ed/ex, since vi is a screen editor.
> What is it that you can do in vi that you cannot do in Perl?
>
> --
> There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
> are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)
------------------------------
Date: Tue, 15 Aug 2000 17:02:14 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: edit multiple files with vi
Message-Id: <qIem5.4274$K5.89729@typhoon.austin.rr.com>
In article <3999763A.3858FFA5@bestedeal.com>,
Lily Fu <lilyfu@bestedeal.com> wrote:
>OK, I use CVS to check in, out and commit
>programs in a team environment.
>
>I made a massive change on a bunch of files,
>and I need to make cvs commit for each of the files.
>
>from command, when I type in
>
>cvs commit filename
>
>it opens a vi window and ask me to type in some
>comment.
>
>That is the reason I want to write a perl
>to automatically insert some comment
>into each CVS commit log using vi.
It's quite reasonable to set the CVSEDITOR enviromnment variable to a
program other than vi, possibly your own perl script.
David Blank-Edelman's "Perl for System Administration" book has examples
of this kind of thing.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ |
GPG PGP Key 1024D/059913DA | Fingerprint 0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work) | 75D2 9EC4 C1C0 0599 13DA
------------------------------
Date: 15 Aug 2000 17:30:28 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: edit multiple files with vi
Message-Id: <8nbunk$ef4$1@internal-news.uu.net>
Lily Fu <lilyfu@bestedeal.com> wrote:
> from command, when I type in
> cvs commit filename
> it opens a vi window and ask me to type in some
> comment.
> That is the reason I want to write a perl
> to automatically insert some comment
> into each CVS commit log using vi.
Read the cvs documentation. You can specify a message on the
command line.
Erik
------------------------------
Date: 15 Aug 2000 17:44:37 +0100
From: nobull@mail.com
Subject: Re: Get ip from visitor
Message-Id: <u9k8dio4ne.fsf@wcl-l.bham.ac.uk>
rune@clamon.dk writes:
> I want to get the ip-adress from the visitor on my homepage that
> executes my perl cgi-script. How is this possible?
It isn't possible, unless they are not using a proxy.
If you are happy getting the address of the proxy if they are using a
proxy then this can be found is one of the environment variables
passed to a CGI script. I won't tell you it's REMOTE_ADDR because
forcing you to read the manual is probably not a bad idea. (Damn!)
This has nothing whatever to do with Perl - the manual you are after
is the CGI manual (not the CGI.pm manual).
Remember that when writing CGI program in Perl to produce HTML content
on an HTTP server you have to be aware that you will encounter issues
relating to: Perl, CGI, CGI.pm, HTTP, HTML, your operating system,
your server software and programming in general. Learning to spot
which is which is a valuable skill to cultivate.
Your question is fundamentally about HTTP and CGI and so you should
have checked resources on those subjects.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 15 Aug 2000 15:52:21 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Help a little needed from regex expert please
Message-Id: <VGdm5.133$DT4.3740365@nnrp2.clara.net>
In article <4P2m5.63$ZC2.4296@nsw.nnrp.telstra.net>, "Robert Chalmers" <robert@chalmers.com.au> wrote:
>No match for "CCSCHINO.COM".
Looks like a whois reply :)
>What I need to do is extract ONLY the word between the "", ie, in this
>case - CCSCHINO.COM
/^No match for "([A-Z0-9]{3,60}\.[A-Z]{3})\"\.$/;
I think domain names have a minimum of 3 and max of 60
Why do you need to though. If it is a return from a whois query to internic,
you already know the domain because you sent it out .. ?
>Does anyone have any clues please.
*digs around down the back of the sofa* :)
I have a question in turn, why does turning the [A-Z]{3} into
[A-Z][A-Z][A-Z] make it slower? I would have assumed that the evaluation is
the same, but Benchmark tests give:
perl -w -Mstrict -MBenchmark
timethese(100000, {
three => sub { $_ = 'No match for "CCSCHINO.COM".';
/^No match for "([A-Z0-9]{3,60}\.[A-Z]{3})\"\.$/; },
fixed => sub { $_ = 'No match for "CCSCHINO.COM".';
/^No match for "([A-Z0-9]{3,60}\.[A-Z][A-Z][A-Z])\"\.$/; }
});
Benchmark: timing 100000 iterations of fixed, three...
fixed: 2 wallclock secs ( 1.72 usr + 0.00 sys = 1.72 CPU)
three: 2 wallclock secs ( 1.76 usr + 0.01 sys = 1.77 CPU)
(And this time I tested it is matching correctly :)
Pointers on where to look for details? (I did see the URLs in the 'grep()
optimisation' thread, but haven't had chance to read them yet :)
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Tue, 15 Aug 2000 09:51:37 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Multiline regexp search and replace?
Message-Id: <MPG.140314efa746b24a98ac7e@nntp.hpl.hp.com>
In article <8nbal3$h5g$1@lublin.zrz.tu-berlin.de>,
anno4000@lublin.zrz.tu-berlin.de says...
> <henrik.jonsson@se.adtranz.com> wrote in comp.lang.perl.misc:
> >Hi,
> >
> >I am trying to make a search and replace in a multiline string but I
> >can't get it to work.
> >
> >I have a textbox where the user can enter a description for a file.
> >This description is then stored in a text file with a single record per
> >line. But in order to store the record on one line I need to replace
> >the \n with <br>'s.
> >
> >I tried s/\n/<br>/gs but it didn't work.
The /s is superfluous, but that should 'work'! Is the operator bound to
the correct variable?
> Probably because the lines you get back from the text box are terminated
> with "\b\n".
I'm sure you meant to write "\r\n". But even if that is the way the
lines end, the regex shown should have inserted the desired <br>s.
In another thread, someone posted something like s/\r?\n/<br>/g, but
that seems like overkill.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 15 Aug 2000 15:15:00 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Passwords
Message-Id: <slrn8pinii.tj3.abigail@alexandra.foad.org>
Alex Buell (alex.buell@tahallah.clara.co.uk) wrote on MMDXLI September
MCMXCIII in <URL:news:6o7ipsol0ggc22lmmnergknhhgihd8q4tm@4ax.com>:
<> Other than using system("stty -echo") and system("stty echo"), are
<> there any other ways of concealing passowrds being entered?
system shutdown => -now;
Abigail
--
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
print+Just (), another (), Perl (), Hacker ();'
------------------------------
Date: 15 Aug 2000 15:13:53 GMT
From: louis@aol.com (Louis)
Subject: Perl - Blinking Text
Message-Id: <20000815111353.00174.00003174@ng-ch1.aol.com>
Hi. While my perl script is processing, I would like the print line "Please
wait, processing data .. " to blink at the command line (UNIX). Does anyone
know how I can get the text to blink?
Thanks,
Louis
------------------------------
Date: 15 Aug 2000 11:40:02 -0400
From: steveo@panix.com (Steven M. O'Neill)
Subject: Re: Perl - Blinking Text
Message-Id: <8nbo8i$kci$1@panix6.panix.com>
Louis <louis@aol.com> wrote:
>Hi. While my perl script is processing, I would like the print line "Please
>wait, processing data .. " to blink at the command line (UNIX). Does anyone
>know how I can get the text to blink?
while (1) {
print "foo";
sleep 1;
print "\b\b\b \b\b\b";
sleep 1;
}
--
Steven O'Neill steveo@panix.com
------------------------------
Date: Tue, 15 Aug 2000 15:59:07 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Perl - Blinking Text
Message-Id: <spiq6bsdkn9171@corp.supernews.com>
In article <20000815111353.00174.00003174@ng-ch1.aol.com>,
Louis <louis@aol.com> wrote:
: Hi. While my perl script is processing, I would like the print line
: "Please wait, processing data .. " to blink at the command line
: (UNIX). Does anyone know how I can get the text to blink?
Yuck. Just say no. How about a spinner?
#! /usr/local/bin/perl -w
use strict;
use POSIX ':sys_wait_h';
sub spin {
my @chars = qw[ - \ | / ];
if (my $pid = fork) {
# parent
local $| = 1;
while ( waitpid($pid, WNOHANG) != -1 ) {
my $c = shift @chars;
print "\rPlease wait; processing data... $c";
push @chars, $c;
select undef, undef, undef, 0.1;
}
print "\n";
}
elsif (not defined $pid) {
die "$0: failed fork: $!";
}
else {
# child
system(qw/ sleep 5 /) == 0
or die "$0: could not start sleep: $!";
exit 42;
}
}
spin;
print "Done.\n";
--
If my children will live a better life than I did by my getting brain damage,
by my being brain dead then let it be.
-- Mike Tyson
------------------------------
Date: 15 Aug 2000 11:02:19 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Perl - Blinking Text
Message-Id: <87k8di8qd0.fsf@limey.hpcc.uh.edu>
>> On 15 Aug 2000 15:13:53 GMT,
>> louis@aol.com (Louis) said:
> Hi. While my perl script is processing, I would like
> the print line "Please wait, processing data .. " to
> blink at the command line (UNIX). Does anyone know how
> I can get the text to blink?
Well, if the terminal type supports it:
perldoc Term::ANSIColor;
Or use something like
perldoc Curses
to provide overwriting capabilities (or do it with
backspaces yourself).
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: Tue, 15 Aug 2000 12:10:43 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Perl - Blinking Text
Message-Id: <21404-39997993-56@storefull-247.iap.bryant.webtv.net>
unrecognized char /240 at line 3
What does that mean?
#!/usr/local/bin/perl -w
=A0=A0=A0=A0=A0=A0=A0=A0use strict;
=A0=A0=A0=A0=A0=A0=A0=A0use POSIX ':sys_wait_h';
=A0=A0=A0=A0=A0=A0=A0=A0sub spin {
=A0=A0=A0=A0=A0=A0=A0=A0my @chars =3D qw[ - \ | / ];
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (my $pid =3D fork) {
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0#
parent
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0local $| =3D 1;
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0wh=
ile
( waitpid($pid, WNOHANG) !=3D -1 ) {
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0my $c =3D shift @chars;
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0print
"\rPlease wait; processing data... $c";
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0push @chars, $c;
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0select
undef, undef, undef, 0.1;
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0} =
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0pr=
int
"\n";
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0}
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0elsif (not defined $pid)
{
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0die "$0: failed fork: $!";
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0}
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0else {
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0#
child
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0system(qw/ sleep 5 /) =3D=3D 0
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0or
die "$0: could not start sleep: $!";
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0exit 42;
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0}
=A0=A0=A0=A0}
=A0=A0=A0=A0=A0=A0=A0=A0spin;
=A0=A0=A0=A0print "Done.\n";
Regards,
Dennis
------------------------------
Date: Tue, 15 Aug 2000 17:48:17 GMT
From: fvw+usenet@var.cx (fvw)
Subject: Re: Perl - Blinking Text
Message-Id: <966362040MEL.fvw@var.cx>
<8nbo8i$kci$1@panix6.panix.com> (steveo@panix.com):
>Louis <louis@aol.com> wrote:
>>Hi. While my perl script is processing, I would like the print line "Please
>>wait, processing data .. " to blink at the command line (UNIX). Does anyone
>>know how I can get the text to blink?
>
>while (1) {
>print "foo";
>sleep 1;
>print "\b\b\b \b\b\b";
>sleep 1;
>}
You'd prolly want to put a $|=1; in front of that..
--
Frank v Waveren
fvw@var.cx
ICQ# 10074100
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4024
**************************************