[19178] in Perl-Users-Digest
Perl-Users Digest, Issue: 1373 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 25 00:05:43 2001
Date: Tue, 24 Jul 2001 21:05:08 -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: <996033908-v10-i1373@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 24 Jul 2001 Volume: 10 Number: 1373
Today's topics:
add [flags for] quote-like operators? <goldbb2@earthlink.net>
Re: Capitalone and LWP <goldbb2@earthlink.net>
Re: CGI -> Apache Problem (Eric Bohlman)
Re: CGI.pm Question <mbudash@sonic.net>
Re: changing a field value in a particular line <andras@mortgagestats.com>
Re: Database Problem <ron@savage.net.au>
Re: Directory Diff <mattc@visi.com>
emacs etags default in cperl mode <badarik@yahoo.com>
Re: Extra bytes when writing file out <goldbb2@earthlink.net>
FAQ: How do I find the current century or millennium? <faq@denver.pm.org>
Re: FAQ: Why aren't my random numbers random? <andras@mortgagestats.com>
help - i am really over my head <smarx@i2000.com>
Re: help - i am really over my head <bwalton@rochester.rr.com>
Re: HTML::Parser Help <tong_po_and_malene@hotmail.com>
kill idle user using unix w <eric.leung@philips.com>
Re: mod_perl for NT <ron@savage.net.au>
Re: Perl and Apache? <joe+usenet@sunstarsys.com>
problems with open <lapenta_jm@yahoo.com>
Re: problems with open <james@zephyr.org.uk>
probs. passing filehandels and scope issues <lapenta_jm@yahoo.com>
Regular expressions... (Markku Hirvonen)
Re: Regular expressions... <bwalton@rochester.rr.com>
Re: timeout of gethostbyaddr and gethostbyname <goldbb2@earthlink.net>
Re: Tutorials? <rachel@lspace.org>
Re: Yet another Perl Web Server (John Holdsworth)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Jul 2001 21:35:20 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: add [flags for] quote-like operators?
Message-Id: <3B5E2258.3FB83569@earthlink.net>
If I wanted to add functionality for a new quote-like operator, or add
new flags for an existing operator, how would I go about doing it?
For example, suppose I want to create operators g// and qg//, which
would be similar in effect to m// and qr//, but which operate with nice,
simple, csh-style glob patterns, instead of [powerful, but not so nice
and simple] regular expressions.
Or if I wanted to create a qc (for quotes with comments) operator, which
quotes like qq, but strips whitespace and comments, like the /x operator
does to m//, s/// and qr//.
Is this posssible to add this via a package, or would it have to be
added to the perl binary?
Another possibility might be to add functionality to be able to add
flags to the normal quote-like operators, so I could do:
my $x = qq{
this\ is\ line\ 1.\n # this is a comment.
this\ is\ line\ 2.\n # this is a second comment.
}x;
# now $x contains "this is line 1.\nthis is line 2.\n";
...which would probably be better than adding a qc operator.
Also, adding /l, /u, and /q flags, which would in effect wrap the
contents with \L, \U, or \Q (and \E at the end) might be desired
(especially with q, since you can't put such escapes inside the quotes,
and you may want to have to the uc, lc, or quotemeta done in the
compiletime, not at runtime, especially if it's called many times).
And wouldn't this be the perfect place to tell what kind of encoding the
given string is? For example /e{UTF-8} or /e{ISO-8859-2} or
/e{Windows-1250} would cause [at complile time] the given byte string to
be converted using that scheme into perl's internal unicode.
Obviously, adding flags to existing operators would likely have to be
done by modifying the perl source, and couldn't be done via a module.
Unless overload could do it?
--
I need more taglines. This one is getting old.
------------------------------
Date: Tue, 24 Jul 2001 22:12:02 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Capitalone and LWP
Message-Id: <3B5E2AF2.FFF43018@earthlink.net>
Enrico Ng wrote:
>
> I am trying to get info from capitalone.com but am having trouble. A page sets two cookies via javascript, then redirects me to the login screen, where there are two hidden form fields with session ids. It looks like the two javascript cookies are just random numbers, so I tried making up my own and doing a POST to the login screen, but I get nothing.
Usually, after a redirect occurs, the form data is lost [not retransmitted when contacting the URL you were redirected to]. This may be your problem.
[snip]
> LWP::Protocol::http::request: reading response
> LWP::Protocol::http::request: HTTP/1.1 302 Moved Temporarily
> LWP::Protocol::http::request: HTTP/1.1 302 Moved Temporarily
> LWP::Protocol::http::request: need more header data
> LWP::UserAgent::request: Simple response: Found
Have you looked into LWP::Protocol::http::request to see what "need more header data" means?
Oh, and you really should be using '', q, or qq rather than "" for strings which have " characters in them:
$req->header( 'Set-Cookie' => qq{OAS_COOKIE_ENABLE="4234634342"; path="/"; domain=".capitalone.com"; path_spec; secure; version=0});
Or, better yet, use qw and join, so it fits on the screen without wrapping:
$req->header( 'Set-Cookie' => join( "; ", qw(
OAS_COOKIE_ENABLE="4234634342"
path="/" domain=".capitalone.com"
path_spec secure version=0 )));
This doesn't work if the quoted strings have spaces... qw will turn COOKIEVALUE="foo bar" into two things, 'COOKIEVALUE="foo' and 'bar"', which isn't likely what you want. But for some things [like this example], it's perfect.
If it did have spaces, you could do it as:
$req->header( 'Set-Cookie' => join( "; ",
qq{COOKIE_NAME="cookie value with spaces"}, qw(
path="/" domain=".something.com"
path_spec secure version=0 )));
--
I need more taglines. This one is getting old.
------------------------------
Date: 24 Jul 2001 23:21:42 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: CGI -> Apache Problem
Message-Id: <9jkvu6$sqg$1@bob.news.rcn.net>
Thomas Bätzler <Thomas@baetzler.de> wrote:
>>my $command = "p:/tools/wni/unzip.exe $myFile";
>>system ($command) or print "Fuck the system command:$!";
> [...]
> I bet that P: is a mapped drive and that the Apache runs as a service
> under a special user account on your Server. So from the Apache's POV,
> there probably is no P: drive as drive mappings are only active for
> the currently logged in account.
Furthermore, the command processor is pretty much the one place in Win32
where you *have* to use backslashes rather than forward slashes as path
separators, and the single-argument form of system() invokes the command
processor.
------------------------------
Date: Wed, 25 Jul 2001 03:14:59 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: CGI.pm Question
Message-Id: <mbudash-8833F3.20145924072001@news.sonic.net>
In article <D1m77.14071$fo2.2217@newsfeed.slurp.net>, "Curtis
Hawthorne" <curtish@ourtownusa.net> wrote:
> "Michael Budash" <mbudash@sonic.net> wrote in message
> news:mbudash-71D78B.14424924072001@news.sonic.net...
>
> > In article <POk77.14039$fo2.2337@newsfeed.slurp.net>, "Curtis
> > Hawthorne" <curtish@ourtownusa.net> wrote:
> >
[snip]
> > > when I use a statement like:
> > > print redirect("http://server.com/cgi-bin/script.pl?var1=$var1");
> > >
> > > where $var1 = "This, that, & other stuff", the & stays in the URL and messes up the
> > > data so that the script only gets var1 as "This, that, ". My question is,
> > > why doesn't CGI.pm automatically enode the & into something that will go
> > > go into a URL without causing problems? And, if it can't do that, what's the
> > > best way to work around it?
> >
> > mr. stein most likely thought that giving the programmer the ultimate
> > decision of what to escape and how to escape it would be a better
> > choice. per the docs (@ http://stein.cshl.org/WWW/software/CGI/ ):
> >
> > escape(), unescape()
> >
> > use CGI qw/escape unescape/;
> > $q = escape('This $string contains ~wonderful~ characters');
> > $u = unescape($q);
> >
> > These functions escape and unescape strings according to the URL hex
> > escape rules. For example, the space character will be converted
> > into
> > the string "%20".
>
> Thanks, I must have missed that part in the documentation.
>
if there's one link whose contents you should read top to bottom, it's
that one ( http://stein.cshl.org/WWW/software/CGI/ ).
good luck!
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Tue, 24 Jul 2001 20:27:17 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: changing a field value in a particular line
Message-Id: <3B5E1265.196A665A@mortgagestats.com>
Balaji wrote:
> Hi Gurus
>
> I am new to this..but it creates lot of interest.
>
> I am ok with scripts like forms creating/printing to a
> datafile/creating results page by printing correct fields etc..getting
> a timestamp/modification time etc..
>
> But I am stuck here totally.
>
> my data file is abc.dat
> it has following values for e.g.
>
> california,sfo,goldengate,80,60,localtime
> arizona,grandcanyon,northrim,70,40,locatime
>
> This values are submitted using a form.
>
> now the same form is used to change
> "california,sfo,goldengate,80,60,localtime" to
> "california,sfo,IMAX,80,60,localtime"
>
> but i can either append the abc.dat or overwriting the whole file
> which certainly i don't want to do.I am not been to overwrite that
> particular line.
>
> I read couple of postings and perlfaq5 etc..but for me right now it is
> tough..
>
> can somebody show me the simple way?
>
> Thanks a lot for your help.
This is a FAQ and the answer is in perlfaq5, available at
http://www.perldoc.com/perl5.6/pod/perlfaq5.html
Look for the section titled "How do I change one line in a file/delete a
line in a file/insert a line in the middle of a file/append to the
beginning of a file? "
------------------------------
Date: Wed, 25 Jul 2001 13:59:48 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Database Problem
Message-Id: <Wxr77.97436$Rr4.571191@ozemail.com.au>
JR
See below.
--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
JR <tommyumuc@aol.com> wrote in message news:319333f5.0107240700.59d86abb@posting.google.com...
> Please help! I'm trying to create a small database that takes data
> from an intranet form and then updates to a .dat file. The .dat file
> takes in all of the fields properly, except for the field from
> 'textarea' of the form.
[snip]
> Then I pass it to my CGI script...
>
> my $typeChange = $q->param('typeChange');
>
> But when it gets written to the .dat file, it is written on a newline
> (which ruins the whole program).
Sorry: 'on a newline' does not compute.
[giant snip]
Perhaps the data submitted in the textarea contains newlines. Try replacing them with <br> for example, with all of this code:
$data =~ s/\r\n/<br>/g; # DOS aka Windows.
$data =~ s/\r/<br>/g; # Macintosh.
$data =~ s/\n/<br>/g; # Unix.
Do not use just 1 line of those 3.
That makes $data easy to store and display. Also, to display you could use:
$data =~ s/<br>/\n/g;
------------------------------
Date: 24 Jul 2001 18:33:12 -0500
From: Matt Christian <mattc@visi.com>
Subject: Re: Directory Diff
Message-Id: <87puaplx6v.fsf@powerhouse.boogie.cx>
Ross,
> I've done a backup on a UNIX directory
> to a temporary location and I'd like to find
> the files that have been changed from my
> current version of the directory. Has anyone
> written a utility to do this? What makes it a
> little tricky is that the directory has many sub-
> directories.
Yes, Paul Mackerras has written dirdiff which does
exactly what you want, it runs in X and requires TCL/TK.
The subdirectories shouldn't be a problem...
dirdiff CVSWeb (download the current/unstable version):
http://samba.org/cgi-bin/cvsweb/dirdiff/
dirdiff FTP site (download the stable version):
ftp://ftp.samba.org/pub/paulus/
Thanks,
Matt
--
Matt Christian - mattc@visi.com
http://www.visi.com/~mattc/
ftp://ftp.visi.com/users/mattc/
Learn to love and love to learn.
------------------------------
Date: Tue, 24 Jul 2001 16:18:49 -0700
From: Badari Kakumani <badarik@yahoo.com>
Subject: emacs etags default in cperl mode
Message-Id: <3B5E0259.E3348BC5@yahoo.com>
folks,
i use emacs cperl mode for writing the perl code.
i am starting to use etags facility. when i search
for a tag using M-. (find-tag) command in emacs, the default
appears to be the word at which the cursor is
located. typical perl function calls we have
are of the form <package>::<function> and that is
selected as the default. but etags needs only <function>
to find the tag. so is there a way to influence
etags find-tag routine to ignore the <package>::
prefix in the word around cursor and select just <function>
as the default value to look for?
thanks,
-badari
------------------------------
Date: Wed, 25 Jul 2001 00:08:32 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Extra bytes when writing file out
Message-Id: <3B5E4640.A22F0E20@earthlink.net>
Your entire program could be easily reduced to:
use LWP::Simple;
mirror( "http://138.216.1.1/ak_ADCON000.Z", "ak_ADCON000.Z" );
--
I need more taglines. This one is getting old.
------------------------------
Date: Wed, 25 Jul 2001 00:16:32 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I find the current century or millennium?
Message-Id: <Ado77.31$os9.201429504@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How do I find the current century or millennium?
Use the following simple functions:
sub get_century {
return int((((localtime(shift || time))[5] + 1999))/100);
}
sub get_millennium {
return 1+int((((localtime(shift || time))[5] + 1899))/1000);
}
On some systems, you'll find that the POSIX module's strftime() function
has been extended in a non-standard way to use a "%C" format, which they
sometimes claim is the "century". It isn't, because on most such
systems, this is only the first two digits of the four-digit year, and
thus cannot be used to reliably determine the current century or
millennium.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
04.11
--
This space intentionally left blank
------------------------------
Date: Tue, 24 Jul 2001 20:36:33 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: FAQ: Why aren't my random numbers random?
Message-Id: <3B5E1491.2E8F8051@mortgagestats.com>
PerlFAQ Server wrote:
>Don't call "srand" more than once--you make your numbers less random, rather
than more.
Why is that?
------------------------------
Date: Tue, 24 Jul 2001 20:16:41 -0400
From: "Steve" <smarx@i2000.com>
Subject: help - i am really over my head
Message-Id: <fdo77.24$44.870@newsreader.i-2000.net>
help, i am a newbie way over his head:
i am scanning a file whose contents are contained in the list HTML. This
file has tags, at the start of lines only, which are defined as "$$xxxx=
" where xxx is any alphanumeric followed by by = foloowed by any number of
spaces. i convert this tag to "$$xxxx= " with just a single space. now i
take all of the characters between the tag $$xxxx= and the next tag which
starts with $$ and call this the value of the tag. i have a hash called %h
which
should hold the the "$tag= " as the key and the characters between the this
tag and the next tag as the value. The following code is invoked repeatedly
for a set of files each which is converted to to the $HTML list.
while($HTML =~ /(\$\$\w+=)\s*(.*)(?!\$\$)/g) {
$keywspc = $1." ";
if(defined $tag{$keywspc}) {die "Duplicate tag $1 in content file $file is
not permitted\n"}
$temp = $2; chomp($temp);
$tag{$keywspc} = $temp;
}
Now everything works fine, untill someone provides tags which have nothing
but spaces and newline or nothing but spaces and a newline followed, in both
instances by another $$xxx=.
Note that is undef the %hash between invocations to the above loop and yet
upon doing some debugging i find that $2 has weird values in it when in fact
it shoud have either nothing or just spaces.
help
Steven Marx
------------------------------
Date: Wed, 25 Jul 2001 03:18:28 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: help - i am really over my head
Message-Id: <3B5E3A91.D47ADC54@rochester.rr.com>
Steve wrote:
...
> i am scanning a file whose contents are contained in the list HTML. This
> file has tags, at the start of lines only, which are defined as "$$xxxx=
> " where xxx is any alphanumeric followed by by = foloowed by any number of
> spaces. i convert this tag to "$$xxxx= " with just a single space. now i
> take all of the characters between the tag $$xxxx= and the next tag which
> starts with $$ and call this the value of the tag. i have a hash called %h
> which
> should hold the the "$tag= " as the key and the characters between the this
> tag and the next tag as the value. The following code is invoked repeatedly
> for a set of files each which is converted to to the $HTML list.
>
> while($HTML =~ /(\$\$\w+=)\s*(.*)(?!\$\$)/g) {
> $keywspc = $1." ";
> if(defined $tag{$keywspc}) {die "Duplicate tag $1 in content file $file is
> not permitted\n"}
> $temp = $2; chomp($temp);
> $tag{$keywspc} = $temp;
> }
>
> Now everything works fine, untill someone provides tags which have nothing
> but spaces and newline or nothing but spaces and a newline followed, in both
> instances by another $$xxx=.
>
> Note that is undef the %hash between invocations to the above loop and yet
> upon doing some debugging i find that $2 has weird values in it when in fact
> it shoud have either nothing or just spaces.
...
> Steven Marx
Well, you've got a couple of problems. First of all, the (.*) will
match everything up to the *last* $$, since it is greedy. So if there
are multiple entries per line, those entries will appear as part of a
key. Second, if a keyword-value item spans a line (as you indicate it
could), you will miss that, since your match operator will look only on
the current line. Use the /s switch to ignore newlines in the match.
Third, you are using a negative lookahead assertion. Why? It should be
a positive lookahead which succeeds when $$ is present, but doesn't
match the $$. And last, the last $$key=value pair will not be matched
unless you permit the end of the string to be included as an alternate
to $$.
The following might do what you want (and is a complete example
including data definition and printout, which is always helpful):
$HTML='$$one= one
$$two= two $$three= three
$$four=
$$five= five';
while($HTML =~ /(\$\$\w+=)\s*(.*?)(?:(?=\$\$)|$)/gs) {
$keywspc = $1." ";
print "\$1=$1, \$2=$2\n";
if(defined $tag{$keywspc}) {die "Duplicate tag $1 in content file $file
is
not permitted\n"}
$temp = $2; chomp($temp);
$tag{$keywspc} = $temp;
}
for(sort keys %tag){print "tag{$_}=$tag{$_}\n"}
--
Bob Walton
------------------------------
Date: Wed, 25 Jul 2001 00:09:14 +0100
From: "Lee" <tong_po_and_malene@hotmail.com>
Subject: Re: HTML::Parser Help
Message-Id: <9jkv24$q44$1@news5.svr.pol.co.uk>
Thanks Bjoern,
Unfortunately, I can get the script to run but it won't product any output!
Lee.
"Bjoern Hoehrmann" <bjoern@hoehrmann.de> wrote in message
news:3b78edc7.34553234@news.bjoern.hoehrmann.de...
> * Lee wrote in comp.lang.perl.misc:
> >I've installed this module from CPAN fine. I have read the documentation
and
> >jus can't get it functioning. All I want to do is remove the HTML tags
from
> >a given text string and return just the remaining non-HTML text.
>
> One simple approach would be
>
> #!perl -w
> use strict;
> use warnings;
>
> use HTML::Parser;
>
> my $text;
> my $p = HTML::Parser->new(
> text_h => [ sub { $text .= $_[0] }, 'dtext' ]
> );
> $p->parse('some <em>highlighted</em> text');
> $p->eof;
>
> print $text;
> --
> Björn Höhrmann { mailto:bjoern@hoehrmann.de } http://www.bjoernsworld.de
> am Badedeich 7 } Telefon: +49(0)4667/981028 { http://bjoern.hoehrmann.de
> 25899 Dagebüll { PGP Pub. KeyID: 0xA4357E78 } http://www.learn.to/quote/
------------------------------
Date: Wed, 25 Jul 2001 09:21:07 +0800
From: "eric leung" <eric.leung@philips.com>
Subject: kill idle user using unix w
Message-Id: <9jl64g$8g3@news.cityu.edu.hk>
Hi
I want using unix command "w" and those users idle more than 30 minutes
without change on JCPU time.
How to write perl ?
/home/eric>w
9:11am up 2 day(s), 2:34, 11 users, load average: 4.59, 4.34, 3.94
User tty login@ idle JCPU PCPU what
Eric , 7/25
------------------------------
Date: Wed, 25 Jul 2001 13:51:38 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: mod_perl for NT
Message-Id: <hqr77.97434$Rr4.571005@ozemail.com.au>
There is a pre-compiled Apache + Perl + mod_perl + other.
Start here: http://savage.net.au/Perl.html#Configuring-Apache
--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
------------------------------
Date: 24 Jul 2001 18:09:59 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Perl and Apache?
Message-Id: <m3ae1u6kso.fsf@mumonkan.sunstarsys.com>
BCC <bcoon@sequenom.com> writes:
> My apologies for a slightly off topic question...
> To use mod_perl, I just need to install the perl Apache module,
> recompile apache and install? I think this patches apache with mod_perl
> support...
Basically that's right. You have some choice in how to build mod_perl,
but essentially 4 things ultimately need to happen:
1) your apache source tree needs to get the mod_perl apache module
copied into /path/to/apache/src/modules/perl
2) your apache needs to be reconfigured to build mod_perl (preferably
with static, not dynamic linking)
3) your perl5 installation tree (/usr/lib/perl5/site_perl/...) needs
to get some Apache modules installed that provide Apache's Perl API.
4) your new mod_perl-enabled apache needs to be installed and
httpd.conf must be set up.
The mod_perl package will do most of these things for you, so be sure to
read the README and installation documents thoroughly.
mod_perl's official website is at
http://perl.apache.org/
In particular read Stas Bekman's excellent guide:
http://perl.apache.org/guide/
>
> Also what is the best book to learn about mod_perl?
The eagle book:
http://www.modperl.com/
is the standard reference.
> P.S. I had heard that Apache 1.3.xx already has mod_perl included. Is
> that true?
No. Some *nix vendors include mod_perl as part of their apache build,
but IMHO it's better to build apache + mod_perl from scratch.
HTH
--
Joe Schaefer "A foolish consistency is the hobgoblin of little minds, adored
by little statesmen and philosophers and divines."
-- Ralph Waldo Emerson
------------------------------
Date: Tue, 24 Jul 2001 22:29:33 -0400
From: Jason LaPenta <lapenta_jm@yahoo.com>
Subject: problems with open
Message-Id: <3B5E2F0D.FD269AFE@yahoo.com>
Why is it when I have
open( content_f, "<content.html" ) or print "Need content.html\n";
print <content_f>;
it works. Yet if I put the same thing in a sub
sub foo{
open( content_f, "<content.html" ) or print "Need content.html\n"
print <content_f>;
}
perl can't open the file. What's the deal with this. Man, I think perl
hates me!
J
------------------------------
Date: Wed, 25 Jul 2001 04:01:18 +0100
From: James Coupe <james@zephyr.org.uk>
Subject: Re: problems with open
Message-Id: <T2QUwfi+ZjX7Ew9D@gratiano.zephyr.org.uk>
In message <3B5E2F0D.FD269AFE@yahoo.com>, Jason LaPenta
<lapenta_jm@yahoo.com> writes
>Why is it when I have
>
>open( content_f, "<content.html" ) or print "Need content.html\n";
>print <content_f>;
>
>it works. Yet if I put the same thing in a sub
You didn't.
>sub foo{
> open( content_f, "<content.html" ) or print "Need content.html\n"
^
> print <content_f>;
>}
And if you're not pasting real code, you really should.
--
James Coupe PGP Key: 0x5D623D5D
"Surely somewhere out there there's a woman who's EBD690ECD7A1F
been sodomized by her father and is capable of B457CA213D7E6
composing a few coherent sentences on the subject." 68C3695D623D5D
------------------------------
Date: Tue, 24 Jul 2001 22:11:06 -0400
From: Jason LaPenta <lapenta_jm@yahoo.com>
Subject: probs. passing filehandels and scope issues
Message-Id: <3B5E2ABA.CBE2CDA1@yahoo.com>
Hello,
Why won't this work? I think it should. It's template_f a global?
########################################
# process_dir
#
sub process_dir {
...
seek( template_f, 0, 0 );#SEEK_SET ); # line 124
while ( $line = <template_f> ) {
....
}
}
}
open( template_f, "<template.html" ) || print "Need template.html\n";
OUTPUT :
seek() on unopened file at ./process2.perl line 124.
How can I get this to work as a global? Or how can I pass template_f? I
tried it but I got useless errors no matter what I tried.
Thanks
Jason
------------------------------
Date: Wed, 25 Jul 2001 02:52:12 GMT
From: markku@huilustudio.fi (Markku Hirvonen)
Subject: Regular expressions...
Message-Id: <3b5e342a.4576437@uutiset.saunalahti.fi>
Hi all!
I would like to know if there is a newsgroup for regular expressions
plz.
Markku
------------------------------
Date: Wed, 25 Jul 2001 03:24:00 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Regular expressions...
Message-Id: <3B5E3BDD.98EBDC89@rochester.rr.com>
Markku Hirvonen wrote:
...
> I would like to know if there is a newsgroup for regular expressions
> plz.
...
> Markku
This one will suffice for Perl regular expressions.
--
Bob Walton
------------------------------
Date: Tue, 24 Jul 2001 20:39:03 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: timeout of gethostbyaddr and gethostbyname
Message-Id: <3B5E1527.1B3C6D67@earthlink.net>
Haber Schabernackel wrote:
>
> I use these sub's to convert between, say 208.201.239.56 and www.perl.com:
>
> print hostname_to_ipnumber("www.perl.com")."\n"; # 208.201.239.56
>
> sub ipnumber_to_hostname{ gethostbyaddr(pack("C4",split("\\.",shift)),2) }
> sub hostname_to_ipnumber{ join(".",unpack("C4",gethostbyname(shift))) }
>
>
> But sometimes the sub's hangs "forever", often up to a minute.
> How can i make them time out after 5 seconds?
> (I'm not interested in the result if it takes longer to find it).
The simplest is to use %SIG, eval, and alarm to create a timeout.
Using a pipe and forking, and having the child do it (and then doing
select() on the pipe in the parent) is a second way to do it.
A third way would be Net::DNS.
--
I need more taglines. This one is getting old.
------------------------------
Date: Tue, 24 Jul 2001 23:01:45 +0100
From: Rachel Coleman <rachel@lspace.org>
Subject: Re: Tutorials?
Message-Id: <sbrrltg4tvphviascn0ldq646dmugigoik@4ax.com>
On Mon, 23 Jul 2001 20:46:28 +0100, "Nathan Randle"
<nathan.randle@ntlworld.com> wrote:
>I have recently ventured into Perl only to find that tutorials are often not
>very helpful. Does anyone know any good free tutorials aviable over the
>internet?
If you find online tutorials unhelpful, you might want to consider
investing real money in one of the recommended books in the FAQ. My
own experience is the 40 pounds or so is quickly paid back in time
saved by learning quickly and well, not to mention having a handy
reference around when you want it.
If your employers want you to learn Perl then they jolly well should
provide the resources you need; if you really can't manage the money
yourself, try a library, programmer friends etc.
Best wishes,
Rachel
------------------------------
Date: 24 Jul 2001 16:15:37 -0700
From: coldwave@bigfoot.com (John Holdsworth)
Subject: Re: Yet another Perl Web Server
Message-Id: <2a46b11e.0107241515.4e4f752a@posting.google.com>
Hi Emmanuel,
I should say it forks a set of child processes but reuses them.
On windows the server works but for Win32 you're probably better
off using PerlScript/Perl for ISAPI and IIS.
There is an overview of how the server works at:
http://www.openpsp.org/design.html
rgds
john
Emmanuel E <shashanka.sj@in.bosch.com> wrote in message news:<3B5BD13B.829ED5FA@in.bosch.com>...
> hi
> how does ur server work if u arent forking? how do u manage threads? are
> u using non blocking I/O ? and some timer signals to manage threads? is
> it stable on the windoze platform on active perl? i'd love to hear from
> u.
>
> thanks
> Emmanuel
>
> John Holdsworth wrote:
>
> > Hi,
> >
> > I've developed a perhaps rather excentric
> > Perl Web Server if it is of interest.
> >
> > It has some rather unusual features:
> >
> > No configuration file (c.f. Apache!)
> > Virtual hosting by creating multiple document directories.
> > Able to proxy a symbolic link through to another server.
> > Can run CGI scripts without forking for each request.
> > Embeddeds perl in a Web page (PSP)
> > Robust.
> >
> > Unfortunately documentation has not been my priority
> > but it is reasonably easy to run. Download the server
> > from http://www.openpsp.org/download.html, uncompress
> > and untar the results then run "server.pl" in the
> > resulting directory and browse to http://<yourhost>:9090/
> >
> > Any suggestions/bug reports appreciated.
> >
> > Cheers
> >
> > John.
> > coldwave@thunder.it
------------------------------
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 1373
***************************************