[19158] in Perl-Users-Digest
Perl-Users Digest, Issue: 1353 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 22 14:10:37 2001
Date: Sun, 22 Jul 2001 11:10:12 -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: <995825412-v10-i1353@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 22 Jul 2001 Volume: 10 Number: 1353
Today's topics:
Screen Resolution <louieyk@pc.jaring.my>
Re: Screen Resolution <pne-news-20010722@newton.digitalspace.net>
Re: Screen Resolution <louieyk@pc.jaring.my>
Re: Screen Resolution <tony_curtis32@yahoo.com>
Re: Screen Resolution (Alexis Machin)
What's the regular expression to check emails and to r (Miriam Raphael-Roberts)
Re: What's the regular expression to check emails and <ilya@martynov.org>
Re: where is the "standard library" <seandarcy@hotmail.com>
Re: where is the "standard library" <pne-news-20010722@newton.digitalspace.net>
Re: where is the "standard library" <jeff@vpservices.com>
Re: where is the "standard library" <seandarcy@hotmail.com>
Re: where is the "standard library" <seandarcy@hotmail.com>
Re: where is the "standard library" <pne-news-20010722@newton.digitalspace.net>
Re: where is the "standard library" <seandarcy@hotmail.com>
Re: where is the "standard library" <jeff@vpservices.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 23 Jul 2001 00:33:05 +0800
From: Snow Wolf <louieyk@pc.jaring.my>
Subject: Screen Resolution
Message-Id: <3B5B0041.33E38E1E@pc.jaring.my>
Hi,
Can anyone tell me how to check visitor's screen resolution by using
Perl ?
Thank you very much ^^
Snow Wolf
louieyk@pc.jaring.my
------------------------------
Date: Sun, 22 Jul 2001 18:47:14 +0200
From: Philip Newton <pne-news-20010722@newton.digitalspace.net>
Subject: Re: Screen Resolution
Message-Id: <so0mlt0bir4o93e0gb7fa275ikoibqhmkr@4ax.com>
On Mon, 23 Jul 2001 00:33:05 +0800, Snow Wolf <louieyk@pc.jaring.my>
wrote:
> Can anyone tell me how to check visitor's screen resolution by using
> Perl ?
Do you mean a visitor to your house?
print "What's your screen resolution, friend? ";
$res = <STDIN>;
chomp($res);
Or a visitor to a website, from a CGI script? If so, you'd probably do
it the same way is in a CGI script written in another language;
comp.infosystems.www.authoring.cgi is over there ------->
Followups set.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Mon, 23 Jul 2001 01:09:55 +0800
From: Snow Wolf <louieyk@pc.jaring.my>
Subject: Re: Screen Resolution
Message-Id: <3B5B08E3.94FC6491@pc.jaring.my>
I want my script to check visitor's screen resolution automatically
and from the obtained info, I can design my site (as I use CGI to generate
HTML) for better look, such as subsitute appropriate value into my script.
Thank Philip
Philip Newton wrote:
> On Mon, 23 Jul 2001 00:33:05 +0800, Snow Wolf <louieyk@pc.jaring.my>
> wrote:
>
> > Can anyone tell me how to check visitor's screen resolution by using
> > Perl ?
>
> Do you mean a visitor to your house?
>
> print "What's your screen resolution, friend? ";
> $res = <STDIN>;
> chomp($res);
>
> Or a visitor to a website, from a CGI script? If so, you'd probably do
> it the same way is in a CGI script written in another language;
> comp.infosystems.www.authoring.cgi is over there ------->
>
> Followups set.
>
> Cheers,
> Philip
> --
> Philip Newton <nospam.newton@gmx.li>
> That really is my address; no need to remove anything to reply.
> If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 22 Jul 2001 12:28:15 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Screen Resolution
Message-Id: <87zo9who0g.fsf@limey.hpcc.uh.edu>
>> On Mon, 23 Jul 2001 01:09:55 +0800,
>> Snow Wolf <louieyk@pc.jaring.my> said:
>> Philip Newton:
>> Or a visitor to a website, from a CGI script? If so,
>> you'd probably do it the same way is in a CGI script
>> written in another language;
>> comp.infosystems.www.authoring.cgi is over there
>> ------->
> I want my script to check visitor's screen resolution
> automatically and from the obtained info, I can design
> my site (as I use CGI to generate HTML) for better look,
> such as subsitute appropriate value into my script.
(a) please do not top-post; cite the relevant portions of
the original and append your new text.
(b) Philip already indicated which newsgroup would be
optimal for refining your question.
(c) if you think you need this information to generate
HTML for different browser configurations, you don't
understand HTML.
(d) in any case, it's impossible.
comp.infosystems.www.authoring.cgi is still over there ------->
[f'up reset]
hth
t
--
Beep beep! Out of my way, I'm a motorist!
------------------------------
Date: Sun, 22 Jul 2001 17:52:21 GMT
From: a.m@myDesktop.somewhereOverTheRainbow.org.nospam (Alexis Machin)
Subject: Re: Screen Resolution
Message-Id: <3b5b10f1.6177625@news.freeserve.co.uk>
On Mon, 23 Jul 2001 00:33:05 +0800, Snow Wolf <louieyk@pc.jaring.my> wrote:
>Hi,
>
>Can anyone tell me how to check visitor's screen resolution by using
>Perl ?
While you can find the screen dimensions, it's not a good idea to send down content
for that size, since few people have their browser maximised, and I personally
instantly leave any site that throws up a "fullscreen" window (since fullscreen on my
monitor is 1920x1200, I don't see why I can't use some of it for something else!)
In any case, you can't do it with perl alone. Use something like the script below to
send the width and height of the BROWSER window to a perl script on the server. If
the script can't find the dimensions (IE4/5,NS4/6,Moz should be ok), it will return
width and height as -1.
You'd probably need a meta refresh tag in your page too, in case javascript was
switched off, or not available in the browser.
Of course, you're assuming a visitor won't resize his/her browser at any time...
<html><head>
<script language="Javascript">
function init(){
var w=-1,h=-1;
if(document.layers||window.innerHeight){
h=windowheight=window.innerHeight;
w=windowheight=window.innerWidth;
}else if(document.body.offsetHeight){
h=windowheight=document.body.offsetHeight;
w=windowheight=document.body.offsetWidth;
}
top.location.href='/cgi-bin/myCgiScript.cgi?width='+w+'&height='+h;
}
</script></head>
<body onload="init()">
</body></html>
--
Alexis Machin
------------------------------
Date: 22 Jul 2001 10:38:36 -0700
From: miriamraphael@yahoo.com (Miriam Raphael-Roberts)
Subject: What's the regular expression to check emails and to remove html
Message-Id: <748729f5.0107220938.385b2e0f@posting.google.com>
Hi,
I know that you can remove HTML from text by using one regular expression.
I saw it once in a book amd I tried to find it today unsuccessfully.
Also, does anyone have a good regular expression that can check whether or not
an email address is in the correct format ?(and not a bogus email).
Can anyone help me with these two items? My email is miriamraphael@yahoo.com
Thanks!
------------------------------
Date: 22 Jul 2001 21:41:40 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: What's the regular expression to check emails and to remove html
Message-Id: <874rs42757.fsf@abra.ru>
MR> Hi,
MR> I know that you can remove HTML from text by using one regular expression.
MR> I saw it once in a book amd I tried to find it today
MR> unsuccessfully.
I'm not sure what do you really want. If you need to remove all tags
try this:
$html =~ s/<[^>]*>//g;
MR> Also, does anyone have a good regular expression that can check
MR> whether or not an email address is in the correct format ?(and not
MR> a bogus email).
Take from CPAN either Mail::CheckUser or Email::Valid.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Sun, 22 Jul 2001 14:43:15 GMT
From: jay <seandarcy@hotmail.com>
Subject: Re: where is the "standard library"
Message-Id: <3B5AE7D5.3070207@hotmail.com>
Thanks for the reply. As you suggested. Now if "@INC" has the standard
libraries, then I still don't understand my problem, because the second
library contains getopts.pl. I realize that the seventh and last library
is the current directory. But certainly the point of standard libraries
is to avoid cd'ing around.
So...If these are the standard libraries, and getopts.pl is in the
second, why doesn't perl getopts.pl find it???
[system@localhost system]$ perl -e 'print join("\n",@INC);'
/usr/lib/perl5/5.6.1/i386-redhat-linux
/usr/lib/perl5/5.6.1
/usr/lib/perl5/site_perl/i386-redhat-linux/5.6.1
/usr/lib/perl5/site_perl
/usr/lib/perl5/site_perl/5.6.0
/usr/lib/perl5/site_perl
.
jay
Akira Yamanita wrote:
> jay wrote:
>
>>I'm running perl 5.6.1 on rh7.1. In trying to install a ghostscript rpm,
>>I got the error message that it couldn't find getopts.pl.
>>
>>But:
>>[root@localhost root]# locate getopts.pl
>>/usr/lib/perl5/5.6.1/getopts.pl
>>
>>So I figured there's something wrong with the rpm, but....
>>
>>[root@localhost root]# perl getopts.pl
>>Can't open perl script "getopts.pl": No such file or directory
>>
>
> Of course not. getopts.pl is not in /root which is where you were
> trying to access it. You didn't specify a path nor did you change
> directories to /usr/lib/perl5/5.6.1
>
>
>>I don't have PERLLIB or PERL5LIB defined. As I read the docs, without
>>these defined, perl supposed to look in the "standard library". If
>>/usr/lib/perl5/5.6.1 isn't the standard library, what is? where is it set?
>>
>
> perl -e 'print join("\n",@INC);'
>
------------------------------
Date: Sun, 22 Jul 2001 17:42:12 +0200
From: Philip Newton <pne-news-20010722@newton.digitalspace.net>
Subject: Re: where is the "standard library"
Message-Id: <jvsllt0io31sk6s8cktrbukm03s3tuhj32@4ax.com>
On Sun, 22 Jul 2001 14:43:15 GMT, jay <seandarcy@hotmail.com> top-posted
full-quoted:
> But certainly the point of standard libraries is to avoid cd'ing around.
No; the point of standard libraries is to avoid having to specify full
paths for "require", and to allow for "use" to work.
> So...If these are the standard libraries, and getopts.pl is in the
> second, why doesn't perl getopts.pl find it???
Because Perl doesn't search @INC for command-line script arguments, only
for do, require, and use.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sun, 22 Jul 2001 08:38:56 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: where is the "standard library"
Message-Id: <3B5AF390.944375F9@vpservices.com>
jay wrote:
>
> Thanks for the reply. As you suggested. Now if "@INC" has the standard
> libraries, then I still don't understand my problem, because the second
> library contains getopts.pl.
@INC tells *perl* where to find modules for *perl* to require or use.
It does not tell your *shell* anything.
> >>[root@localhost root]# perl getopts.pl
> >>Can't open perl script "getopts.pl": No such file or directory
Those are commands and errors in your *shell*. The same kind of error
would happen if you substituted the words "rm" or "ls" for the word
"perl". (Don't try the former at home). And like any program run in the
shell, you need to pass a path to file arguments not located in the
current directory. (And if your system is properly configured, even if
it is in your current directory.)
BUT ... getopts.pl is not a program to be run in your shell, it is a
(very old and outdated) library to be used *inside a perl program*. So
write a program called "test" and in that program put a line "require
getopts.pl;" and then run that program in your shell. Within the
program "test" perl will use @INC to find getopts.pl so you won't need
to specify its location inside "test". You will, however, still have to
tell your shell where to find "test".
And BTW, did you happen to read this message at the top of the
getopts.pl file?
# This library is no longer being maintained, and is included for
backward
# compatibility with Perl 4 programs which may require it.
#
# In particular, this should not be used as an example of modern Perl
# programming techniques.
#
# Suggested alternatives: Getopt::Long or Getopt::Std
That means you should forget about getopts.pl and use one of those
others instead. It is a script that is intended for a version of perl
that became outdated seven years ago.
It is also possibly part of the reason for your confusion: .pl
originally stood for "Perl Library" and was used to denote scripts like
this one meant to be included in other scripts. But these days .pl is
more often (rightly or wrongly) short for "PerL script" and is more
often (rightly or wrongly) found on scripts intended to be run in the
shell as you tried to run this one.
> >>[root@localhost root]#
Geeze, back in "the days", one had to know something about one's system
before being root. (Well, that's a lie, my first experience as root was
on a NeXT cube and I knew nothing about either it or UNIX until I
floundered around for months shooting myself in the foot daily).
Sorry, Jay, don't take it personally, I'm just grumpy this morning.
Good luck.
--
Jeff
------------------------------
Date: Sun, 22 Jul 2001 15:51:27 GMT
From: jay <seandarcy@hotmail.com>
Subject: Re: where is the "standard library"
Message-Id: <3B5AF7BF.8040102@hotmail.com>
Thanks for the reply. As you suggested. Now if "@INC" has the standard
libraries, then I still don't understand my problem, because the second
library contains getopts.pl. I realize that the seventh and last library
is the current directory. But certainly the point of standard libraries
is to avoid cd'ing around.
So...If these are the standard libraries, and getopts.pl is in the
second, why doesn't perl getopts.pl find it???
[system@localhost system]$ perl -e 'print join("\n",@INC);'
/usr/lib/perl5/5.6.1/i386-redhat-linux
/usr/lib/perl5/5.6.1
/usr/lib/perl5/site_perl/i386-redhat-linux/5.6.1
/usr/lib/perl5/site_perl
/usr/lib/perl5/site_perl/5.6.0
/usr/lib/perl5/site_perl
.
jay
Akira Yamanita wrote:
> jay wrote:
>
>>I'm running perl 5.6.1 on rh7.1. In trying to install a ghostscript rpm,
>>I got the error message that it couldn't find getopts.pl.
>>
>>But:
>>[root@localhost root]# locate getopts.pl
>>/usr/lib/perl5/5.6.1/getopts.pl
>>
>>So I figured there's something wrong with the rpm, but....
>>
>>[root@localhost root]# perl getopts.pl
>>Can't open perl script "getopts.pl": No such file or directory
>>
>
> Of course not. getopts.pl is not in /root which is where you were
> trying to access it. You didn't specify a path nor did you change
> directories to /usr/lib/perl5/5.6.1
>
>
>>I don't have PERLLIB or PERL5LIB defined. As I read the docs, without
>>these defined, perl supposed to look in the "standard library". If
>>/usr/lib/perl5/5.6.1 isn't the standard library, what is? where is it set?
>>
>
> perl -e 'print join("\n",@INC);'
>
------------------------------
Date: Sun, 22 Jul 2001 15:58:26 GMT
From: jay <seandarcy@hotmail.com>
Subject: Re: where is the "standard library"
Message-Id: <3B5AF966.20402@hotmail.com>
Thanks for the reply. As you suggested. Now if "@INC" has the standard
libraries, then I still don't understand my problem, because the second
library contains getopts.pl. I realize that the seventh and last library
is the current directory. But certainly the point of standard libraries
is to avoid cd'ing around.
So...If these are the standard libraries, and getopts.pl is in the
second, why doesn't perl getopts.pl find it???
[system@localhost system]$ perl -e 'print join("\n",@INC);'
/usr/lib/perl5/5.6.1/i386-redhat-linux
/usr/lib/perl5/5.6.1
/usr/lib/perl5/site_perl/i386-redhat-linux/5.6.1
/usr/lib/perl5/site_perl
/usr/lib/perl5/site_perl/5.6.0
/usr/lib/perl5/site_perl
.
jay
Akira Yamanita wrote:
> jay wrote:
>
>>I'm running perl 5.6.1 on rh7.1. In trying to install a ghostscript rpm,
>>I got the error message that it couldn't find getopts.pl.
>>
>>But:
>>[root@localhost root]# locate getopts.pl
>>/usr/lib/perl5/5.6.1/getopts.pl
>>
>>So I figured there's something wrong with the rpm, but....
>>
>>[root@localhost root]# perl getopts.pl
>>Can't open perl script "getopts.pl": No such file or directory
>>
>
> Of course not. getopts.pl is not in /root which is where you were
> trying to access it. You didn't specify a path nor did you change
> directories to /usr/lib/perl5/5.6.1
>
>
>>I don't have PERLLIB or PERL5LIB defined. As I read the docs, without
>>these defined, perl supposed to look in the "standard library". If
>>/usr/lib/perl5/5.6.1 isn't the standard library, what is? where is it set?
>>
>
> perl -e 'print join("\n",@INC);'
>
------------------------------
Date: Sun, 22 Jul 2001 18:23:18 +0200
From: Philip Newton <pne-news-20010722@newton.digitalspace.net>
Subject: Re: where is the "standard library"
Message-Id: <hbvllt8m6il6s0sonioos0tga9tl50o29h@4ax.com>
On Sun, 22 Jul 2001 08:38:56 -0700, Jeff Zucker <jeff@vpservices.com>
wrote:
> jay wrote:
> >
> > Thanks for the reply. As you suggested. Now if "@INC" has the standard
> > libraries, then I still don't understand my problem, because the second
> > library contains getopts.pl.
>
> @INC tells *perl* where to find modules for *perl* to require or use.
> It does not tell your *shell* anything.
Irrelevant here.
> > >>[root@localhost root]# perl getopts.pl
> > >>Can't open perl script "getopts.pl": No such file or directory
>
> Those are commands and errors in your *shell*.
Nope. The shell needs to know where to find 'perl', but what perl does
with the command-line argument 'getopts.pl' is up to *it*. It could
choose to look for it in the current directory, in /, in @INC, in
$ENV{LD_LIBRARY_PATH}, or treat it as a command-line argument. It's perl
that gives you the error message.
> So write a program called "test"
Bad choice for a program name.
> You will, however, still have to tell your shell where to find "test".
It's likely that the shell already knows where to find test --
/usr/bin/test is a common place. Which is why you shouldn't name your
own scripts 'test' :) (I like 'tryit'.)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sun, 22 Jul 2001 16:21:13 GMT
From: jay <seandarcy@hotmail.com>
Subject: Re: where is the "standard library"
Message-Id: <3B5AFEB7.228DC241@hotmail.com>
Thanks for your reply. And I understand grumpy. FWIW, I'm trying to upgrade
the rpm for ghostscript and need root
permissions.
And my problem is that the ghostscript rpm tells me it won't install because
..it.. can't find getopts.pl:
[root@localhost i386]# rpm -Fvh ghostsc*
error: failed dependencies:
perl(getopts.pl) is needed by ghostscript-6.51-1
SO... since this is not a perl issue, I'm off to redhat bugzilla.
Thanks for all the help
jay
Jeff Zucker wrote:
>
>
> @INC tells *perl* where to find modules for *perl* to require or use.
> It does not tell your *shell* anything.
>
> > >>[root@localhost root]# perl getopts.pl
> > >>Can't open perl script "getopts.pl": No such file or directory
>
> Those are commands and errors in your *shell*. The same kind of error
> would happen if you substituted the words "rm" or "ls" for the word
> "perl". (Don't try the former at home). And like any program run in the
> shell, you need to pass a path to file arguments not located in the
> current directory. (And if your system is properly configured, even if
> it is in your current directory.)
>
> BUT ... getopts.pl is not a program to be run in your shell, it is a
> (very old and outdated) library to be used *inside a perl program*. So
> write a program called "test" and in that program put a line "require
> getopts.pl;" and then run that program in your shell. Within the
> program "test" perl will use @INC to find getopts.pl so you won't need
> to specify its location inside "test". You will, however, still have to
> tell your shell where to find "test".
>
> And BTW, did you happen to read this message at the top of the
> getopts.pl file?
>
> # This library is no longer being maintained, and is included for
> backward
> # compatibility with Perl 4 programs which may require it.
> #
> # In particular, this should not be used as an example of modern Perl
> # programming techniques.
> #
> # Suggested alternatives: Getopt::Long or Getopt::Std
>
> That means you should forget about getopts.pl and use one of those
> others instead. It is a script that is intended for a version of perl
> that became outdated seven years ago.
>
> It is also possibly part of the reason for your confusion: .pl
> originally stood for "Perl Library" and was used to denote scripts like
> this one meant to be included in other scripts. But these days .pl is
> more often (rightly or wrongly) short for "PerL script" and is more
> often (rightly or wrongly) found on scripts intended to be run in the
> shell as you tried to run this one.
>
> > >>[root@localhost root]#
>
> Geeze, back in "the days", one had to know something about one's system
> before being root. (Well, that's a lie, my first experience as root was
> on a NeXT cube and I knew nothing about either it or UNIX until I
> floundered around for months shooting myself in the foot daily).
>
> Sorry, Jay, don't take it personally, I'm just grumpy this morning.
> Good luck.
>
> --
> Jeff
------------------------------
Date: Sun, 22 Jul 2001 09:29:34 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: where is the "standard library"
Message-Id: <3B5AFF6E.5725E9C7@vpservices.com>
Philip Newton wrote:
> On Sun, 22 Jul 2001 08:38:56 -0700, Jeff Zucker <jeff@vpservices.com>
> wrote:
>
> It's perl
> that gives you the error message.
Yep, my bad.
> > So write a program called "test"
>
> Bad choice for a program name.
Actually that was a slightly evil choice on my part as a further example
of why one should put a path on script names in the shell.
>
> > You will, however, still have to tell your shell where to find "test".
>
> It's likely that the shell already knows where to find test --
> /usr/bin/test is a common place. Which is why you shouldn't name your
> own scripts 'test' :) (I like 'tryit'.)
I know, - been there, done that, that's why I suggested it - as a
learning experience. You left out the part where I said he should use
path names on file arguments even when they are in the current
directory. Hey, I admited to being grumpy this morning.
--
Jeff
------------------------------
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 1353
***************************************