[24309] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 6500 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 1 18:05:41 2004

Date: Sat, 1 May 2004 15:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 1 May 2004     Volume: 10 Number: 6500

Today's topics:
    Re: comparing decimal numbers <dwall@fastmail.fm>
    Re: Finding all open filehandles and closing them befor <troc@pobox.com>
        Help with forum (javatiger)
        Longest match wins - how to do it Perl way? (A. Farber)
    Re: OSs with Perl installed <trammell+usenet@hypersloth.invalid>
    Re: OSs with Perl installed <postmaster@castleamber.com>
    Re: problem with redirect in CGI ctcgag@hotmail.com
    Re: reducing a regex <uri@stemsystems.com>
        regex question ... <jhalbrook@bjc.org>
        Wanted: Perl Developer (Stephen O'Brien)
    Re: Why doesn't this work? <tadmc@augustmail.com>
    Re: Why doesn't this work? <David@Wheat.con>
    Re: Why doesn't this work? <matternc@comcast.net>
    Re: Why doesn't this work? <invalid-email@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 01 May 2004 18:46:46 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: comparing decimal numbers
Message-Id: <Xns94DC965A2D86dkwwashere@216.168.3.30>

"Jürgen Exner" <jurgenex@hotmail.com> wrote:

> David K. Wall wrote:
>> Tad McClellan <tadmc@augustmail.com> wrote:
>>
>>> Thens <thens@NOSPAMti.com> wrote:
>>>
>>>> I have to compare two decimals numbers 1.5.0 and 2.1.1.
>>>
>>>
>>> Those are not decimal numbers...
>>
>> They don't look like whole numbers, either.
> 
> "These aren't green cars. "
> "They don't look like a red cars, either."
> 
> Surprise, surprise, it's a submarine.

Just as long as it's not a flame-breathing monster screaming "substr()!"


------------------------------

Date: Sat, 01 May 2004 21:54:26 GMT
From: Rocco Caputo <troc@pobox.com>
Subject: Re: Finding all open filehandles and closing them before exiting
Message-Id: <slrnc9879b.lqj.troc@eyrie.homenet>

On 30 Apr 2004 23:19:58 -0700, Vilmos Soti wrote:
> rook_5150@yahoo.com (Bryan Castillo) writes:
>
>>>>> I have a signal handler which tries to unmount the disk in
>>>>> the case of a sigint, but it will fail if copy from File::Copy
>>>>> has an open filehandle on the mounted disk.

I use this:

  use POSIX qw(MAX_OPEN_FDS);
  POSIX::close($_) for $^F+1 .. MAX_OPEN_FDS;

It's a heavy-handed way to close every file descriptor, whether open or
not.  It won't close stdin, stdout, or stderr, however.  For that, use 0
instead of $^F+1.

-- 
Rocco Caputo - http://poe.perl.org/


------------------------------

Date: 1 May 2004 14:30:07 -0700
From: tigermott@yahoo.com (javatiger)
Subject: Help with forum
Message-Id: <962e2a34.0405011330.5d8ee55d@posting.google.com>

Iam just learning perl and need help with a forum Iam trying to put in
my website.

I have uploaded the files into cgi bin and files in html but I keep
getting error messages.

Could someone take alook and see if they can get it running. Its the
thorn folder.

My site is at www.tripod.com

my username is mickmotty

password is sunday

Cheers


------------------------------

Date: 1 May 2004 15:03:26 -0700
From: Alexander.Farber@t-online.de (A. Farber)
Subject: Longest match wins - how to do it Perl way?
Message-Id: <c9ccaf83.0405011403.77366df9@posting.google.com>

Hi, I have a simple problem, which I have solved, but 
my solution feels ugly to me. Any improvements please?

A web form contains a list of project names. And for 
some projects there are mailing lists, which I need 
to display if the matching project has been selected.

Some project names begin with the same string, like
"p1881_aq_" and "p1881". In those cases only the longest 
match should be taken. Here is how I tried to solve it:

# put the longest keys first, to make them win

my @KEYS = qw( p1881_aq_ p1881_ p1972_ p1981_ p2311_ );

my %MAIL = (p1881_aq_ => {name => 'Project Aqua',
                          mail => 'aqua@Nokia.com'},
            p1881_    => {name => 'Project Alpha',
                          mail => 'alpha@Nokia.com'},
            p1972_    => {name => 'Project Beta',
                          mail => 'beta@Nokia.com'},
            p1981_    => {name => 'Project Gamma',
                          mail => 'gamma@Nokia.com'},
            p2311_    => {name => 'Project Theta',
                          mail => 'theta@Nokia.com'},
);

 .....
    for my $p (@selected_projects) { 
        for my $k (@KEYS) { 
            if (0 == index $p, $k) {
                printf q{<A HREF="MAILTO:%s">%s</A>}, 
                    $MAIL{$k}->{mail}, $MAIL{$k}->{name};
                last;
            }
        }
    }


------------------------------

Date: Sat, 1 May 2004 20:04:52 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: OSs with Perl installed
Message-Id: <slrnc980n4.gnj.trammell+usenet@hypersloth.el-swifto.com.invalid>

On Sat, 1 May 2004 00:24:05 -0400, Matt Garrish wrote:
> To cut to the chase, though, the faster revenues drop the faster heads
> get chopped. Linux is a powerful, secure, cheap and quickly becoming
> easy-to-use OS. You do the math...

<dons tinfoil hat>

Here's the math:

  MS bankroll: 5e10 USD
  US Congress(wo)?men: 4.4e2

Which means approximately 1e8 USD per congressperson.  With a little
bakshish, they classify Linux as a copyright circumvention device,
and poof, away it goes for all time, game over.

<doffs hat>

I'm not saying I *believe* that will happen, but it's conceivable.



------------------------------

Date: Sat, 01 May 2004 16:39:01 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: OSs with Perl installed
Message-Id: <409418f7$0$190$58c7af7e@news.kabelfoon.nl>

Matt Garrish wrote:

> "John Bokma" <postmaster@castleamber.com> wrote in message
> news:40931ffc$0$198$58c7af7e@news.kabelfoon.nl...
> 
>>Matt Garrish wrote:
>>
>>>If I worked for Microsoft I would be very afraid of Linux...
>>
>>Why?
> 
> Because I can't see Windows in the workplace as anything more than a
> temporary solution to the difficulty imposed by unix on average users. The
> best of both worlds would be an easy to use system that can be extended and
> developed to meet a business's needs. Windows is not that. Linux is also not
> that, but is much closer to becoming it than Windows.

Doubt it. Both GUIs for example are getting faster bloated and more 
focussed on skinning, and other things you really can do without than XP.

> M$ can come up with
> all the "revolutionary" new layers of abstraction it wants, but what's under
> the hood is still a shambles.

Under the hood are many changes too, you can not compare Win2K, XP to 
Win95 and friends.

> To cut to the chase, though, the faster revenues drop the faster heads get
> chopped. Linux is a powerful, secure,

secure... sure. That's why there are special secure versions of 
GNU/Linux, and many people really considered about security don't use 
Linux at all.

> cheap and quickly becoming easy-to-use

An easy-to-use OS doesn't exist. If all MS users who surf as 
Administrator, and infect their machine on a daily basis get Linux, they 
will make similar mistakes. Both operating systems provide enough rope 
to hang an advanced user, imagine a novice.

> OS. You do the math...

Microsoft #1 for the coming 10 years.

-- 
John                               MexIT: http://johnbokma.com/mexit/
                            personal page:       http://johnbokma.com/
    Experienced Perl programmer available:     http://castleamber.com/


------------------------------

Date: 01 May 2004 20:39:17 GMT
From: ctcgag@hotmail.com
Subject: Re: problem with redirect in CGI
Message-Id: <20040501163917.318$0u@newsreader.com>

"Danny" <dannywork5@hotmail.com> wrote:
> WE are using the redirect command in the code below, I am trying to test.
> we are trying to post our products on the shopping sites, like
> shopping.com, froogle, nextag etc etc.

I don't understand the connection.  You want to post a URL to someone
else's site, which when followed goes to one of your sites, then redirects
to a different one of your sites?


> But when we use this url as you see below as the product_url, it gives an
> error.  But if you copy and paste it into the url it will work.  ODD.  So
> I tried to do a redirect from my cgi directory and use this cgi script as
> the product url for these sites.

What do you mean "use this cgi script as the product url"?  I can only
assume "this" cgi is the one you posted below, and that obviously is not
the product cgi.

> But it does not work.
> How can I some how make it go to my website and act as if the product_url
> is being called  from my website

That doesn't make much sense.  You build a vault, and then complain that
other people can't get into it?

> PS. the url works in some sites like froogle.
> the error comes from our product.cgi saying "cannot create session"
> I know the problem in there, but how can we make this work?

If the problem is in product.cgi, then why don't you show us product.cgi?

<snip code that apparently *does* work.>

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Sat, 01 May 2004 18:28:42 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: reducing a regex
Message-Id: <x78ygc0zol.fsf@mail.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> Uri Guttman  <uri@stemsystems.com> wrote in comp.lang.perl.misc:

  AS> my @matches =  /([\w.]+)/g;
  >> 
  AS> extracts the same fields.  If it does what you want, I don't know.
  >> 
  >> not exactly. he has some grabbed numbers with optional leading - signs
  >> and [\w+.] won't grab them.

  AS> Oh, right.  I didn't see them in the monster regex.

another reason to either not use monster regexes or to enable /x.

  >> so [\w.-]+ could work. but we both don't know the real spec so we
  >> can't be sure. i wonder if he really wants to grab all those things
  >> and if they are needed to actually match the string. me thinks the
  >> OP just thinks you have to match each part in detail.

  AS> That's the point I was hoping to make by giving a pointedly
  AS> unspecific regex.  It doesn't hurt the point much that it is a
  AS> little too unspecific.

yep.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: Sat, 1 May 2004 13:13:13 -0500
From: "JK" <jhalbrook@bjc.org>
Subject: regex question ...
Message-Id: <1097q608hqj454c@corp.supernews.com>

I'm trying to convert URLs in text strings to hyperlinks.  My script:

                          $new_string = $string;
                          chop($new_string);
                          if ((index($new_string,"http:") > -1) &&
(index($new_string,"/a>") == -1)) {
                              $str = index($new_string,"http:");
                              $end = index($new_string," ",$str);
                              if ($end == -1) {
                                  $end = length($new_string);
                              }
                              $link = substr($new_string,$str,($end -
$str));
                              $link =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
                              #$link = uri_escape($link);   ( I tried this,
but with the same results.)
                              $string =~ s/$link/<a href=\"$link\"
target=\"_blank\">$link<\/a>/ig;
                          }
                          print $string;


This works fine except when there are special characters in the URL, i.e.

http://m1e.net/c?28187522-xsleUKKDTFo.o%40511609-6aPKRw00Wbpzg

in which case, it fails.

Any ideas on how I might overcome this delimma would be greatly appreciated.

JK




------------------------------

Date: 1 May 2004 13:02:00 -0700
From: stephenob@iol.ie (Stephen O'Brien)
Subject: Wanted: Perl Developer
Message-Id: <58a37fec.0405011202.6f710c62@posting.google.com>

Hello all,

I need a perl developer for the following job:

Simple database script (flatfile csv) which stores information about
many HTML files, and contains a link to a html body doc for each
record, and a unique ID. Example database:

ID, Title, BodyTextLink, Footer
001, Home, Home.html, (c) 2004

This script can be called on (like this: script.pl?ID=001&Title=Home)
and will retrieve the data from the db and from external html file and
place it in a designated area of a html template.

The main purpose is to allow easy HTML content editing.

Willing to pay around US$150, but will require script testing first.

Email me at stephenNOobSPAM@iol.ie
(Remove NO and SPAM)


------------------------------

Date: Sat, 1 May 2004 12:20:36 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Why doesn't this work?
Message-Id: <slrnc97n34.3ci.tadmc@magna.augustmail.com>

David Grey <David@Grey.con> wrote:
> Jürgen Exner wrote:
>> David Grey wrote:

>> > $tempfile = "http://www.domain.com/temp.txt";
>> > copy($tempfile,"temp2.txt");
>>
>> It doesn't work because copy() copies files and
>> http://www.domain.com/temp.txt is not a file but a URL


> Thanks, I found this after going to a bunch of pages in google that
> were asking how to use it and finally came across the form:
> 
> # Create a user agent object
> use LWP::UserAgent;


> I don't think I would want to POST I think I would want to GET,


   use LWP::Simple;
   my $txt_file = get 'http://www.domain.com/temp.txt';


> and then it did not have any copy examples. Can someone give
> me a hint on this as well? 


   perldoc LWP::Simple


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sat, 01 May 2004 20:22:43 GMT
From: David Wheat <David@Wheat.con>
Subject: Re: Why doesn't this work?
Message-Id: <36645806.F9726B7C@Wheat.con>



Sherm Pendley wrote:

> David Grey wrote:
>
> > Thanks, I found this after going to a bunch of pages in google that
> > were asking how to use it
>
> Google is nice, but did you try looking on your own computer?
>
> perldoc LWP
> perldoc LWP::Simple
> perldoc lwpcook

I have no way to access that. It seems like the LWP is not installed
on my host. Unless these will cause a 500 error.

#!/usr/bin/perl

LWP::UserAgent;

$ua = LWP::UserAgent->new;

$ua->proxy(['http', 'ftp'], 'http://www.domain.com/');
$req = new HTTP::Request('GET' => 'http://www.domain.com/temp.txt');

--
or
--

#!/usr/bin/perl

use LWP::Simple;
$doc = get 'http://www.domain.com/temp.txt';





------------------------------

Date: Sat, 01 May 2004 17:07:44 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Why doesn't this work?
Message-Id: <9c6dnVXZROg9jAnd4p2dnA@comcast.com>

David Grey wrote:

> #!/usr/bin/perl

# always, always, ALWAYS include these in your code:
use warnings;
use strict;
> 
> use File::Copy;
> 
> $tempfile = "http://www.domain.com/temp.txt";
> copy($tempfile,"temp2.txt");
> 
Well, no.  File::Copy copies one local file to another.  It's
not going to connect to other servers for you.
> 
> How would you call a file from another server?

Depends on how I need to call it.  For HTTP, I'd use
LWP::Simple, which should have come with your perl install.
-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


------------------------------

Date: Sat, 01 May 2004 21:11:14 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Why doesn't this work?
Message-Id: <4094116A.5030205@rochester.rr.com>

David Grey wrote:

 ...
>>>#!/usr/bin/perl
>>>
>>>use File::Copy;
>>>
>>>$tempfile = "http://www.domain.com/temp.txt";
>>>copy($tempfile,"temp2.txt");
>>>
 ...


> 
> I don't think I would want to POST I think I would want to GET,
> and then it did not have any copy examples. Can someone give
> me a hint on this as well? I assume the  use File::Copy;  will not
> work as pointed out.


[code below is all one line, change shell quoting if not on Windoze]:

perl -MLWP::Simple -e "getprint 'http://bwalton.com/'">temp2.txt

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



------------------------------

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 6500
***************************************


home help back first fref pref prev next nref lref last post