[18126] in Perl-Users-Digest
Perl-Users Digest, Issue: 286 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 14 06:06:06 2001
Date: Wed, 14 Feb 2001 03:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982148711-v10-i286@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 14 Feb 2001 Volume: 10 Number: 286
Today's topics:
Re: ANN: Latitude longitude database (Csaba Raduly)
Re: Array question <jdb@ga.prestige.net>
Re: Array question <Jonathan.L.Ericson@jpl.nasa.gov>
comp.infosystems.www.authoring.cgi (BUCK NAKED1)
Re: comp.infosystems.www.authoring.cgi <godzilla@stomp.stomp.tokyo>
Re: comp.infosystems.www.authoring.cgi (Csaba Raduly)
CRC-32 in Perl (was: Strings and pointers in Perl?) <fw@lanvision.nl>
die hard hefe@in-time.se
File stat's <jdb@ga.prestige.net>
Re: Help with a perl/cgi script (Rob - Rock13.com)
Re: How bad is that Jeopardy post? <no@email.com>
Re: How bad is that Jeopardy post? <nospam@nospam.com>
How to measure the duration of a Perl-subfunction in fr <Marcus.Spang@germany.ncr.com>
Is there a tutorial in XML::Parser <andyh@littoralis.co.uk>
links in cgi? hefe@in-time.se
Re: links in cgi? <fw@lanvision.nl>
Re: localtime -> reverse -> localtime (Villy Kruse)
Re: Locking files in a CGI script (Chris Fedde)
Re: Locking files in a CGI script <lurvas@excite.com>
Re: Newbie Perl / CGI Question <lostshade@home.com>
Re: opening files <lostshade@home.com>
Re: opening files <Jonathan.L.Ericson@jpl.nasa.gov>
Re: Q: printing IEEE float or double as hex (Mark Jason Dominus)
Question <copenhagen@copenhagen.com>
Re: Question <tore@extend.no>
Re: Question <copenhagen@copenhagen.com>
Re: Question <tore@extend.no>
Re: rand function does not work (Homer Simpson)
Re: Replacing single-letter words doesn't work (Holger Marzen)
Re: Sendmail::Milter delrcpt problems (Chris Fedde)
Re: Strings and pointers in Perl? <fw@lanvision.nl>
Re: Syntax quickie: How do I get the index of an arrayr <bart.lateur@skynet.be>
Re: What v65 refer to ? nobull@mail.com
Why can't I grab this URL? <whataman@home.com>
Re: Why can't I grab this URL? (Chris Fedde)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 14 Feb 2001 09:46:56 +0000 (UTC)
From: real.email@signature.this.is.invalid (Csaba Raduly)
Subject: Re: ANN: Latitude longitude database
Message-Id: <Xns904868433quuxi@194.203.134.135>
And so it came to pass that "LatLong" <latlong@css2.com> on 13 Feb
2001 wrote <_Mji6.4761$hN2.881397@news3.cableinet.net>:
[snip blatant advert of latitude-longitude database]
Does ANN stand for annoying ?
--
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com http://www.sophos.com/
US Support +1 888 SOPHOS 9 UK Support +44 1235 559933
You are in a maze of twisted little minds, all different.
------------------------------
Date: Wed, 14 Feb 2001 04:07:16 GMT
From: "Jeremia d." <jdb@ga.prestige.net>
Subject: Re: Array question
Message-Id: <3A8968A5.F816F75D@ga.prestige.net>
--------------B381AADA56AF5FEBB64774A4
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
--------------B381AADA56AF5FEBB64774A4
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
Thanks alot, but someone has already helped me. Thanks again.
<br>Ian Shaughnessy wrote:
<blockquote TYPE=CITE><style></style>
<font size=-1>my $Files = `find /
-perm +4000`;</font> <font size=-1>my @FilesArray = split( /\n/, $Files
);</font> <font size=-1>That should work. That could be obfuscated
down to one line, but its more readable this way ;-)</font> <font size=-1>|
ian shaughnessy | <a href="mailto:conraduno@binxdsign.com">conraduno@binxdsign.com</a></font>
<blockquote
style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">"Jeremia
d." <<a href="mailto:jdb@ga.prestige.net">jdb@ga.prestige.net</a>> wrote
in message <a href="news:3A892E38.74B8A281@ga.prestige.net">news:3A892E38.74B8A281@ga.prestige.net</a>...
<pre>Ok i got it to where i can run the command to find all the suid files on the system</pre>
<pre>"$Files = system(`find / -perm +4000`);"</pre>
<pre>Now I want to store each file into an array "This is where I am stuck"</pre>
<pre>After that is complete I would like to take each file and run them with a file test operator</pre>
<pre>like -e "$file[0]" or warn "File is non existent";</pre>
<pre>I think I can do this just getting the files into an array is my problem</pre>
<pre>--
A little experience often upsets a lot of theory.</pre>
</blockquote>
</blockquote>
<pre>--
A little experience often upsets a lot of theory.</pre>
</body>
</html>
--------------B381AADA56AF5FEBB64774A4--
------------------------------
Date: 14 Feb 2001 05:25:48 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Array question
Message-Id: <861yt1al9f.fsf@jon_ericson.jpl.nasa.gov>
"Ian Shaughnessy" <conraduno@binxdsign.com> writes:
> Newsgroups: comp.lang.perl,comp.lang.perl,comp.lang.perl.misc
comp.lang.perl is _still_ a bogus group (and repeating it doesn't
make it better).
> my $Files = `find / -perm +4000`;
>
> my @FilesArray = split( /\n/, $Files );
>
> That should work. That could be obfuscated down to one line, but its more
> readable this way ;-)
What's obfuscated about:
my @files = qx{find / -perm +4000};
? Your way is ponderous compared to idiomatic Perl.
Jon
------------------------------
Date: Wed, 14 Feb 2001 01:09:45 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: comp.infosystems.www.authoring.cgi
Message-Id: <3497-3A8A2F39-3@storefull-248.iap.bryant.webtv.net>
What's wrong with this sister group? No posts there since Feb 4.
--Dennis
------------------------------
Date: Tue, 13 Feb 2001 23:53:44 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: comp.infosystems.www.authoring.cgi
Message-Id: <3A8A3988.4DB53780@stomp.stomp.tokyo>
BUCK NAKED1 wrote:
> What's wrong with this sister group? No posts there since Feb 4.
With A Purposeful Grimace And A Terrible Sound
She Pulls The Spitting High Tension Wires Down
Helpless People On A Subway Train
Scream Bug-eyed As She Looks In On Them
She Picks Up A Bus And She Throws It Back Down
As She Wades Through The Buildings Toward The Center Of Town
Oh No, They Say She's Got To Go Go Go Godzilla!
Oh No, There Goes Tokyo Go Go Godzilla!
History Shows Again And Again
How Nature Points Up The Folly Of Men
I stomped that newsgroup.
SQUISH! SQUISH!
Godzilla!
------------------------------
Date: Wed, 14 Feb 2001 09:47:44 +0000 (UTC)
From: real.email@signature.this.is.invalid (Csaba Raduly)
Subject: Re: comp.infosystems.www.authoring.cgi
Message-Id: <Xns90486AE26quuxi@194.203.134.135>
And so it came to pass that dennis100@webtv.net (BUCK NAKED1) on 14 Feb
2001 wrote <3497-3A8A2F39-3@storefull-248.iap.bryant.webtv.net>:
>What's wrong with this sister group? No posts there since Feb 4.
>
Is it because all CGI-related questions are asked in c.l.p.misc instead
?
--
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com http://www.sophos.com/
US Support +1 888 SOPHOS 9 UK Support +44 1235 559933
You are in a maze of twisted little minds, all different.
------------------------------
Date: Wed, 14 Feb 2001 10:45:02 +0100
From: Frank van Wensveen <fw@lanvision.nl>
Subject: CRC-32 in Perl (was: Strings and pointers in Perl?)
Message-Id: <5gkk8tgb8soi660smvsgucjhk7ch8usb9r@4ax.com>
On Tue, 13 Feb 2001 21:44:45 GMT, tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
wrote:
[In answer to my question on strings and chars]
> There is a few ways but you don't really say what it is you are doing to
> the string so that influences things.
Well, basically I'm trying to calculate the 32-bit CRC for a string. I
haven't found *any* perl code at all to do this, just modules that
call C code. The String::crc32 module on Cpan is an extension, the
Compression::* modules call code in the Zlib compression library.
I want to write a piece of Perl code without external dependencies
(i.e. that will run without having to install things like Zlib or
exensions). The algorithm itself is fairly simple. Coding it is simple
in C but not so in Perl. (That's probably the reason that everyone's
doing this in C.)
So what I'm looking for (call me stubborn) is a Perl-only method of
calculating CRC32. I'll be CRC-ing strings (not huge blocks of data)
so performance shouldn't be too much of an issue. I hope.
Suggestions anyone?
FVW
------------------------------
Date: 14 Feb 2001 09:46:19 GMT
From: hefe@in-time.se
Subject: die hard
Message-Id: <96dk5b$6q2$1@news.netmar.com>
How do you kill a cgi script and print out ONLY your own error message to the
browser?
I noticed that if you do a regular die, the message doesn't show up in the
browser, so I used
use CGI::Carp qw(fatalsToBrowser);
This prints out:
"Content-type: text/html
Software error:
Error message! at cgi.cgi line 22, <FILE> chunk 1.
For help, please send mail to the webmaster (webmaster@server.net), giving
this error message and the time and date of the error."
Don't want that!
I just want the Error message!
Can I do this with die or something similar?
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: Wed, 14 Feb 2001 04:48:24 GMT
From: "Jeremia d." <jdb@ga.prestige.net>
Subject: File stat's
Message-Id: <3A897248.88E385A4@ga.prestige.net>
Ok, I am working on a small app that will search your hdd for SUID/SGID
files. Now I have gotten that down and got them stored into an array,
and I can pull out each one. Now I am wondering of a easier and faster
way to stat the files, permissions for owner, group, and world. Then
check them perms and files against like a ACL or something similar. So
like if /bin/su has Setuid bit set and is NOT owned by root notify user.
I can accomplish this but just taking the file perms of each file and
storing them to test against. Thnks
--
A little experience often upsets a lot of theory.
------------------------------
Date: 14 Feb 2001 05:16:21 GMT
From: rob_13@excite.com (Rob - Rock13.com)
Subject: Re: Help with a perl/cgi script
Message-Id: <9048F5DCrock13com@207.91.5.10>
newuser <newuser@nospam.slip.net>:
>Hello,
> I am having some problems where to insert a part of a perl/cgi
> script
>into a master perl script and was wondering what is the correct
>way to post the script here for help.
> Is it ok to post the whole script or just a snippet of it here
> for help.
I'm new here but if they're large post them to some webspace and give
the URL. Make sure they can be downloaded, some servers don't like to
serve .pl or .cgi files.
The master script could etiher call the other one, or you can paste
it directly in (perhaps as a subroutine).
--
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/
------------------------------
Date: Wed, 14 Feb 2001 06:06:05 GMT
From: "Frank Miller" <no@email.com>
Subject: Re: How bad is that Jeopardy post?
Message-Id: <hfpi6.420323$U46.12354662@news1.sttls1.wa.home.com>
What the hell does not having a sig mean, other then I am not a geek. All
you've really created is a nerd filter.
FrankM
------------------------------
Date: 14 Feb 2001 06:46:31 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: How bad is that Jeopardy post?
Message-Id: <96d9k7$abj$0@216.155.32.204>
In article <slrn98hq7o.ns9.vek@pharmnl.ohout.pharmapartners.nl>,
vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse) wrote:
| The problem is nore that the entire post that is responded to is
| quoted in full, and the answer isn't given in context.
|
| In the good old days you were not allowed by the software to post
| message where there is more quoted text than new text.
I miss those days .. all the 'me too' posts (at the top) (with
EVERYTHING following it) (including multiple sigs) are starting to
irritate the bejesus outta me. particularly in e-mail. (mailing lists
and whatnot) -- we try and correct them, but people just don't listen.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Wed, 14 Feb 2001 11:12:11 +0100
From: "Marcus Spang" <Marcus.Spang@germany.ncr.com>
Subject: How to measure the duration of a Perl-subfunction in fractions of a second?
Message-Id: <3a8a59fc$1@rpc1284.daytonoh.ncr.com>
Hello,
I'm a Perl newbie.
I need to measure the duration of a Perl-subfunction in fractions of a
second.
I've tried 'localtime' but that doesn't return fractions of a second.
Thank's
Marcus
------------------------------
Date: Wed, 14 Feb 2001 10:26:28 -0000
From: "Andy Holyer" <andyh@littoralis.co.uk>
Subject: Is there a tutorial in XML::Parser
Message-Id: <q3ti6.68722$_B6.904544@monolith.news.easynet.net>
The time has come (the Walrus said...)
I need to parse some XML. As I've discovered, the true way to do this is to
use XML::Parser.
Now, I think I follow what this module does, but I'm still a bit lost where
to start. Has anyone produced a tutorial in how to use it?
Thanks in Advance.
------------------------------
Date: 14 Feb 2001 09:34:01 GMT
From: hefe@in-time.se
Subject: links in cgi?
Message-Id: <96dje9$51a$1@news.netmar.com>
I have a "vision", but haven't found anything like this in the docs...
I have a cgi script which prints out links for other webpages. Currently, I'm
doing this as
print '<a href.......</a>';
Is there an alternate way of doing this using cgi?
And, more importantly, is there a way to print out your own error message if
the page can not be accessed, instead of getting a "404" from the
server
where the file used to be?
If it's possible, I would like two things to happen if a file is not found:
- error message to the user, in the browser
- error message emailed to me, so I can take care of the problem
Can this be accomplished?
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: Wed, 14 Feb 2001 10:53:45 +0100
From: Frank van Wensveen <fw@lanvision.nl>
Subject: Re: links in cgi?
Message-Id: <9vkk8t8uv9oe4tkm445p4hktpe2akrh3g0@4ax.com>
On 14 Feb 2001 09:34:01 GMT, hefe@in-time.se wrote:
> I have a cgi script which prints out links for other webpages. Currently, I'm
> doing this as print '<a href.......</a>';
This is the standard way for a CGI script to do things. Whatever you
want to appear on the webpage must be output by the CGI script to
stdout.
If it's redirection that you want (i.e. the CGI script refers the
browser to another web page) this can be done by:
sub redirect { # Redirect browser to URL
$url = shift;
print "Content-type: text/html\n";
print "Location: $url\n\n";
exit 0;
}
> Is there an alternate way of doing this using cgi?
Not that I know of. Maybe if you explain why you want to do it
differently (IOW what are you trying to accomplish) we can think of
one.
> And, more importantly, is there a way to print out your own error message if
> the page can not be accessed, instead of getting a "404" from the
> server where the file used to be?
That's something you want to take care of in your webserver config. Or
if you want to prevent misdirection on other websites, first check if
the page loads and then print an error message? (I'm not really sure
what you're trying to do here.)
> If it's possible, I would like two things to happen if a file is not found:
> - error message to the user, in the browser
That's what your webserver does. You can configure what the error
message should look like (on my websites I use either my own HTML page
or even a CGI script as a 404 error handler). See your webserver docs
for details.
> - error message emailed to me, so I can take care of the problem
OK, so your 404-handler should be a CGI script.
> Can this be accomplished?
Yes, but how depends on which webserver you run.
Alternatively, your CGI script should check for the existence of a
given file, and modify its output accordingly.
FVW
------------------------------
Date: 14 Feb 2001 08:22:08 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: localtime -> reverse -> localtime
Message-Id: <slrn98kg1g.rej.vek@pharmnl.ohout.pharmapartners.nl>
On Tue, 13 Feb 2001 15:29:40 +0100, Marc Roos <postmaster@roosit.nl> wrote:
>($sec,$min,$hour,$mday,$mon,$year)=
> localtime(mktime(0,0,0,0,int($month-1),$yeari-1900));
> 17 printf "sec= %s min= %s, hour= %s,mday= %s,mon= %s,year= %s\n",
>$sec,$min,$hour,$mday,$mon+1,$year+1900;
>===============================
>
Don't forget the isdst parameter to mktime, or your time might be one hour
off from what you beleive it is supposed to be.
Villy
------------------------------
Date: Wed, 14 Feb 2001 05:35:43 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Locking files in a CGI script
Message-Id: <POoi6.105$zN2.170647552@news.frii.net>
In article <01HW.B6AF3662000394C904CE5CE0@news.communique.se>,
Hariga Ben <lurvas@excite.com> wrote:
>I'm pretty sure this is covered by some FAQ or something similar but I can't
>find it. So, if someone knows where I can find some hints on how to do this I
>would be grateful for a pointer.
>
>I'm writing a few simple CGI scripts which will allow two people to change
>some information. Since the updates will be few (probably in the order of
>once or twice a week) there will probably be no problem with concurrent
>changes etc ... but I would like to learn a few new thing I thought I would
>take the opportunity to play a bit 8-)
>
>Adding information is no problem, then I can 'flock'. But I don't really know
>how to proceed when it comes to changing some info. I mean I can't use
>'flock' since I can't be sure that there will be a second call that submits
>the changes and releases the lock ... (I'm probably looking for a lock that
>times out after 15 minutes or so).
>
>I'll have limited access to the server so I'm unsure if I can have some
>regular "clean up" script running. The info I'm changing are a few text
>files.
> h.B.
There is a common paradigm for this. Before commiting data check
that the data on disk is the same as it was when the form was
generated. If the data is the same then the commit is fine. Otherwise
report an error and re-prompt the user with a new form.
You can use a hidden field or a cookie to carry a checksum or a
copy of the original data between the generate and the commit phases
of the CGI script.
chris
--
This space intentionally left blank
------------------------------
Date: Wed, 14 Feb 2001 06:58:41 +0100
From: Lurviga Ben <lurvas@excite.com>
Subject: Re: Locking files in a CGI script
Message-Id: <lurvas-DED937.06584114022001@news.umu.se>
In article <96c591$l9r$1@nntp9.atl.mindspring.net>, "Kurt Stephens"
<kstep@pepsdesign.com> wrote:
> Any action that changes data on the server should be atomic - a single
> call
> locks the resource, updates it and frees the lock. The problem is
> maintaining the state of the application between the time that the user
> starts the action and when the data is ready to be written.
Yes, you're abosolutely right. After I had posted the article I went
home at sat down in front of the TV and realized that I had approached
the problem in completely the wrong way: I shouldn't do database locking
I should lock a record (with a time-out).
And this is quite simple. As you say I need another field and a few
lines of code.
I should have realized this ... probably I was too busy trying to solve
the problem the wrong way instead of taking a step back and look if it
was the right way of doing it.
Well, this should be fixed quickly. Thanks.
jem
--
Lurviga Ben
lurvas@excite.com
------------------------------
Date: Wed, 14 Feb 2001 05:30:12 -0000
From: <lostshade@home.com>
Subject: Re: Newbie Perl / CGI Question
Message-Id: <t8k5v4p2s23g82@corp.supernews.com>
Oh, It took me a minute to figure out what you were asking and Im still
not positive this is what you were looking for but.
print "<INPUT TYPE=HIDDEN NAME='myparam' value='myval'>";
It'll pass on with thw query string when you submit
Matt York wrote:
>
> Hi Group,
>
> I'm currently trying to write a CGI script that will allow me to specify
> my own parameters as well as those generated by a form.
> e.g.
>
> I am trying to get the parameter myparam passed into the next page not
just the form items.
>
> print "<p>username and password</p>";
> print param('myparam','myval'');
> print textfield(-name=>'username');
> print "<BR><p>Password</p>";
> print password_field(-name=>'password');
> print "<BR><p>Press submit below when done</p>";
> print submit('Login');
> print end_form;
>
> can anyone see what i'm doing wrong ?
>
>
>
>
>
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Wed, 14 Feb 2001 05:30:11 -0000
From: <lostshade@home.com>
Subject: Re: opening files
Message-Id: <t8k5v3p14ebq7e@corp.supernews.com>
Amazing,
Im Mike as well and searching for the exact same thing today!!!!
I've done some extensive studing today and have not found a solution. I
thought I could read the file in with the open command however it appears
that it is a "disk" command as opposed to opening something off the net.
In other words it accesses the file locally, so it wont understand a web
address.
There has to be some way to load the data other then open?
Anyone know how to make those jump pages? Without clicking your sent to
another page?
Here is my thought.
turn my text documents into a simple html page with my txt file as a query
string. It would jump into my perl script with the data loaded. It could
work especilly if you could set the timer to 0 on the jump page to make it
occur immediately. The huge query string could be hidden by using frames.
Anyhow, Mike if you find the solution let me know.
Mike
M Comerford wrote:
>
>
> Hi, I am new at programming with perl and I was wondering if perl scripts
> can open up files directly over the internet. For example, my script is
> running on one server and I want it to be able to open a .txt file that
runs
> on a completely different external server. So, in the "open" command I
am
> going to need a web address. Is this possible?
>
> Any advice would be greatly appreciated.
> Mike
>
>
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: 14 Feb 2001 05:09:54 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: opening files
Message-Id: <8666idalzx.fsf@jon_ericson.jpl.nasa.gov>
"M Comerford" <mcomerf@nortelnetworks.com> writes:
> Hi, I am new at programming with perl and I was wondering if perl scripts
> can open up files directly over the internet. For example, my script is
> running on one server and I want it to be able to open a .txt file that runs
> on a completely different external server. So, in the "open" command I am
> going to need a web address. Is this possible?
You're going to need a module - perhaps
http://search.cpan.org/search?dist=libwww-perl
could be of service?
Jon
------------------------------
Date: Wed, 14 Feb 2001 09:18:37 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Q: printing IEEE float or double as hex
Message-Id: <3a8a4d6c.49c1$ef@news.op.net>
In article <3A89B6DD.597BC8F9@lmco.com>,
Chuck Meyers <chuck.meyers@lmco.com> wrote:
>Is there a way within perl to print a float or double as a 32 or 64 bit
>integer?
I think this is what you want:
@bytes = reverse unpack "C*", pack "f", 1.125;
print "@bytes\n";
$int = unpack 'L', pack "f", 1.125;
print "$int\n";
Omit the 'reverse' on a big-endian machine. Use 'Q' and 'd' instead
of 'L' and 'f' for doubles. (I think; check the 'pack' manual.)
>Are calling a C routine or picking the double apart bit by bit the only
>options?
Naah.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Wed, 14 Feb 2001 17:21:15 +1000
From: "Copenhagen" <copenhagen@copenhagen.com>
Subject: Question
Message-Id: <_mqi6.285$yps1.19857888@news.randori.com>
I have a quick question.
Snip of code is below:
#the items are Y or N
#I have specific items I need to pull from the array. (There are about 50
fields in this table)
my ($item1,$item2,$item3) = @array; #fetched from DBI
my $num = 1; #for counting purposes
my ($box_1,$box_2); #used for output to template generator
my %hash = (1,"item1",2,"item2",3,"item3"); #so that my <select name =
FIELD> is correct
#now this is where I am having my problem
foreach $thing($item1,$item2,$item3) {
$item = $hash{$num}; #so that my <select name = FIELD> is correct
if ($thing eq "Y") {
$box."_"."$num" .= "<select size=\"1\" name= $item>";
$box."_"."$num" .= "<option value=\"Y\" selected>Yes</option>";
$box."_"."$num" .= "<option value=\"N\">No</option>";
$box."_"."$num" .= "</select>";
} else {
$box."_".$num .= "<select size=\"1\" name= $item>";
$box."_".$num .= "<option value=\"Y\">Yes</option>";
$box."_".$num .= "<option value=\"N\" selected>No</option>";
$box."_".$num .= "</select>";
}
$num++;
}
}
From the code above I think you can get the idea of what I am trying to
accomplish. I need to generate code which equals
$box_1 =
<select size="1" name= $item>
<option value="Y">Yes</option>
<option value="N" selected>No</option>
</select>
$box_2 =
<select size="1" name= $item>
<option value="Y">Yes</option>
<option value="N" selected>No</option>
</select>
$box_3 =
<select size="1" name= $item>
<option value="Y">Yes</option>
<option value="N" selected>No</option>
</select>
but without having to do a if/else for 30 + items
Any help is greatly appreciated.
--
WOW Only two days...
Give me a couple more and I will script the world into being :)
------------------------------
Date: Wed, 14 Feb 2001 09:28:09 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: Question
Message-Id: <MPG.14f46007b873c8959898ac@news.online.no>
In article <_mqi6.285$yps1.19857888@news.randori.com>,
copenhagen@copenhagen.com says...
> I have a quick question.
> Snip of code is below:
>
> #the items are Y or N
> #I have specific items I need to pull from the array. (There are about 50
> fields in this table)
> my ($item1,$item2,$item3) = @array; #fetched from DBI
> my $num = 1; #for counting purposes
> my ($box_1,$box_2); #used for output to template generator
> my %hash = (1,"item1",2,"item2",3,"item3"); #so that my <select name =
> FIELD> is correct
>
> #now this is where I am having my problem
> foreach $thing($item1,$item2,$item3) {
> $item = $hash{$num}; #so that my <select name = FIELD> is correct
> if ($thing eq "Y") {
> $box."_"."$num" .= "<select size=\"1\" name= $item>";
> $box."_"."$num" .= "<option value=\"Y\" selected>Yes</option>";
> $box."_"."$num" .= "<option value=\"N\">No</option>";
> $box."_"."$num" .= "</select>";
> } else {
> $box."_".$num .= "<select size=\"1\" name= $item>";
> $box."_".$num .= "<option value=\"Y\">Yes</option>";
> $box."_".$num .= "<option value=\"N\" selected>No</option>";
> $box."_".$num .= "</select>";
> }
> $num++;
> }
> }
How about this approach;
my @things = @array; # DBI
my %output;
foreach my $thing (@things) {
my $yes_selected = ($thing eq 'Y') ? ' SELECTED' : '';
my $no_selected = ($thing ne 'Y') ? ' SELECTED' : '';
$output{$thing} = qq|
<SELECT NAME="item_$thing" SIZE="1">
<OPTION VALUE="Y"$yes_selected>Yes</OPTION>
<OPTION VALUE="N"$no_selected>No</OPTION>
</SELECT>
|;
}
Unfortunately, I haven't had the chance to test this. It should give
you a hint on what I'm trying to say, though. :-)
--
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/
------------------------------
Date: Wed, 14 Feb 2001 19:13:04 +1000
From: "Copenhagen" <copenhagen@copenhagen.com>
Subject: Re: Question
Message-Id: <21si6.296$yps1.42336308@news.randori.com>
That would be ok if all the items in the array were y/n items but they all
ate not.
"Tore Aursand" <tore@extend.no> wrote in message
news:MPG.14f46007b873c8959898ac@news.online.no...
> In article <_mqi6.285$yps1.19857888@news.randori.com>,
> copenhagen@copenhagen.com says...
> > I have a quick question.
> > Snip of code is below:
> >
> > #the items are Y or N
> > #I have specific items I need to pull from the array. (There are about
50
> > fields in this table)
> > my ($item1,$item2,$item3) = @array; #fetched from DBI
> > my $num = 1; #for counting purposes
> > my ($box_1,$box_2); #used for output to template generator
> > my %hash = (1,"item1",2,"item2",3,"item3"); #so that my <select name =
> > FIELD> is correct
> >
> > #now this is where I am having my problem
> > foreach $thing($item1,$item2,$item3) {
> > $item = $hash{$num}; #so that my <select name = FIELD> is correct
> > if ($thing eq "Y") {
> > $box."_"."$num" .= "<select size=\"1\" name= $item>";
> > $box."_"."$num" .= "<option value=\"Y\"
selected>Yes</option>";
> > $box."_"."$num" .= "<option value=\"N\">No</option>";
> > $box."_"."$num" .= "</select>";
> > } else {
> > $box."_".$num .= "<select size=\"1\" name= $item>";
> > $box."_".$num .= "<option value=\"Y\">Yes</option>";
> > $box."_".$num .= "<option value=\"N\" selected>No</option>";
> > $box."_".$num .= "</select>";
> > }
> > $num++;
> > }
> > }
>
> How about this approach;
>
> my @things = @array; # DBI
> my %output;
> foreach my $thing (@things) {
> my $yes_selected = ($thing eq 'Y') ? ' SELECTED' : '';
> my $no_selected = ($thing ne 'Y') ? ' SELECTED' : '';
> $output{$thing} = qq|
> <SELECT NAME="item_$thing" SIZE="1">
> <OPTION VALUE="Y"$yes_selected>Yes</OPTION>
> <OPTION VALUE="N"$no_selected>No</OPTION>
> </SELECT>
> |;
> }
>
> Unfortunately, I haven't had the chance to test this. It should give
> you a hint on what I'm trying to say, though. :-)
>
>
> --
> Tore Aursand - tore@extend.no - http://www.extend.no/~tore/
------------------------------
Date: Wed, 14 Feb 2001 11:38:25 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: Question
Message-Id: <MPG.14f47e8a5e34b61d9898ad@news.online.no>
In article <21si6.296$yps1.42336308@news.randori.com>,
copenhagen@copenhagen.com says...
>> my @things = @array; # DBI
>> my %output;
>> foreach my $thing (@things) {
>> my $yes_selected = ($thing eq 'Y') ? ' SELECTED' : '';
>> my $no_selected = ($thing ne 'Y') ? ' SELECTED' : '';
>> $output{$thing} = qq|
>> <SELECT NAME="item_$thing" SIZE="1">
>> <OPTION VALUE="Y"$yes_selected>Yes</OPTION>
>> <OPTION VALUE="N"$no_selected>No</OPTION>
>> </SELECT>
>> |;
>> }
> That would be ok if all the items in the array were y/n items but
> they all ate not.
First of all; Learn how to quote. Your answers should appear _below_
the original posting.
Secondly; If you want (proper) help, please describe your problem as
accurate as possible. This time, the number of variables weren't
mentioned, which lead to a "wrong" answer.
Now back to the problem; How do you know what to select? I'm not sure
that you are giving us all the details on the problem, or is it me that
can't understand what you're meaning?
--
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/
------------------------------
Date: 14 Feb 2001 06:16:15 GMT
From: homer.simpson@springfield.nul (Homer Simpson)
Subject: Re: rand function does not work
Message-Id: <96d7rf$ara$0@216.39.134.61>
This sample should help explain what's happening:
#!/usr/bin/perl -w
srand ; # init. the qseudo-random # generator
@All_Quotes=<DATA> ; # everything after the __END__ token
# ----------------------------------------------------------------------------
$temp=join("",@All_Quotes) ; # string all quotes together
@All_Quotes=split(/%%/,$temp) ; # make a new array with quotes as elements
$All_Quotes=@All_Quotes ; # get number of elements in the array
$rand_num=rand($All_Quotes) ; # get a random number for the quote
# and display it.
print $All_Quotes[$rand_num];
print "Random number was $rand_num \n";
__END__
%%
Quote ONE
%%
Quote TWO
%%
Quote THREE
%%
In article <20010213122239.17652.00000644@ng-cm1.aol.com>,
falc2199@aol.comNOJUNK (Falc2199) wrote:
>The rand function in the following script does not seem to work. It is suppose
>to choose the index of one of the three files in the array and load that file.
>But it always chooses the first file (meaning the rand function is always
>returning 1, I think). Can ne1 make sense of this...
>
>#!/usr/bin/perl
>
>print "Content-type: text/html\n\n";
>
>print "<HTML>\n<BODY>\n";
>
>srand;
>
>@articles = ("fact1.html", "fact2.html", "fact3.html");
>
>$random = rand(@aritcles);
>
>$article = $articles[$random];
>
>open(FILE, $article);
>
>while(<FILE>)
>{
>
>print $_;
>
>}
>close(FILE);
>print "</BODY>\n";
>print "</HTML>\n";
>
>Thanks in advance for any help,
>Jehan
>
>
>
>
>To e-mail, remove NOJUNK
------------------------------
Date: 14 Feb 2001 08:13:24 GMT
From: holger.marzen@sik-gmbh.de (Holger Marzen)
Subject: Re: Replacing single-letter words doesn't work
Message-Id: <slrn98kfh4.gs9.holger.marzen@sally.sik-gmbh.de>
On Tue, 13 Feb 2001 19:18:25 GMT, Uri Guttman wrote:
> HM> $suchtext =~ s/(^| )[A-Za-z0-9ÄÖÜäöüß]{1}(?=
> HM> [ ]|$)//g;
>
> HM> First it looks for the beginning-of-line or a SPACE. Then for
> HM> exactly one of the characters
> HM> A-Za-z0-9ÄÖÜäöüß. Then for end-of-line or a
> HM> SPACE, but that SPACE will be seen after the deletion.
>
>some minor improvements. do you realize you will delete that leading
>space if it exists? maybe put $1 in the replacement string to correct
>that.
It's ok. I want it to be deleted.
>theres is no need for the {1} as 1 char is all a char class will ever
>match by itself.
Right, but I have another line below with a {2} to eliminiate 2-letter
words. Looks nicer. Oh, I can replace it by {1,2}.
>there is no need for [ ] to in the lookahead. in fact what if the space
>you find is really a tab or newline? you might be better off matching a
>\s there (and also in the beginning).
>adding the /i modifier will allow you to use only A-Z and possibly match
Let's see:
$suchtext =~ s/(^|\s)[A-Z0-9ÄÖÜäöüß\-_]{1,2}(?=\s|$)//ig
seems to work ok.
Instead of (^|\s) I think I could also write [\^\s] but I am not sure if
- \^ is start-of-line instead NOT
- \s is a space instead of s (can I use special classes like \s in [] ?)
>more locale chars in the class. look into perl 5.6's support of posix
>char classes which might solve the problem better. this is possible:
This is perl, version 5.005_03
------------------------------
Date: Wed, 14 Feb 2001 06:31:02 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Sendmail::Milter delrcpt problems
Message-Id: <GCpi6.109$zN2.188319744@news.frii.net>
In article <96boks$184t$1@dunlop.dowcarter.com>,
Rob Blake <dr.bob@dowcarter.com> wrote:
>
>Has anyone else managed to get delrcpt to work properly in the
>Sendmail::Milter module?
>
>I've been playing all day with it, and I've got to the stage where I can
>rewrite headers, add new headers, and add new recipients successfully.
>The problem comes when I try and delete current recipients.
>
>I've tried passing the recipient name from the envrcpt callback, and
>I've tried entering a particular address hardcoded in the script.
>Each time the ctx->delrcpt command reports success, but the recipient
>still gets a copy of the message.
>
>Concerned, I tried adding a bogus email address to be deleted from the
>recipient list. The delrcpt command happily reported success for this
>one too, despite the fact it didn't appear anywhere in the message.
>
>Here's the appropriate bit of code:
>
> for $rcpt ("dr.bob\@dowcarter.com","arse\@feck.com") {
> if ($ctx->delrcpt($rcpt) == undef) {
> print "Argh, recipient $rcpt not deleted\n";
> } else {
> print "Removed recipient $rcpt\n";
> }
> }
>
I have only limited experiance with the module. Envrcpt_callback
gets called once for each recipient. I'd have expected the convention
to be more on these lines:
sub envrcpt_callback
{
my $ctx = shift;
my $rcpt = shift;
if ($rcpt =~ /arse\@feck.com/) {
$ctx->delrcpt($rcpt);
}
return SMFIS_CONTINUE;
}
Charles Ying does not give an example of its use any where in
the package. And the rcpt filter is excluded from the example
in the libmilter source in 8.11.2. I wonder if that is some kind
of a hint. You might send him mail to see if he has any thoughts.
chris
--
This space intentionally left blank
------------------------------
Date: Wed, 14 Feb 2001 10:08:13 +0100
From: Frank van Wensveen <fw@lanvision.nl>
Subject: Re: Strings and pointers in Perl?
Message-Id: <glik8t08k5okkcakilkvudjvp9mi7cvt3l@4ax.com>
On Tue, 13 Feb 2001 17:18:06 +0100, Marco Natoni <foo@bar.va> wrote:
> but I keenly suggest you to explore the marvellous world of regular
> expressions,
I wholeheartedly agree, and if it were a simple reformatting task I'd
already have done that. But the 'do something wich each character'
involves a CRC calculation among other things which is a little hard
to do with regexps. :-)
FVW
------------------------------
Date: Wed, 14 Feb 2001 08:56:51 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Syntax quickie: How do I get the index of an arrayref?
Message-Id: <s0ik8tsbudrtm81ohpa3ciqsg4d4heud34@4ax.com>
Philip Obbard wrote:
>Question: I know I can get the index of @items by using $#items. But if
>$items is actually an arrayref, which variable to I use?
It's not really a variable.
$#$items
If your arrayref is too complex, you can putit between braces.
$#{$items}
--
Bart.
------------------------------
Date: 14 Feb 2001 08:54:17 +0000
From: nobull@mail.com
Subject: Re: What v65 refer to ?
Message-Id: <u9g0hhh9pi.fsf@wcl-l.bham.ac.uk>
nobull@mail.com writes:
> I've not submitted this to perlbug (ID 20010213.008).
s/not//;
Like... duh!
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 14 Feb 2001 05:24:00 GMT
From: "What A Man !" <whataman@home.com>
Subject: Why can't I grab this URL?
Message-Id: <3A8A16DA.77E98BB5@home.com>
Why can't I grab this URL?
http://www.fortunecity.com/millenium/blyton/243/clemrule.zip
My coding below grabs most every URL for me and stores it
in $tmpfile. However, a URL on a webhost like this one
redirects to the webhost's HTML default page. From a
browser I get the correct zip file, but from the perl
script below I get a default html page. Why?
$ua = LWP::UserAgent->new;
$ua->agent("$0/0.1 " . $ua->agent);
my $req = new HTTP::Request 'GET', $URL;
$req->header('Accept' => 'text/html');
$res = $ua->request($req, $tmpfile);
if ($res->is_error) {
print "$res->status_line . "\n"; exit();
};
I've also tried this using LWP::Simple's getstore($URL,
$tmpfile), and LWP''s UserAgent $ua->mirror($URL,
$tmpfile). Same results... they grab most files OK, except
for one that defaults to an HTML page.
My server is BSDi running Apache, and of course I don't
know what software the servers are running where I am
retrieving the files from.
Is there a way to get around this problem, or am I doing
something wrong?
Please help. This is the fourth time I've posted this in
over a week. I hope this one shows up. :-(
Thanks,
Dennis
------------------------------
Date: Wed, 14 Feb 2001 05:47:45 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Why can't I grab this URL?
Message-Id: <5_oi6.106$zN2.188836864@news.frii.net>
In article <3A8A16DA.77E98BB5@home.com>,
What A Man ! <whataman@home.com> wrote:
>Why can't I grab this URL?
>
>http://www.fortunecity.com/millenium/blyton/243/clemrule.zip
>
>My coding below grabs most every URL for me and stores it
>in $tmpfile. However, a URL on a webhost like this one
>redirects to the webhost's HTML default page. From a
>browser I get the correct zip file, but from the perl
>script below I get a default html page. Why?
>
>$ua = LWP::UserAgent->new;
>$ua->agent("$0/0.1 " . $ua->agent);
>my $req = new HTTP::Request 'GET', $URL;
>$req->header('Accept' => 'text/html');
>$res = $ua->request($req, $tmpfile);
>if ($res->is_error) {
> print "$res->status_line . "\n"; exit();
> };
>
>I've also tried this using LWP::Simple's getstore($URL,
>$tmpfile), and LWP''s UserAgent $ua->mirror($URL,
>$tmpfile). Same results... they grab most files OK, except
>for one that defaults to an HTML page.
>
>My server is BSDi running Apache, and of course I don't
>know what software the servers are running where I am
>retrieving the files from.
>
>Is there a way to get around this problem, or am I doing
>something wrong?
>
>Please help. This is the fourth time I've posted this in
>over a week. I hope this one shows up. :-(
>
The code below prints "200 OK". I suspect that the extra quote in your
print statement might be part of the problem.
Good Luck
chris
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
my $URL = "http://www.fortunecity.com/millenium/blyton/243/clemrule.zip";
my $ua = LWP::UserAgent->new;
my $req = new HTTP::Request 'GET', $URL;
my $res = $ua->request($req);
print ($res->status_line . "\n"); exit();
--
This space intentionally left blank
------------------------------
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 V10 Issue 286
**************************************