[18568] in Perl-Users-Digest
Perl-Users Digest, Issue: 736 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 21 14:11:01 2001
Date: Sat, 21 Apr 2001 11:10:14 -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: <987876614-v10-i736@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 21 Apr 2001 Volume: 10 Number: 736
Today's topics:
Re: openfile (Tad McClellan)
Re: openfile (echo 'Rudolf Polzer'>/dev/null)
POE 0.13 is available (Rocco Caputo)
Re: reg ex highlight outside html tags (Tad McClellan)
Re: Searching a File for a string, displaying the reult <abe@ztreet.demon.nl>
Re: Service <04-2001_news@elchnet.org>
Re: Slighty OT: Perl Books... <DNess@Home.Com>
Re: Thankyou All Most Kindly :-) (J.B. Moreno)
Re: Things I'm just not getting in Perl (Anno Siegel)
Re: Things I'm just not getting in Perl (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 21 Apr 2001 10:38:58 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: openfile
Message-Id: <slrn9e36s2.9cg.tadmc@tadmc26.august.net>
[ Please put your comments *following* the quoted text that you
are commenting on.
Please do not quote an entire article.
Please never quote .sigs.
Jeopardectomy performed.
]
Pujo C A <adustipujo1@mediaone.net> wrote:
><nobull@mail.com> wrote in message news:u9oftrcwdr.fsf@wcl-l.bham.ac.uk...
>> "Pujo C A" <adustipujo1@mediaone.net> writes:
>>
>> > I can do it in perl script but when I do it in CGI it doesnt work?
>>
>> So your first though should be that the reason will not be related to
>> your choice of programming language.
>>
>> When it "doesn't work" does soemthing happen or does the univers
>> simply end? Do you see errors in the log?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This question is important to figuring out what your problem is,
which is why nobull asked it I suppose.
You did not answer it.
Answering it will help us help you.
Ignoring it seems that you are not willing to provide the requested
information, leading to just ignoring your post altogether.
>> > open(GRADES, "+<testfil") or die "can not open grades: $!\n";
>>
>> Random shot in the dark: Your web server s/w is running the script
>> with a different current directory
Have you checked what current directory your web server is giving you?
I expect that the above is the cause of your problem. It is up to you
to go see if that is what it is. We cannot know how your web server
is configured...
Try it with an absolute path to the file instead of a relative path,
or chdir() to the directory where 'testfil' is before you open it.
>> or with a user ID that lacks write
>> permission to 'testfil'.
If this is the cause of your problem, then answering the log question
above would have confirmed it.
But you didn't answer that question, so we still don't know if that
is the cause or not.
>> BTW: Why did you open the file read/write?
Another unanswered question.
Are you ignoring us? What is the point of asking a question if you
aren't going to pay attention to the answers given?
>The think is I put the input file in the same directory to make me easy.
The same directory as *what* ?
The same directory as your program?
If so, then that is not what nobull said.
He did not talk about the directory where your program is. He
talked about your current directory.
>so it should look in the same directory.
The directory where your program is and the current directory may
not coincide to be the same directory.
Seems likely, in fact, that the current directory that your server
gives you is NOT the same directory that the program is in.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 21 Apr 2001 17:56:22 +0200
From: rpolzer@www42.t-offline.de (echo 'Rudolf Polzer'>/dev/null)
Subject: Re: openfile
Message-Id: <slrn9e3bd6.rt4.rpolzer@www42.t-offline.de>
nobull@mail.com <nobull@mail.com> wrote:
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
Nice sig, but unfortunately 2 lines too long.
Fup2me
--
#!/usr/bin/perl -W -- WARNING: This will print 22,307 bytes! <strictsafe!>
use strict;for(my$y=-1;$y<1;$y+=.1){for(my$x=-1.9;$x<.4;$x+=.03){print'+';
my$X=my$Y=0;for(0..99){($X,$Y)=($X*$X-$Y*$Y+$x,2*$X*$Y+$y);print"\b "if$X*
$X+$Y*$Y>9;}}print"\n"};print''.reverse"\nHPAJ \a!rezloP .R yb torblednaM"
------------------------------
Date: 20 Apr 2001 23:15:35 GMT
From: troc@netrus.net (Rocco Caputo)
Subject: POE 0.13 is available
Message-Id: <te33l3a6v5tdce@corp.supernews.com>
POE is an award-winning threaded application kernel for Perl. It is
compatible with BSD and SysV flavors of Unix, OS/2, and (with some
caveats) Windows. It is written entirely in Perl for maximum
portability and is known to work with versions 5.005_03 through 5.6.1.
POE has been actively, openly developed since its first CPAN release
in 1998. It has been used in mission critical systems since shortly
after that. Despite its woefully low version number, POE has an
extensive test suite. The latest version passes 467 tests covering
over 70% of the distribution's breakpoints.
POE 0.13 has been uploaded to the PAUSE, and your favorite CPAN mirror
will have it after the usual propagation delays. The impatient can
download it right now from Sourceforge or POE's own home page:
http://poe.perl.org/
http://sourceforge.net/projects/poe
A recent ActiveState PPM is at <http://poe.sourceforge.net/>. The
newest version should be available there shortly.
The changes since POE's last CPAN release (version 0.12) are scarily
long, so they will only be summarized here:
Bug fixes! Lots of bug fixes!
Optimizations! We got some of them, too!
Documentation! It's been overhauled yet again!
Features! Many new things to make lives easier!
Here are some of those new features:
Interfaces to Event, Gtk, Tk and POE's own select() loops have been
turned into plug-ins. Start-up is a little faster, and new event
loops are easier to support. This one mainly makes *my* life
easier. :)
Developers get new TRACE and ASSERT flags to turn on extra parameter
and return value checking.
New module: Wheel::Run simplifies running asynchronous child
processes. It encapsulates pipe/fork/exec, similar to
IPC::Open[23].
New module: Wheel::ReadLine accepts user input on the console. It
reinvents a lot of Term::ReadLine, but it's compatible with POE.
New module: Wheel::Curses performs non-blocking Curses input. POE
programs can now have full-screen textual user interfaces and still
multitask.
New modules: Filter::Stackable, Filter::Grep, Filter::Map, and
Filter::RecordBlock. These implement simple protocol stacks.
The complete, detailed change log is in POE's distribution. It's also
on the web at <http://poe.perl.org/poedown/Changes>.
POE's README includes the most recent test summaries and coverage
statistics. It's on the web too: <http://poe.perl.org/poedown/README>.
And finally, POE has a mailing list. Send a blank message to
<poe-help@perl.org> for more information.
Thank you for reading.
-- Rocco Caputo / troc@netrus.net / poe.perl.org / poe.sourceforge.net
------------------------------
Date: Sat, 21 Apr 2001 10:10:41 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: reg ex highlight outside html tags
Message-Id: <slrn9e3571.9cg.tadmc@tadmc26.august.net>
M@ <matt@NOSPAM.yewlands.com> wrote:
>I am trying to use a reg ex to highlight words as long as they are not with
>a html tag.
You can't always get what you want.
>So if I have a string
>$string = "<span class=message>span, span the span</span>";
>and I want want to replace all occurances of span but only those outside of
>a html tag, how would I go about this?
By parsing the HTML with a module that parses HTML.
>I can't use any other modules to achieve this
Why not?
Many people think they cannot use modules when they really can
use modules.
If you tell us why you think you cannot use them, maybe we can
show how you _can_ use them.
>it has to be done using reg ex
It cannot, in the general case, be done using a regex, so you are SOL.
>I'm a very new reg ex user so please be kind :-)
That won't matter, since regexs do not have sufficient power to do
what you want done :-)
Use a module that parses HTML to parse HTML.
>I'm awaiting delivery of the oreilly book this is quite urgent.
^^^^^^
Usenet is not the right place then.
If it is truly urgent, then you should hire someone to take care
of it for you. If it is not urgent, then you shouldn't tell fibs,
it has an effect opposite of what you are trying to acheive.
It can take hours or days (or even "forever") for an article to
propagate via news, so you will probably already be dead before
anyone even sees your question.
Not much point in answering an "urgent" question after the deadline
has already passed, so most folks will just move on to another
question with more generous time constraints.
>Please reply to email.
Ask it here, get the answer here.
>matt-at-yewlands.com
Uh oh.
"send me email", when coupled with a munged address, yields a
*plonk*
Bye.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 21 Apr 2001 19:49:09 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Searching a File for a string, displaying the reults
Message-Id: <u2d3etce16nonmkr4g9he1t65lv05hsa9j@4ax.com>
On Fri, 20 Apr 2001 19:37:55 GMT, "Kenneth Eide" <js@hotmail.com> wrote:
> I have a file, "morning.ini" which looks like this:
[ moved to the end ]
> I made a script that searches for the name, and displays the Name + the URL
It should start with:
#!/usr/bin/perl -w
use strict;
to let perl help you as much as it can.
> open (OLD, "<morning.ini") or die "Error: Could not open morning.ini: $!\n";
Good! diagnostic message that includes '$!'.
> if ($ARGV[0] =~ /^search$/i) {
Since you are actually checking for equality:
if ( lc $ARGV[0] eq 'search' ) {
But as nothing hapens unless this condition is met, you could also
exit() or die() and save yourself a lot of indenting later on, making
the program more readable.
> $sstring = "@ARGV[1..$#ARGV]";
> while (<OLD>) {
If you only want to search in the 'name fields', you'd better include
that somewhere. Try searching (in the above data) for 'bbc.co' with your
program.
Skip the non-name lines:
next unless /^url\d+name=/;
> if ($_ =~ /$sstring/i) {
> $urlname = $_;
> $urllinenum = $. - 1;
> $exists = "yes";
If you want to 'remember' more matches, you'll have to use a data
structure that allows for that. An array looks good for the job:
push @matches, $. - 1;
> }
> }
> if (defined $exists) {
> }
> else {
> die "Error: Found no matches for \"$sstring\" in morning.ini\n";
> }
Brrr, this is why we have 'unless' :
die "No matches found for '$sstring'\n" unless @matches;
> close(OLD);
> open (OLD, "<morning.ini");
Oops, the open() could fail the second time, the file might have been
deleted. You should always check the result of open(), like you did the
first time.
If you insist on reading the file a second time, you could seek() to
reset the filepointer to the beginning, but don't forget to reset '$.'.
A better solution would be to remember more while reading the file the
first time.
This is what I made of it with your code as a base, using the special
DATA filehandle:
#!/usr/bin/perl -w
use strict;
exit unless lc $ARGV[0] eq 'search';
my $sstring = "@ARGV[1..$#ARGV]";
my( $url, @matches );
while ( <DATA> ) {
chomp;
$url = $_ if s/^url\d+=//; # remember this
next unless s/^url\d+name=//; # search only in 'name'
push @matches, [ $_, $url ] if /$sstring/i;
}
die "Error: Found no matches for \"$sstring\" in morning.ini\n"
unless @matches;
foreach my $match ( @matches ) {
print "$match->[0]\n$match->[1]\n";
}
__DATA__
url0=http://europe.cnn.com
url0name=CNN Europe
url1=http://bbc.co.uk
url1name=BBC
url2=http://cnn.com/europe
url2name=CNN Europe
--
Good luck, Abe
Amsterdam Perl Mongers http://amsterdam.pm.org
perl -wle '$_=q@Just\@another\@Perl\@hacker@;print qq@\@{[split/\@/]}@'
------------------------------
Date: 21 Apr 2001 18:34:19 +0200
From: Markus Luft <04-2001_news@elchnet.org>
Subject: Re: Service
Message-Id: <9bsjrb.ko.1@hamster.elchnet.org>
* "Roland Pellegrini" <pellegrini@erste.at> wrote:
> How can i register a perl-script as an service under WinNT ?
> I need this for running perl-scripts in background.
>
If you only want scripts to run in background use 'wperl.exe' instead of
'perl.exe' or use a small vbs-script to start your perl-script:
'start_my_script.vbs
'starts a perlscript in an unvisible window
DIM OBJ_Shell
Set OBJ_Shell = Wscript.CreateObject("Wscript.Shell")
OBJ_Shell.run "D:\path\myscript.pl",0,vbTrue
If you need a true service/Dienst have a look at
<URL:http://www.firedaemon.com/>.
HTH,
Markus
--
It isn't easy being green.
(Kermit)
------------------------------
Date: Sat, 21 Apr 2001 15:05:38 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: Slighty OT: Perl Books...
Message-Id: <3AE1A1D8.5D17434D@Home.Com>
Young Chi-Yeung Fan wrote:
>
> I have the Perl CD Bookshelf (from O'Reilly), and like it. Well within your
> budget, too. Since you're probably going to buy from Amazon.com, here are the
> URL's for the current edition, and the one that will come out in May:
>
Only a fool buys from Amazon when there are so many better (i.e. cheaper)
suppliers available. Amazon shows this book, for example, at nearly $60, while
it can be purchased from highly reliable places for about $45. $15 may not mean
much to you, but it sure matters to me.
If I were you I'd take a look at the many suppliers offered by searching for the
book on http://www.pricescan.com and then see if they are willing to ship to Ireland.
I suspect most would.
------------------------------
Date: Sat, 21 Apr 2001 14:02:26 -0400
From: planb@newsreaders.com (J.B. Moreno)
Subject: Re: Thankyou All Most Kindly :-)
Message-Id: <1es6xsw.1r21gsxstd0azN%planb@newsreaders.com>
Tad McClellan <tadmc@augustmail.com> wrote:
> Karl Young <karlyoung@unconscious.co.uk> wrote:
>
> >Does anyone really read a newsgroup for 3 weeks before posting to it?
>
>
> Folks that are very interested in not embarrassing themselves do.
Well, I'm at least moderately interested in not embarrassing myself, but
at most I read the last 3 weeks worth of messages in lieu of actually
waiting the 3 weeks before posting...
--
JBM
"Your depression will be added to my own" -- Marvin of Borg
------------------------------
Date: 21 Apr 2001 16:28:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Things I'm just not getting in Perl
Message-Id: <9bscf9$hd7$1@mamenchi.zrz.TU-Berlin.DE>
According to Damian Conway <damian@cs.monash.edu.au>:
[...]
> Or just use the special C<< 1-print >> built-in:
>
> do { print "enter a number: " }
> until ($response)=<>=~/^(\d+)$/
> or 1-print "No, stupid, ";
The 1-print operator has been deemed unsafe. Use the newer !print.
> ;-)
Emphasized.
Anno
------------------------------
Date: 21 Apr 2001 16:38:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Things I'm just not getting in Perl
Message-Id: <9bsd1t$hd7$2@mamenchi.zrz.TU-Berlin.DE>
According to Abigail <abigail@foad.org>:
[...]
> Or even a plain goto:
>
> NUMBER:
> print "Enter a number: ";
> chomp ($response = <>);
> goto NUMBER unless $response =~ /^\d+$/;
>
> (cue the Dijk^WWirth chanters)
Oh, we stopped chanting long ago, about when ALGOL60 died. No use
preaching to the choir.
Anno
------------------------------
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 736
**************************************