[24014] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6212 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 4 06:05:40 2004

Date: Thu, 4 Mar 2004 03:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 4 Mar 2004     Volume: 10 Number: 6212

Today's topics:
    Re: Anyone got a good one-liner? <krahnj@acm.org>
    Re: Anyone got a good one-liner? (Heinrich Mislik)
    Re: Double Jump Box Redirection (Kenton)
        how to see how many open file descriptors my program ha (Rex Gustavus Adolphus)
        My PERL program slows down over time. (Marc)
    Re: My PERL program slows down over time. (Sam Holden)
    Re: My PERL program slows down over time. <tim@vegeta.ath.cx>
    Re: My PERL program slows down over time. <gnari@simnet.is>
        Need help on a sendmail contrib, qtool.pl <reply_to@newsgroup.only>
        Need help with Undeliverable Emails <nospam@myemail.com>
    Re: Need help with Undeliverable Emails (David Efflandt)
    Re: passing arrays to function <yamini_rajan@nospam.com>
    Re: passing arrays to function (Chris Marshall)
    Re: Perl & Sessions? (Malcolm Dew-Jones)
    Re: Problem open'ing a file to read utf16 (alex)
    Re: Removing accents from spanish characters <jurgenex@hotmail.com>
    Re: Removing accents from spanish characters <HelgiBriem_1@hotmail.com>
        Slow Sorting $_@_.%_
    Re: Slow Sorting <gnari@simnet.is>
        the "system" and "print" function thingy (flying lumberjack)
        This drives me crazy !!! (Foo Bar)
        using C++ from perl (Sergei Emantayev)
    Re: using C++ from perl <fifo@despammed.com>
    Re: waitpid interrupted problem <usenet@morrow.me.uk>
    Re: webservices <ceo@nospan.on.net>
    Re: webservices <hillmw@ram.lmtas.lmco.com>
    Re: webservices (Sam Holden)
    Re: webservices <gnari@simnet.is>
    Re: What with this open file descriptor/"Read on closed (Rex Gustavus Adolphus)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 03 Mar 2004 23:21:46 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Anyone got a good one-liner?
Message-Id: <40466880.CEB20512@acm.org>

"D. Alvarado" wrote:
> 
> I have a hash
> 
> %sqlUpdatePairs
> 
> whose key and value are both scalar strings.  What I would like is a
> resulting string, resembling
> 
> "COL1 = 'val1', COL2 = 'val2', COL3 = 'val3'"
> 
> assuming my hash had only 3 entries, referenced by the keys "COL1",
> "COL2", and "COL3" whose respective values were "val1", "val2", and
> "val3" (note that the values have no apostraphes).
> 
> Anyone know a one line (or at worst two line) way I can form the
> desired string out of my hash?
> 
> Much apprecation - Dave


( $string = join( "\0", %sqlUpdatePairs ) . "'" ) =~ s/\0/ $|-- ? "', " : " = '" /eg;



John
-- 
use Perl;
program
fulfillment


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

Date: 04 Mar 2004 10:06:25 GMT
From: Heinrich.Mislik@univie.ac.at (Heinrich Mislik)
Subject: Re: Anyone got a good one-liner?
Message-Id: <4046ff9c$0$17706$3b214f66@usenet.univie.ac.at>

In article <LSm1c.676406$X%5.168900@pd7tw2no>, peter@PSDT.com says...
>
>
>In article <9fe1f2ad.0403030648.4cc08057@posting.google.com>,
> laredotornado@zipmail.com (D. Alvarado) writes:
>>I have a hash
>>
>>%sqlUpdatePairs
>>
>>whose key and value are both scalar strings.  What I would like is a
>>resulting string, resembling
>>
>>"COL1 = 'val1', COL2 = 'val2', COL3 = 'val3'"
>>
>>assuming my hash had only 3 entries, referenced by the keys "COL1",
>>"COL2", and "COL3" whose respective values were "val1", "val2", and
>>"val3" (note that the values have no apostraphes).
>
>Maybe today they don't, but why take the chance?  There is a
>more efficient way of doing this, assuming you are using DBI,
>that doesn't care.
>
>>Anyone know a one line (or at worst two line) way I can form the
>>desired string out of my hash?
>
>Using said more robust way (untested):
>
>my @col_names = keys %sqlUpdatePairs;
>my $sql = "UPDATE foo SET "
>          . join("," => map "$_ = ?" => @col_names)
>          . " WHERE blah";
>my $sth = $dbh->prepare($sql);
>#...
>$sth->execute(@sqlUpdatePairs{@col_names});

This can be shorter (still untested):

my $sql = "UPDATE foo SET "
          . join("," => map "$_ = ?" => keys %sqlUpdatePairs)
          . " WHERE blah";
my $sth = $dbh->prepare($sql);
#...
$sth->execute(values %sqlUpdatePairs);

perldoc -f keys explicitly states that keys and values will use the same order.

Cheers 

Heinrich Mislik

-- 
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140



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

Date: 3 Mar 2004 17:58:23 -0800
From: kenton_mcleod@hotmail.com (Kenton)
Subject: Re: Double Jump Box Redirection
Message-Id: <f18c773b.0403031758.4a80bb8c@posting.google.com>

Sandman <mr@sandman.net> wrote in message news:<mr-B4933B.18140827022004@news.fu-berlin.de>...
> 
> All you seem to have recieved was attitude.
> 

You're not wrong ... thanks for your help Sandman, nuts to the rest of
you.

I am fully aware that what I had was JS. 
Sorry if that wasn't clear.

I also said that I'd been scared off JS which is why I wasn't posting
to a JS group.
Sorry if that wasn't clear.

I listed the JS just to show what I already had (and wanted to
replace)
Sorry if that wasn't clear.

I wanted to use a cgi script and I thought this was an appropriate
place to post.
Sorry if that wasn't clear.

Bugger it ... Javascript programmers are friendlier I'll just go and
see them and do it their way. Obviously 5/6 perl programmers are rude.


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

Date: 4 Mar 2004 01:54:34 -0800
From: uffesterner@spamhole.com (Rex Gustavus Adolphus)
Subject: how to see how many open file descriptors my program has?
Message-Id: <c70a85ff.0403040154.6ecf243@posting.google.com>

This question is about a pre-5.6-perl


I have a problem with a deamon-program I've written that after a
couple of days/weeks runs out of file descriptors.

I wonder if there is a command
to see how many open file descriptors my program has?

And is there a command
to see how many open file descriptors the system has?

I am not opening them explicitly,
I think they are being opened by
glob() and/or File::Copy::move
(the deamon is polling for certain files, and when found
moves them between NFS-mounted filesystems)

tia
/RGA


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

Date: 3 Mar 2004 23:37:28 -0800
From: bookmarc_junk@hotmail.com (Marc)
Subject: My PERL program slows down over time.
Message-Id: <a892d310.0403032337.11bc1518@posting.google.com>

I wrote a PERL program to creat thousands of files.  The program zips
along at first but then begins to slow down.

Does any one have any ideas on what might be causing this?

-M


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

Date: 4 Mar 2004 08:16:36 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: My PERL program slows down over time.
Message-Id: <slrnc4dpf4.387.sholden@flexal.cs.usyd.edu.au>

On 3 Mar 2004 23:37:28 -0800, Marc <bookmarc_junk@hotmail.com> wrote:
> I wrote a PERL program to creat thousands of files.  The program zips
> along at first but then begins to slow down.
> 
> Does any one have any ideas on what might be causing this?

Most file systems use a linear search through directory entries. Hence file
system operations (opening a file, deleting a file, creating a file, and so
on) slow down as the number of directory entries increase.

Use a file system with a better than linear data structure/algorithm or 
create subdirectories based on sum property of the filename (a hash, or
the first letter are commonly used).

-- 
Sam Holden


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

Date: 4 Mar 2004 08:25:38 GMT
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: My PERL program slows down over time.
Message-Id: <slrnc4dq24.fjs.tim@vegeta.saiyix>

Sam Holden <sholden@flexal.cs.usyd.edu.au> wrote:
>  Marc <bookmarc_junk@hotmail.com> wrote:
> > I wrote a PERL program to creat thousands of files.  The program
> > zips along at first but then begins to slow down.
> > 
> > Does any one have any ideas on what might be causing this?
>  
[ snip good points ]

Even better, post some code so we can give better answers than just
educated guesses.  Most likely you're using a poor algorithm for the
operation or just using a bad approach, but it's difficult to tell which
or where it occurs without some reference point.

Post relevant code.  It helps.  It's also good etiquette.

HTH,
Tim Hammerquist


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

Date: Thu, 4 Mar 2004 08:02:26 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: My PERL program slows down over time.
Message-Id: <c26noh$91c$1@news.simnet.is>

"Marc" <bookmarc_junk@hotmail.com> wrote in message
news:a892d310.0403032337.11bc1518@posting.google.com...
> I wrote a PERL program to creat thousands of files.  The program zips
> along at first but then begins to slow down.
>
> Does any one have any ideas on what might be causing this?

yes. you are doing at leas 3 things wrong:

a) you are createing all these files in the same directory, and your filing
system
    slows down as the number increases

b) you use a fancy method to make sure the file does not exist already.
        for my $fileno (1....10000) {
            $subnum=0;
            $subnum++ while (-f "file_$subnum");
            # create file
       }
    you have to do more and more work for each file
    if you had called your file "file_$fileno"."_$subnum" instead,
    you would not have had this problem

 c) the logic error on line 42 makes you create file number n
     n times.

gnari





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

Date: Thu, 4 Mar 2004 09:11:48 +0000 (UTC)
From: Ninou <reply_to@newsgroup.only>
Subject: Need help on a sendmail contrib, qtool.pl
Message-Id: <Xns94A2677D9248Creplytonewsgrouponly@195.25.12.38>

Hi all,

I need some help with the contrib program 'qtool'. (sun solaris 8, 
sendmail)

I'm trying to use 'qtool' with those parameters :
 ./qtool.pl -e '$msg->{message} = Deferred' /var/spool/mqueueold
/var/spool/mqueue

and it doesn't work of course, I obtain this output:


Global symbol "$msg" requires explicit package name at (eval 1) line 1.
Bareword "Deferred" not allowed while "strict subs" in use at (eval 1) 
line
2.
Bareword "Deferred" not allowed while "strict subs" in use at (eval 2) 
line
2.
Bareword "Deferred" not allowed while "strict subs" in use at (eval 3) 
line
2.
Bareword "Deferred" not allowed while "strict subs" in use at (eval 4) 
line
2.
Bareword "Deferred" not allowed while "strict subs" in use at (eval 5) 
line
2.

 .... and so on

and only this message:
Global symbol "$msg" requires explicit package name at (eval 1) line 1.
if I use:
perl qtool.pl -e '$msg->{message} = Connection timed out with'
/var/spool/mqueueold /var/spool/mqueue


Could somebody help me?

Thank you very much.
Ninou


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

Date: Thu, 4 Mar 2004 13:18:08 +1100
From: "great places to stay." <nospam@myemail.com>
Subject: Need help with Undeliverable Emails
Message-Id: <404691e4@daisy.ans.com.au>

Hi,

I do hope there is a person out there that can help.

My problem is when my perl script sends out an email using perls /sendmail
to one of my users, that have added their email address to one of my forms
the email is bounced back if it is undeliverable.

The problem I have is my ISP can't work out how to get those bounced emails
to be sent back to my email address so I am aware that an email sent by
/sendmail in perl has not been delivered.

Any help would be greatly appreciated.

Cheers
Paul




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

Date: Thu, 4 Mar 2004 04:48:53 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Need help with Undeliverable Emails
Message-Id: <slrnc4dd9l.hs9.efflandt@typhoon.xnet.com>

On Thu, 4 Mar 2004, great places to stay. <nospam@myemail.com> wrote:
> Hi,
> 
> I do hope there is a person out there that can help.
> 
> My problem is when my perl script sends out an email using perls /sendmail
> to one of my users, that have added their email address to one of my forms
> the email is bounced back if it is undeliverable.
>
> The problem I have is my ISP can't work out how to get those bounced emails
> to be sent back to my email address so I am aware that an email sent by
> /sendmail in perl has not been delivered.

It is not clear from your post if using Mail::Sendmail and whether it is
configured to use a functioning relay?  And/or are you using local
sendmail (can it successfully send/receive mail)?  Regardless, does your
script use a valid From: address that can successfully receive mail?

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/


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

Date: Wed,  3 Mar 2004 21:59:23 -0600
From: "yamini" <yamini_rajan@nospam.com>
Subject: Re: passing arrays to function
Message-Id: <d0ac7e03a63d512fe4433462afba884a@localhost.talkaboutprogramming.com>

thank u for ur kind responses
cheers!!!!!!
   yamini



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

Date: 4 Mar 2004 02:38:56 -0800
From: c_j_marshall@hotmail.com (Chris Marshall)
Subject: Re: passing arrays to function
Message-Id: <cb9c7b76.0403040238.41db1ce0@posting.google.com>

"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message 
> Or use a more suitable prototype:
> 
>     sub get (\@\@) {
> 	my ($ag, $bg) = @_;
> 	...
>     }
> 
>     # and call it without references
>     get(@a, @b);
> 
> With this prototype, perl will transform the two plain arrays and turn
> them into references.


ahhh - I didn't know you could do that. That's handy - thanks.


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

Date: 3 Mar 2004 17:36:44 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Perl & Sessions?
Message-Id: <4046882c@news.victoria.tc.ca>

Greg Klinedinst (g_klinedinst@hotmail.com) wrote:
: On Wed, 03 Mar 2004 21:07:58 +0100, Vetle Roeim <vetro@online.no>
: wrote:

: >  If you put the session id in the URL, your system may be vulnerable
: >  to session hijacking.
: >
: >  If the user goes to a page in your system (with the session id in
: >  the URL) and clicks a link to an external site, the session id will
: >  appear in the referer-header that is sent to the external site.
: >
: >  Sverre H. Husebys "Innocent Code" covers this, and much more.
: >  <URL:http://innocentcode.thathost.com/>

: The user can find out their own session ID in all cases, since in all
: cases it is data they(the client) are sending to your server. The only
: real difference is that with the URL/hidden vars way you don't need to
: worry about the client rejecting cookies. Also the URL way(GET)
: probably isn't ideal b/c the URL has a maximum length, so hidden
: vars(POST) are best IMHO. You just have to make sure that they cannot
: guess how you created the session ID, and make sure you expire session
: IDs in your DB.


Cookies are handled by the browser, so they may be easier to code.  You
set them just once, and then read them as necessary, no need to ever
accomodate them in your pages.  In particular your web site can use static
pages when ever it is convenient, and the context is not lost.

Caching can mean that old values are passed around, whereas the cookie is
always up to date.

A cookie can be changed independently of the pages (which can be good or
bad).

Personally, I have set up pages that used nothing but hidden fields, but I
don't do it anymore.  I have found that a cookie is just too much easier
to use (unless you pay me well - then I would of course) mostly because
you only ever use them when you need them, whereas a hidden field must
always be passed around somehow, which limits the techniques available for
generating pages, links, and etc.

Someone mentioned the problem of the referrer header passing information
to unrelated sites, and therefore links should not contain session ids. I
just thought I would reiterate that, because if you know someones session
id it can be trivial to play in their session.

As for user's turning cookies off, this is no different than (for example)  
selling an item with a picture and trying to accomodate a person with a
text browser - at some point you just have to say "sorry", you need a
certain base level to access all the features of this site.  Same with
Javascript.  I understand the reluctance of some people to turn it on, but
at some point the user needs to decide if they want to interact with you,
kind of like deciding whether they will bite the bullet and key in their
credit card number - at some point they must do what _you_ want if they
want to interact with your system.



--
Web Work Wanted, Perl Projects Programmed, Database Development Done.

I'm looking for telecommute projects. (Paying that is, various
arrangements possible.)


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

Date: 4 Mar 2004 01:09:35 -0800
From: alex522@mailinator.com (alex)
Subject: Re: Problem open'ing a file to read utf16
Message-Id: <90030f0e.0403040109.7f81b50e@posting.google.com>

Ben Morrow <usenet@morrow.me.uk> wrote in message news:<c24u6o$jeo$1@wisteria.csv.warwick.ac.uk>...
> alex522@mailinator.com (alex) wrote:
> > I have a (little endian) UTF-16 unicode file which i want 
> > to read. I use code looking like:
> > 
> >   open(F, "<:encoding(utf16)", $file)
> >     or die "can't open $file: $!\n";
> >   while (<F>) {
> >     print;
> >   }
> > 
> > This works fine for the first few lines of the file,
> > before it throws an exception:
> > 
> > UTF-16:Unrecognised BOM 2400
> > 
> > What appears to be happening is that chunks of 1024 bytes
> > are being passed to Encode::Unicode::decode to break into
> > characters, and that on the second chunk there isn't (of
> > course!) a BOM and so it throws an exception.
> 
> Hmmmm.... try ':encoding(utf16le)': you'll have to strip the BOM
> yourself.
> 
> Ben

Thanks. This works as i had hoped.

One question remains - what is the point of the plain 'utf16'
encoding when opening files if it expects a BOM at the start
of every chunk. Surely it should remember the endiannes from
the initial BOM. Feels like a bug to me.


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

Date: Thu, 04 Mar 2004 04:54:39 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Removing accents from spanish characters
Message-Id: <jEy1c.36526$6K.21997@nwrddc02.gnilink.net>

Gunnar Hjalmarsson wrote:
> Duke of Hazard wrote:
>> Gunnar Hjalmarsson wrote:
>>> Duke of Hazard wrote:
>>>> If a user types in a spanish word with accents on some
>>>> characters (e.g. ~ on top of a), how can i remove just the
>>>> accents and keep the word?
>>>
>>> Why would you like to do that?
>>
>> I have a searchable database of cities that is used by people from
>> all over the world. So some people may type Sao Paulo with or
>> without the accent and I want my search function to treat both
>> queries the same.
>
> I see. Think I have seen a module that does that, but I'm not able to
> find it now. Suppose the approach that Helgi suggested is sufficient.

Maybe String::Approx is a better approach?

jue




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

Date: Thu, 04 Mar 2004 10:46:12 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: Removing accents from spanish characters
Message-Id: <fs1e409j1bq4asroeu73duj2v95urtqkt7@4ax.com>

On Wed, 3 Mar 2004 21:08:26 -0000, "gnari" <gnari@simnet.is> wrote:
>what's the deal with the return within the loop?
>you realize this will just return the first argument (fixed),
>so the loop has no real purpose, other than a fancy way
>to do $_=$_[0]

No, gnari, you are wrong.  It will return the substituted text.

Try this with and without the return.  You can feed
the subroutine either and array or a scalar.  It will
work with either.

#!perl
use warnings;
use strict;

my $text = 'Þjóðlegir þýskir ferðamenn líða ekki fúlar fréttir';
print "$text\n";
$text = fix_Icelandic_letters($text);
print "$text\n";

sub fix_Icelandic_letters
{
for (@_) 
	{ 
	tr/ÁÐÉÍÓÚÝÖáðéíóúýö/ADEIOUYOadeiouyo/; 
	s/Þ/Th/; 
	s/Æ/Ae/; 
	s/þ/th/; 
	s/æ/ae/;
	return $_;	
}
}



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

Date: Thu, 04 Mar 2004 04:07:39 GMT
From: $_@_.%_
Subject: Slow Sorting
Message-Id: <fYx1c.7677$YN5.4930@nwrdny03.gnilink.net>


This sort runs pretty slowly, any hints on how to speed this up?

foreach my $k (sort {$file{$b}[$col] cmp $file{$a}[$col]}
                     keys %file)

%file is a 'HoA', there are usually around 500 keys.
Each {key} has an anonymous [array] with 8 items.
The item data is mixed.. numbers, punctuation, letters.

Also is there a way the 'each' function could be used
to save memory?

Any help would just great.  Thanks.




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

Date: Thu, 4 Mar 2004 07:52:05 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Slow Sorting
Message-Id: <c26n55$8rt$1@news.simnet.is>

<$_@_.%_> wrote in message news:fYx1c.7677$YN5.4930@nwrdny03.gnilink.net...
>
> This sort runs pretty slowly, any hints on how to speed this up?
>
> foreach my $k (sort {$file{$b}[$col] cmp $file{$a}[$col]}
>                      keys %file)
>
> %file is a 'HoA', there are usually around 500 keys.
> Each {key} has an anonymous [array] with 8 items.
> The item data is mixed.. numbers, punctuation, letters.

you probably are doing something wrong
this should not take a long time

gnari






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

Date: 4 Mar 2004 01:55:45 -0800
From: aflyr3@hotmail.com (flying lumberjack)
Subject: the "system" and "print" function thingy
Message-Id: <dd90154a.0403040155.47e8ef0b@posting.google.com>

I am currently trying to learn PERL and have a very limited programing
background (QBASIC). So to do this i decided to have a bit of a mess
around with an example of a very basic telnet script from "Erik
Olson's Programming with Perl Modules". With the print function it
allows you to display the text you want to display on the clients
screen. Can you display the results from the "system" function on both
the server and the client, as i can only get it to display the results
on the server screen.

Here is the script (i did't write this):
    use IO::Select;
    
    # Create a socket to listen on.
    #
    my $listener = 
      IO::Socket::INET->new( LocalPort => 8008, Listen => 5, Reuse =>
1 );
    
    die "Can't create socket for listening: $!" unless $listener;
    print "Listening for connections on port 8008\n";
    
    my $readable = IO::Select->new;     # Create a new IO::Select
object
    $readable->add($listener);          # Add the listener to it
    
    while(1) {
    
        # Get a list of sockets that are ready to talk to us.
        #
        my ($ready) = IO::Select->select($readable, undef, undef,
undef);
        foreach my $s (@$ready) {
            
            # Is it a new connection?
            #
            if($s == $listener) {
            
                # Accept the connection and add it to our readable
list.
                #
                my $new_sock = $listener->accept;
                $readable->add($new_sock) if $new_sock;
                
                print $new_sock "Welcome!\r\n";
                
            } else {  # It's an established connection
            
                my $buf = <$s>;   # Try to read a line
                
                # Was there anyone on the other end?
                #
                if( defined $buf ) {
                    
                    # If they said goodbye, close the socket. If not,
                    # echo what they said to us.
                    #
                  if ($buf =~ /goodbye/i) {
                        print $s "See you later!\n";
                        $readable->remove($s);
                        $s->close;
   
   
                    } else {
                        system ("$buf\n");
                    }
                    
                } else { # The client disconnected.
                
                    $readable->remove($s);
                    $s->close;
                    print STDERR "Client Connection closed\n";
                    
                }
            }
        }
    }


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

Date: 4 Mar 2004 02:12:54 -0800
From: mike_constant@yahoo.com (Foo Bar)
Subject: This drives me crazy !!!
Message-Id: <47904420.0403040212.1f997898@posting.google.com>

Singleton.pm:
=============
package Singleton;
my $instance = undef;
sub new
{
  if (!defined $instance) {
    $instance->{count} = 0;
    bless($instance, 'Singleton');
  }
  return $instance;
}
1;

Obj.pm:
=======
package Obj;
use Singleton;
@Obj::ISA = qw(Singleton);
sub count {
  my $self = shift;
  return $self->{count}++;
}
1;

test.pl:
========
#!/usr/bin/perl -w
use Obj;
my $obj = new Obj;
print $obj->count, "\n";

Friggin' error:
===============
Can't locate object method "count" via package "Singleton" at test.pl line 60.

Even I tried to throw in Singleton as follow and it didn't help:
BEGIN
{ 
   use Exporter ();
   @Singleton::ISA = qw(Exporter);
}

Dang...I'm too tired to figure out what goes wrong!!!!


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

Date: 4 Mar 2004 01:10:47 -0800
From: sergeem@yahoo.com (Sergei Emantayev)
Subject: using C++ from perl
Message-Id: <6b1ff979.0403040110.51150fce@posting.google.com>

Hello, dear all!
My question is about using C++ classes from Perl.
Is it possible to create and manage c++ objects in perl?
Is there any helper libraries like boost.python?


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

Date: Thu, 04 Mar 2004 09:20:34 +0000
From: fifo <fifo@despammed.com>
Subject: Re: using C++ from perl
Message-Id: <20040304092033.GC5711@fleece>

At 2004-03-04 01:10 -0800, Sergei Emantayev wrote:
> Is it possible to create and manage c++ objects in perl?
> Is there any helper libraries like boost.python?

SWIG


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

Date: Wed, 3 Mar 2004 23:17:05 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: waitpid interrupted problem
Message-Id: <c25p1h$9gd$1@wisteria.csv.warwick.ac.uk>


Jason Godfrey <jg2002@aptsolutions.com> wrote:
> 
> No, with your script I don't see the behaivour either. However, with a slight
> modification I can see it:
> 
> strace perl -le'sub sigAlarm{ $i++; }
>     $SIG{'ALRM'} = 'sigAlarm';
>     $x = fork; defined $x or die "fork: $!";
>     $x or do { sleep 5; exit 1};
>     $y = fork; defined $y or die "fork: $!";
>     $y or do { sleep 6; exit 1};
>     alarm 2;
>     print waitpid $y, 0;
>     print waitpid $x, 0;'
> 
> Output:
>   2008
>   -1
> 
> Strace:
> rt_sigaction(SIGALRM, {0x20000000006ddce0, [], 0}, {SIG_DFL}, 8) = 0
> clone2(child_stack=0, stack_size=0,
> flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD,
> child_tidptr=0x200000000002ede0) = 2008
> clone2(child_stack=0, stack_size=0,
> flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD,
> child_tidptr=0x200000000002ede0) = 2009
> setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={2, 0}}, {it_interval={0, 0},
> it_value={0, 0}}) = 0
> wait4(2009, 0x60000fffffff9510, 0, NULL) = ? ERESTARTSYS (To be restarted)
> --- SIGALRM (Alarm clock) @ 20000000003dcdf1 (0) ---
> rt_sigreturn()                          = ? (mask now [])
> wait4(-1, [WIFEXITED(s) && WEXITSTATUS(s) == 1], 0, NULL) = 2008
> write(1, "2008\n", )                   = 5
> wait4(2008, 0x60000fffffff9510, 0, NULL) = -1 ECHILD (No child processes)
> write(1, "-1\n", 3)                     = 3

Interesting... I don't get the error with that, either; but my strace
looks somewhat different from yours:

rt_sigaction(SIGALRM, {0x4002ffc0, [], SA_RESTORER, 0x40109218},
{SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [RTMIN], NULL, 8) = 0
fork()                                  = 23540
fork()                                  = 23541
alarm(2)                                = 0
wait4(23541, 0xbffff3a8, 0, NULL)       = ? ERESTARTSYS (To be restarted)
--- SIGALRM (Alarm clock) @ 0 (0) ---
sigreturn()                             = ? (mask now [RTMIN])
rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 8) = 0
wait4(23541, 0xbffff3a8, 0, NULL)       = ? ERESTARTSYS (To be restarted)
--- SIGCHLD (Child exited) @ 0 (0) ---
wait4(23541, [WIFEXITED(s) && WEXITSTATUS(s) == 1], 0, NULL) = 23541
--- SIGCHLD (Child exited) @ 0 (0) ---
brk(0)                                  = 0x817c000
brk(0x817d000)                          = 0x817d000
write(1, "23541\n", 623541)             = 6
wait4(23540, [WIFEXITED(s) && WEXITSTATUS(s) == 1], 0, NULL) = 23540
write(1, "23540\n", 623540)             = 6

notably, mine uses fork(2) instead of clone2(2) and alarm(2) instead of
setitimer(2). What are your linux/glibc/perl versions? I have

linux 2.4.20-xfs_pre6 (with Gentoo patches)
glibc 2.3.2
    linuxthreads-0.10
perl 5.8.2 for i686-linux-thread-multi
    with mostly defaults taken for Configure (in particular, perl
    *doesn't* use vfork)
    
Ben

-- 
And if you wanna make sense / Whatcha looking at me for?          (Fiona Apple)
                            * ben@morrow.me.uk *


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

Date: Wed, 03 Mar 2004 23:41:48 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: webservices
Message-Id: <03u1c.20911$3A5.9001@newssvr31.news.prodigy.com>

Michael Hill wrote:
>>Try Googling for terms like "Perl SOAP" or "Perl XML RPC" and see what
>>you come up with.
>>
>>chris
>>-----
> 
> Thank you very much .... I can't ask any more specific questions yet
> because I don't know enough ..... but in a bit I'll be smarter to ask
> better questions.
> 
> Mike

Just so you know...  I wasn't trying to climb you as much as to say "web 
services" is just too generic to answer...  It can be a rough crowd in 
here sometimes, but that wasn't my intention... 8-)

chris
-----
chris olive
chris -at- --spammer-speed-bump-- technologEase -dot- com
http://www.technologEase.com
(pronounced "technologies")


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

Date: Wed, 03 Mar 2004 17:57:17 -0600
From: Michael Hill <hillmw@ram.lmtas.lmco.com>
To: gnari <gnari@simnet.is>
Subject: Re: webservices
Message-Id: <404670DD.9D60EF45@ram.lmtas.lmco.com>

ok i cleaned it up a bit. The error I am getting is:

End tag mismatch (BODY != P) [Ln: 12, Col: 6]

**************************************************
use strict;

# Create a user agent object
use LWP::UserAgent;
use XML::Simple;

#define the user agent
my $ua = new LWP::UserAgent();

my $request = new
HTTP::Request('GET','http://someplace.com/cgi-bin/script.pl'); 
#script.pl produces an xml structure from mysql like:
#<file>
#	<stuff>mystuff</stuff>
#</file>

my $result = $ua->request($request);

my $xs = XML::Simple->new();

my $stuff = $xs->XMLin( $result->content );

print $stuff;


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

Date: 4 Mar 2004 00:53:23 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: webservices
Message-Id: <slrnc4cvg3.sum.sholden@flexal.cs.usyd.edu.au>

On Wed, 03 Mar 2004 17:57:17 -0600,
	Michael Hill <hillmw@ram.lmtas.lmco.com> wrote:
> ok i cleaned it up a bit. The error I am getting is:
> 
> End tag mismatch (BODY != P) [Ln: 12, Col: 6]

Which clearly states that the XML isn't valid XML, due to incorrect
tag nesting/closing.

> 
> **************************************************
> use strict;
> 
> # Create a user agent object
> use LWP::UserAgent;
> use XML::Simple;
> 
> #define the user agent
> my $ua = new LWP::UserAgent();
> 
> my $request = new
> HTTP::Request('GET','http://someplace.com/cgi-bin/script.pl'); 
> #script.pl produces an xml structure from mysql like:
> #<file>
> #	<stuff>mystuff</stuff>
> #</file>

The error message indicates that <body> and <p> tags are involved which
is different then what you clam here.

> 
> my $result = $ua->request($request);
> 
> my $xs = XML::Simple->new();
> 
> my $stuff = $xs->XMLin( $result->content );

print $result->content and see why the XML is incorrect. 

The GGI script probably isn't returning what you think it should.

-- 
Sam Holden


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

Date: Thu, 4 Mar 2004 07:32:43 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: webservices
Message-Id: <c26m0q$8p6$1@news.simnet.is>

"Michael Hill" <hillmw@ram.lmtas.lmco.com> wrote in message
news:404670DD.9D60EF45@ram.lmtas.lmco.com...
> ok i cleaned it up a bit. The error I am getting is:
>
> End tag mismatch (BODY != P) [Ln: 12, Col: 6]

are you sure you fed XML to XMLin() ?

> ...
> my $request = new
> HTTP::Request('GET','http://someplace.com/cgi-bin/script.pl');
> #script.pl produces an xml structure from mysql like:
> #<file>
> # <stuff>mystuff</stuff>
> #</file>

does not particularly match the error above

>
> my $result = $ua->request($request);
>  ...
> my $stuff = $xs->XMLin( $result->content );

you should test if request() succeeded, and possibly do
a basic test to see if you got what you expected

    if ($result->is_success) {
        my $content = $result->content;
        die "ooops: wierd result [$content] unless
             $content=~/^<file>.*<\/file>/s;
        my $stuff = $xs->XMLin( $content );
        ..
    } else {
        ...
    }

gnari






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

Date: 4 Mar 2004 01:44:43 -0800
From: uffesterner@spamhole.com (Rex Gustavus Adolphus)
Subject: Re: What with this open file descriptor/"Read on closed filehandle " stuff?
Message-Id: <c70a85ff.0403040144.37123d5d@posting.google.com>

Thanks for your valuable input, Ben!
I appreciate it!
A few follow-up-questions and comments below:

Ben Morrow <usenet@morrow.me.uk> wrote in message news:<c14sju$c84$1@wisteria.csv.warwick.ac.uk>...
> uffesterner@spamhole.com (Rex Gustavus Adolphus) wrote:
> >
> > sub check_for_file {
> > my ($dbh, $filename,$wait_after_last_write, $msglevel) = @_;
> >         my ($file);
> >         my @files;
> >         my $age_in_seconds;
> 
> You don't really need to declare these up here: it's better to keep
> variables in as small a scope as possible, and simply declare them the
> first time you use them.

I guess this is mostly a matter of personal taste (TMTOWTDI), or is
there any special reason your way is better?

> 
> >         &printlog($msglevel,3,"looking for $filename");
> 
> Don't call subs with & unless you need to (here you don't).

Isn't this another case of TMTOWTDI?


<snip>

> > In other parts of the program I am renaming or moving the found file
> > with this code:
>  ...
> >     if ( (rename $file => $target ) or move($file,$target) ) {
> 
> There's no need to do that (I take it move() comes from File::Copy?) as
> it will use rename if it can.
> 

Yes, of course, I'll change that!


> > I'm not at that site now, but it's an older perl, 5.005, I think,
> > running on Solaris, (sorry for being so vague).
> > 
>  <snip>
> > I didn't think my code opened any file descriptors at all.
> > 
> > So finally my questions:
> > Does glob open file descriptors for the found files?
> 
> On older perls (pre-5.6), glob is performed by forking a csh(1). This is
> a Bad Thing, so it was replaced with File::Glob in 5.6.

But even if it is performed that way, why is the program running out
of file descriptors eventually?
Seems to me like a bug in the pre-5.6-glob() or File::Copy::move then.
If glob() or File::Copy::move opens filedescriptors they should close
them to, or??

> 
> > Does rename or File::move open file descriptors?
>                       ^^ Copy::, almost certainly 
> rename: no.
> File::Copy::move: it depends on whether it could be done with rename or
> if the file had to be copied then deleted.
> 
> > Would using File::glob solve the issue?
>                     ^ G
> Yes.

But File::Glob isn't available right now (pre-5.6 perl as it is),
so I figure I could do it this way:

I forgot to mention it in my first post, but more often than not
there's
actually no need to glob() at all since $filename seldom contains
wildcards.

I change this code 
        @files = glob($filename);
to this:
        $_ = $filename;
        # check for existence of ? and/or * 
        if ( m/.*[\?|\*].*/ ) {
            @files = glob($filename);
        } else {
            push(@files,$filename);
        }

It's not a perfect solution, but will at least make the number of
glob()-call much less.
I guess it won't help much if the real problem is the
File::Copy::move-call
> 
> Ben

/RGA


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

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


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