[24047] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6244 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 11 00:05:44 2004

Date: Wed, 10 Mar 2004 21:05:06 -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           Wed, 10 Mar 2004     Volume: 10 Number: 6244

Today's topics:
        Deleting a folder recursively <info@pcconnect.net>
    Re: Deleting a folder recursively <usenet@morrow.me.uk>
    Re: Deleting a folder recursively <info@pcconnect.net>
    Re: Deleting a folder recursively <arthur0421@163.com>
        Getting Listen directive value in a mod_perl <Perl> sec <ralph@ralphcrawford.deletethis.org>
    Re: IF statement case sensitivity <arthur0421@163.com>
    Re: perl on windows <matthew.garrish@sympatico.ca>
    Re: perl on windows <usenet@morrow.me.uk>
    Re: perl on windows <matthew.garrish@sympatico.ca>
    Re: perl on windows <kevin@vaildc.net>
    Re: perl on windows <bobx@linuxmail.org>
    Re: perl on windows <matthew.garrish@sympatico.ca>
    Re: perl on windows <matthew.garrish@sympatico.ca>
    Re: Quoting non-numbers (Anno Siegel)
    Re: Quoting non-numbers <usenet@morrow.me.uk>
    Re: Regex doesn't match - what am I doing wrong? <tadmc@augustmail.com>
    Re: Regex doesn't match - what am I doing wrong? <zoooz@gmx.de>
    Re: Regex doesn't match - what am I doing wrong? (Anno Siegel)
    Re: Syntax error <usenet@morrow.me.uk>
        Test Framework for cross platform client/server running (Charlie)
    Re: using an assoc. array as a 'set' (Anno Siegel)
    Re: using an assoc. array as a 'set' <usenet@morrow.me.uk>
    Re: variable initialization question (Anno Siegel)
    Re: variable initialization question (Jay Tilton)
        what's the easiest way to do a SQL-like query against a (valued customer)
    Re: what's the easiest way to do a SQL-like query again <dwall@fastmail.fm>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 10 Mar 2004 16:39:51 -0800
From: "Shabam" <info@pcconnect.net>
Subject: Deleting a folder recursively
Message-Id: <T5GdnQLlcYNzLtLdRVn-ug@adelphia.com>

I'm currently using the following function to delete entire directories
including all content in it.  However it often fails out on me and gives me
the message "Failed to remove foldername".  Can someone take a look at this
and tell me what I can do to stop that?  Basically I want to duplicate the
system function "rm -rf foldername" with perl.  I'm running this in the
command line btw.



sub dir_del {

my $direc = $_[0];
my (@dirs,$new_dir);

opendir(DIR,$direc);
@dirs = grep {!(/^\./) && -d "$direc/$_" } readdir(DIR);
close DIR;
@dirs = sort(@dirs);

opendir (DIR, "$direc");
@files = grep {!(/^\./) && -f "$direc/$_"}  readdir(DIR);
close (DIR);

foreach $file(@files) {
        unlink("$direc/$file") || print "Failed to remove $direc/$file";
}

for $new_dir(0..$#dirs) {
        &dir_del("$direc/$dirs[$new_dir]");
        rmdir("$direc/$dirs[$new_dir]") || print "Failed to remove
$direc/$dirs[$new_dir]";
}

}




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

Date: Thu, 11 Mar 2004 01:10:37 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Deleting a folder recursively
Message-Id: <c2oead$ktq$6@wisteria.csv.warwick.ac.uk>


Quoth "Shabam" <info@pcconnect.net>:
> I'm currently using the following function to delete entire directories
> including all content in it.  However it often fails out on me and gives me
> the message "Failed to remove foldername".  Can someone take a look at this
> and tell me what I can do to stop that?  Basically I want to duplicate the
> system function "rm -rf foldername" with perl.  I'm running this in the
> command line btw.
> 
> sub dir_del {
> 
> my $direc = $_[0];
> my (@dirs,$new_dir);
> 
> opendir(DIR,$direc);
> @dirs = grep {!(/^\./) && -d "$direc/$_" } readdir(DIR);

Why are you ignoring files beginning with a dot? If you have a directory
with a dotfile in it, the dotfile won't be deleted and then you won't be
able to rmdir the directory.

Either use File::Path or File::Find if you need to be more general.

Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos.    |
Musica truces molit animos, tristesque mentes erigit.    |   ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras.        |


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

Date: Wed, 10 Mar 2004 18:16:43 -0800
From: "Shabam" <info@pcconnect.net>
Subject: Re: Deleting a folder recursively
Message-Id: <RLqdna68j_g_V9LdRVn-uQ@adelphia.com>

> Why are you ignoring files beginning with a dot? If you have a directory
> with a dotfile in it, the dotfile won't be deleted and then you won't be
> able to rmdir the directory.
>
> Either use File::Path or File::Find if you need to be more general.

Could you provide sample code that would work better?  I'm a newbie and I
actually got that snippet off someone else's code on the newsgroups.




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

Date: Thu, 11 Mar 2004 10:42:07 +0800
From: Regent <arthur0421@163.com>
Subject: Re: Deleting a folder recursively
Message-Id: <c2ojn8$1qp4$1@mail.cn99.com>

Shabam wrote:

>>Why are you ignoring files beginning with a dot? If you have a directory
>>with a dotfile in it, the dotfile won't be deleted and then you won't be
>>able to rmdir the directory.
>>
>>Either use File::Path or File::Find if you need to be more general.
> 
> 
> Could you provide sample code that would work better?  I'm a newbie and I
> actually got that snippet off someone else's code on the newsgroups.
> 
> 
I guess the relevant RegExp is /^\.\.$/

-- 
Regent


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

Date: Wed, 10 Mar 2004 17:25:09 -0500
From: Gatekeeper <ralph@ralphcrawford.deletethis.org>
Subject: Getting Listen directive value in a mod_perl <Perl> section in httpd.conf
Message-Id: <oKydnY9nH_tqItLdRVn-ig@speakeasy.net>

I have no problem getting the Port directive value through 
Apache->server->port, but I can't seem to find a way to get the Listen 
directive's value.  It will be set as an IP address, so I need it for a 
dynamic NameVirtualHost along with some VirtualHost sections (I get the 
info for those from a database).  All of this works fine if I hard code 
the value for the NameVirtualHost value, as in...

$NameVirtualHost = q(127.0.0.1);

but that defeats the whole purpose.  Is there any way to get this 
particular configuration directive value, or the values of other 
configuration directives given prior to the <Perl> section?

Any help at all would be most appreciated.  Thanks for your time.

Stryder22204@yeehaw.com

Yahoo!



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

Date: Thu, 11 Mar 2004 10:49:06 +0800
From: Regent <arthur0421@163.com>
Subject: Re: IF statement case sensitivity
Message-Id: <c2ok4b$1rbi$1@mail.cn99.com>

Connell Gauld wrote:

> Hey,
> How do I change the following IF statement to make it case-insensitive?
> 
> if ($example eq "text"){
> .......
> }
> 
> 
You may find help in Perldoc perlre

-- 
Regent


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

Date: Wed, 10 Mar 2004 18:19:45 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: perl on windows
Message-Id: <ioN3c.34389$6y1.1105988@news20.bellglobal.com>


"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:c2nbrs$re7$1@wisteria.csv.warwick.ac.uk...
>
> Quoth "Matt Garrish" <matthew.garrish@sympatico.ca>:
> >
> > "chatiman" <chatiman@free.fr> wrote in message
> > news:404f14a0$0$312$626a14ce@news.free.fr...
> > > Hello,
> > >
> > > I'm willing to write an app for windows with perl having a GUI.
> > > So here's a few questions :
> > > - What are the supported libraries for the GUI (gtk ?, qt ?, ... ?) ?
> >
> > You could try the Tk extensions, but I wouldn't recommend it if you want
a
> > standard looking windows app.
>
> I would. As of quite some time ago it uses standard Windows widgets,
unlike say
> Gtk which doesn't.
>

If your idea of a standard Windows app is a *nix app then yes. If you want
something a little more "with the times" (i.e. along the lines of what you
would get using Visual Studio), then I wouldn't waste any time with Tk.

You must be forgetting that Windows is all about appearances. If your app
looks like it predates 3.1, most Windows users will expect that it *does*
predate 3.1... : )

And if you really want to see just how hideous it can be even at its best
(and I don't mean this as a knock against the authors of these programs, as
I assume the programs do exactly what is required of them), try running any
of these examples http://www.perltk.org/ex/index.htm on an XP box and see
how out-of-place they appear.

Matt




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

Date: Thu, 11 Mar 2004 01:01:04 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: perl on windows
Message-Id: <c2odof$ktq$4@wisteria.csv.warwick.ac.uk>


Quoth "Matt Garrish" <matthew.garrish@sympatico.ca>:
> 
[Tk on win32]
> 
> If your idea of a standard Windows app is a *nix app then yes. If you want
> something a little more "with the times" (i.e. along the lines of what you
> would get using Visual Studio), then I wouldn't waste any time with Tk.
> 
> You must be forgetting that Windows is all about appearances. If your app
> looks like it predates 3.1, most Windows users will expect that it *does*
> predate 3.1... : )

Ummm... I think I must be missing something here... In my experience, Tk
on windows has the standard win95ish look-and-feel. It doesn't look
anything like Tk on unix, which is utterly vile, and it certainly
doesn't look like 3.1 apps look under win32.

> And if you really want to see just how hideous it can be even at its best
> (and I don't mean this as a knock against the authors of these programs, as
> I assume the programs do exactly what is required of them), try running any
> of these examples http://www.perltk.org/ex/index.htm on an XP box and see
> how out-of-place they appear.

I don't know if Tk themes along with XP: I wouldn't be surprised if it
does (if I were writing it I'd use real Windows widgets) but then again
I wouldn't be surprised if it doesn't. But shirely anyone with half a
clue turns XP back to 'Windows Classic' a.k.a 'don't use so much memory
and go a bit faster and don't treat me like a three-year-old'...?

Ben

-- 
Every twenty-four hours about 34k children die from the effects of poverty.
Meanwhile, the latest estimate is that 2800 people died on 9/11, so it's like
that image, that ghastly, grey-billowing, double-barrelled fall, repeated
twelve times every day. Full of children. [Iain Banks]         ben@morrow.me.uk


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

Date: Wed, 10 Mar 2004 21:27:45 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: perl on windows
Message-Id: <z8Q3c.4054$j05.269054@news20.bellglobal.com>


"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:c2odof$ktq$4@wisteria.csv.warwick.ac.uk...
>
> Quoth "Matt Garrish" <matthew.garrish@sympatico.ca>:
> >
> >
> >
> > You must be forgetting that Windows is all about appearances. If your
app
> > looks like it predates 3.1, most Windows users will expect that it
*does*
> > predate 3.1... : )
>
> Ummm... I think I must be missing something here... In my experience, Tk
> on windows has the standard win95ish look-and-feel. It doesn't look
> anything like Tk on unix, which is utterly vile, and it certainly
> doesn't look like 3.1 apps look under win32.
>

I've never seen a Tk app with even that good a look. And switching back to
the classic view in XP does not improve the relative look-and-feel of a Perl
Tk app (but it does make me all warm and fuzzy inside). I've used Tk enough
on Windows to have gotten so sick of it that I've turned to VC++ because
there's just no winning (the simplicity of programming edge that I'd give to
Perl/Tk app over a VC++ app is dwarfed by that ugliness factor and pain of
creation).

In the end it boils down to a matter of taste, though, and you'll never
convince me I'm wrong (or me you that I'm right, I'm sure). I can only end
by saying that I can always spot a Perl/Tk app on Windows because they
always look like something off my Red Hat machine with a beige tint (and Red
Hat hasn't quite reached a 3.1 look-and-feel yet, hence my remark).

Matt




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

Date: Thu, 11 Mar 2004 03:00:48 GMT
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: perl on windows
Message-Id: <kevin-34D5CC.22004110032004@news.verizon.net>

In article <z8Q3c.4054$j05.269054@news20.bellglobal.com>,
 "Matt Garrish" <matthew.garrish@sympatico.ca> wrote:

> In the end it boils down to a matter of taste, though, and you'll never
> convince me I'm wrong (or me you that I'm right, I'm sure). I can only end
> by saying that I can always spot a Perl/Tk app on Windows because they
> always look like something off my Red Hat machine with a beige tint (and Red
> Hat hasn't quite reached a 3.1 look-and-feel yet, hence my remark).

I write a lot of internal utilities using Perl/Tk on Win2000, and most 
of the people who use them need to be told that they aren't VB apps.  Tk 
uses native scrollbars, and I pick the user's selected colors out of the 
Registry for other UI elements.  Then select the right fonts and you're 
there.
-- 
Bright eyes/burning like fire,           | Kevin Michael Vail
Bright eyes/how can you close and fail?  | kevin@vaildc.net
How can the light that shone so brightly | . . . . . . . . . .
Suddenly shine so pale?/Bright eyes      |  . . . . . . . . .


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

Date: Wed, 10 Mar 2004 22:07:32 -0500
From: Robert <bobx@linuxmail.org>
Subject: Re: perl on windows
Message-Id: <C9mdnVpkOMBpStLdRVn-hQ@adelphia.com>

chatiman wrote:
> Hello,
> 
> I'm willing to write an app for windows with perl having a GUI.
> So here's a few questions :
> - What are the supported libraries for the GUI (gtk ?, qt ?, ... ?) ?
> - Is there examples of apps writen entirely in perl ?
> - What about PerlScript for building the whole app ?
> Are the perl features limited with PerlScript ?
> - Can perl be bundled with the app or not ?
> 
> Thanks
> 
> 
> 
wxperl.sf.net  :-)


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

Date: Wed, 10 Mar 2004 23:30:37 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: perl on windows
Message-Id: <KXR3c.37483$6y1.1242162@news20.bellglobal.com>


"Kevin Michael Vail" <kevin@vaildc.net> wrote in message
news:kevin-34D5CC.22004110032004@news.verizon.net...
> In article <z8Q3c.4054$j05.269054@news20.bellglobal.com>,
>  "Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
>
> > In the end it boils down to a matter of taste, though, and you'll never
> > convince me I'm wrong (or me you that I'm right, I'm sure). I can only
end
> > by saying that I can always spot a Perl/Tk app on Windows because they
> > always look like something off my Red Hat machine with a beige tint (and
Red
> > Hat hasn't quite reached a 3.1 look-and-feel yet, hence my remark).
>
> I write a lot of internal utilities using Perl/Tk on Win2000, and most
> of the people who use them need to be told that they aren't VB apps.  Tk
> uses native scrollbars, and I pick the user's selected colors out of the
> Registry for other UI elements.  Then select the right fonts and you're
> there.
>

Not to keep this going forever, but it's the blockish look that is a
turn-off, not the colours. Plus there are other weird oddities like the
colouration around borders being off. In vc++ I spend 10% of my time on the
gui and 90% in the coding. In Perl/Tk, it's 90% gui and 10% coding. So, as
I've said in previous threads, I often write the gui part in vc++ and use
perl to do the background processing. Why not take advantage of what
something does best/easiest? (The same way I often call Omnimark scripts
from Perl to do markup language processing.)

It's done wonders for my mental health! Of course, I also have the luxury of
everyone who uses my apps already having Perl installed... : )

Matt




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

Date: Wed, 10 Mar 2004 23:39:40 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: perl on windows
Message-Id: <f4S3c.27152$hG.327279@news20.bellglobal.com>


"Kevin Michael Vail" <kevin@vaildc.net> wrote in message
news:kevin-34D5CC.22004110032004@news.verizon.net...
> In article <z8Q3c.4054$j05.269054@news20.bellglobal.com>,
>  "Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
>
> > In the end it boils down to a matter of taste, though, and you'll never
> > convince me I'm wrong (or me you that I'm right, I'm sure). I can only
end
> > by saying that I can always spot a Perl/Tk app on Windows because they
> > always look like something off my Red Hat machine with a beige tint (and
Red
> > Hat hasn't quite reached a 3.1 look-and-feel yet, hence my remark).
>
> I write a lot of internal utilities using Perl/Tk on Win2000, and most
> of the people who use them need to be told that they aren't VB apps.  Tk
> uses native scrollbars, and I pick the user's selected colors out of the
> Registry for other UI elements.  Then select the right fonts and you're
> there.
> -- 

I'd be interested in hearing if anyone has used Visual Perl and has any
comments on it.

Matt




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

Date: 10 Mar 2004 23:39:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Quoting non-numbers
Message-Id: <c2o90d$m9k$1@mamenchi.zrz.TU-Berlin.DE>

Ben Morrow  <usenet@morrow.me.uk> wrote in comp.lang.perl.misc:
> 
> Quoth "John W. Krahn" <krahnj@acm.org>:
> > Stevens wrote:
> > > 
> > > I'm trying to create a regular expression that takes a list of space
> > > delimited words and numbers and encloses every non-number within single
> > > quotes.
> > > 
> > > e.g 1967 foo 3.234 system_analyst 87834/d23434 would be returned as 1967
> > > 'foo' 3.234 'system_analyst' '87834/d23434'
> > > 
> > > I can't get the syntax right ... how could you do this?
> > 
> 
> {
>     no warnings 'numeric';
> 
> > s/(\S+)/ $1 eq $1 + 0 ? $1 : "'$1'" /eg;
> 
> }

That quotes 1.0.  Not to mention leading zeros.

I have been using the "+ 0" test in this form:

    sub is_num {
        use warnings FATAL => 'numeric';
        no warnings 'void';
        eval { shift + 0 };
        not $@;
    }

That reflects Perl's opinion about a string being a number, but it doesn't
inline easily.

Anno


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

Date: Thu, 11 Mar 2004 01:07:03 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Quoting non-numbers
Message-Id: <c2oe3n$ktq$5@wisteria.csv.warwick.ac.uk>


Quoth anno4000@lublin.zrz.tu-berlin.de (Anno Siegel):
> Ben Morrow  <usenet@morrow.me.uk> wrote in comp.lang.perl.misc:
> > 
> > Quoth "John W. Krahn" <krahnj@acm.org>:
> > >
> >
> > {
> >     no warnings 'numeric';
> > 
> > > s/(\S+)/ $1 eq $1 + 0 ? $1 : "'$1'" /eg;
> > 
> > }
> 
> That quotes 1.0.  Not to mention leading zeros.
>
> I have been using the "+ 0" test in this form:
> 
>     sub is_num {
>         use warnings FATAL => 'numeric';
>         no warnings 'void';
>         eval { shift + 0 };
>         not $@;
>     }
> 
> That reflects Perl's opinion about a string being a number, but it doesn't
> inline easily.

If you're going to do that, you might as well use
Scalar::Util::looks_like_number, which I'd imagine would be somewhat
faster.

Ben

-- 
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based 
on the strictest morality.  [Samuel Butler, paraphrased]       ben@morrow.me.uk


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

Date: Wed, 10 Mar 2004 17:14:44 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regex doesn't match - what am I doing wrong?
Message-Id: <slrnc4v8b4.2ad.tadmc@magna.augustmail.com>

Sriram <mailsb04-posts@yahoo.com> wrote:

> I am having trouble matching a regex that combines a negated character
> class and an anchor ($). Basically, I want to match all strings that
> don't end in a digit. So I tried:
> 
> bash-2.05a@bermuda:15$perl -e 'while (<STDIN>) { if (/[^0-9]$/) {
> print;}}'
> skdsklds
> skdsklds
> sklskl2 <== why does this match? it ends in a digit.


No it doesn't.

It ends with a newline character (which will match the [^0-9]). 


   /[^0-9]\n/

ought to do it.


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


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

Date: Thu, 11 Mar 2004 00:24:25 +0100
From: Amir Kadic <zoooz@gmx.de>
Subject: Re: Regex doesn't match - what am I doing wrong?
Message-Id: <c2o89b$1uhbrv$1@ID-142982.news.uni-berlin.de>

Sriram wrote:

> Hi,
> 
> Basically, I want to match all strings that
> don't end in a digit. 
> 
> bash-2.05a@bermuda:15$perl -e 'while (<STDIN>) { if (/[^0-9]$/) {

What about an empty string? 
It doesn't end in a digit, but still fails this test 
(if you chomp() the input).




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

Date: 10 Mar 2004 23:48:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regex doesn't match - what am I doing wrong?
Message-Id: <c2o9ga$m9k$2@mamenchi.zrz.TU-Berlin.DE>

Tad McClellan  <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> Sriram <mailsb04-posts@yahoo.com> wrote:
> 
> > I am having trouble matching a regex that combines a negated character
> > class and an anchor ($). Basically, I want to match all strings that
> > don't end in a digit. So I tried:

[...]

>    /[^0-9]\n/
> 
> ought to do it.

I believe,

    !/[0-9]$/

is closest to the "...don't end in a digit" specification.

Anno


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

Date: Thu, 11 Mar 2004 00:51:54 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Syntax error
Message-Id: <c2od7a$ktq$3@wisteria.csv.warwick.ac.uk>


Quoth Tore Aursand <tore@aursand.no>:
> On Wed, 10 Mar 2004 13:34:01 -0500, Marshall Dudley wrote:
> > Why won't this compile, and what can I do to make it compile?
> > 
> > $match_word =~ s/\$/\\$/g;
> 
> Try this instead:
> 
>   $match_word =~ s,\$,\\\$,;
> 
> In other words:  You have to escape the '\\$', as '$' refers to 'at the
> end of'.
> 
> Feel free to use a slash instead of the commas;  I get psycho when I see
> too many \/\/\/\/. :)

Feel even freer to use ' instead of /,:

$match_words =~ s'\$'\$'g;

Ben

-- 
  Joy and Woe are woven fine,
  A Clothing for the Soul divine       William Blake
  Under every grief and pine          'Auguries of Innocence'
  Runs a joy with silken twine.                                ben@morrow.me.uk


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

Date: 10 Mar 2004 18:29:27 -0800
From: cji_work@yahoo.com (Charlie)
Subject: Test Framework for cross platform client/server running.
Message-Id: <1dc70d61.0403101829.7dc8a02d@posting.google.com>

Hi there, 
I have created a test framework for the client/Server testing in PERL.
So far those features are implemented. If a user running the test
cases, following things happen: "1. localserver Daemon started; 2.
local Server started; 3. Client started and calls the Server; 4. local
Server is stopped; 5. localserver Daemon stopped."
Now the next thing that I want to do is to have the Server and client
running on different platforms, such as Unix to Unix, Unix to window.
And I am stucked here.

Let's say I start my test cases on my client platform, and following
are the code that I have now,
"
   ....
    # to get the remote platform that server is going to be    
    $host = ENVUTIL::getConfig("SERVER_MACHINE");
    # to get the remote port number for connection. 
    $port = ENVUTIL::getConfig("SERVER_PORT");
    
    $host = "localhost" if ($host eq "");
    $port = 9000 if ($port eq "");

   # create a tcp connection to the specified host and port
    $handle = IO::Socket::INET->new(Proto    => "tcp",
                                    PeerAddr => $host,
                                    PeerPort => $port)
    or die "connectToServer: Can't connect to port $port on $host:
$!";

    $handle->autoflush(1); #so output gets there right away
 
    executeServer();
   ....
"
It always failed when the tcp connect is to made, it gives me some
error as the port is invalid, but I have double checked, it is a valid
port number. Any ideas what else might be, or I missed something ?


Thanks for the help 


CJ


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

Date: 11 Mar 2004 00:05:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: using an assoc. array as a 'set'
Message-Id: <c2oag4$m9k$3@mamenchi.zrz.TU-Berlin.DE>

Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in comp.lang.perl.misc:
> Also sprach ixtahdoom:
> 
> > I find myself doing this quite a bit in perl:
> > 
> >   my %h;
> >  :
> >  :
> >   {   
> >     $h{$k} = 1;  # don't care about the value, only the key
> >   }
> >  :
> > 
> > 
> > Simply because I want to use an assoc. array as a set, i don't care
> > about the value, only the key.  Is there a way to do something like
> > 
> >   define $h{$k}
> > 
> > ??
> > 
> > This seems more intuitive than having to assign an unused value to a
> > key.
> 
> Here is a counter-intuitive (but working) way:
> 
>     undef $h{$k};
> 
> Or you just assign undef in one or the other way:
> 
>     $h{$k} = undef;
>     # or
>     $h{$k} = ();

The last way says it best: assign nothing to this key.  That's the idea
in this situation.

Anno


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

Date: Thu, 11 Mar 2004 00:47:18 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: using an assoc. array as a 'set'
Message-Id: <c2ocum$ktq$2@wisteria.csv.warwick.ac.uk>


Quoth anno4000@lublin.zrz.tu-berlin.de (Anno Siegel):
> Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in
> comp.lang.perl.misc:
> >
> >     $h{$k} = ();
> 
> The last way says it best: assign nothing to this key.  That's the idea
> in this situation.

The trouble with that is that you then have to test with exists() rather than
simply testing for truth...

Ben

-- 
I've seen things you people wouldn't believe: attack ships on fire off
the shoulder of Orion; I watched C-beams glitter in the dark near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die.                                                   ben@morrow.me.uk


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

Date: 11 Mar 2004 00:11:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: variable initialization question
Message-Id: <c2oase$m9k$4@mamenchi.zrz.TU-Berlin.DE>

John W. Krahn <krahnj@acm.org> wrote in comp.lang.perl.misc:
> Alexander Stremitzer wrote:
> > 
> > I found that the following statement only initializes the first variable.
> > my ($a,$b,$c) = 0;
> > A way that works is:
> > my ($a,$b,$c) = (0,0,0);
> > 
> > Is there a simpler way to initialize all variables with the same value 0 ?
> 
> my ($a,$b,$c) = (0) x 3;

  $_ = 0 for my ( $a, $b, $c);

Anno


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

Date: Thu, 11 Mar 2004 00:33:29 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: variable initialization question
Message-Id: <404fb3d6.337170996@news.erols.com>

Alexander Stremitzer <stremitz@consultant.com> wrote:

: I found that the following statement only initializes the first variable.
: my ($a,$b,$c) = 0;
: A way that works is:
: my ($a,$b,$c) = (0,0,0);
: 
: Is there a simpler way to initialize all variables with the same value 0 ?

Looks pretty simple to me.  What complexity are you hoping to
eliminate?

You could initialize a batch of scalars without caring how many are
declared.

    $_=0 for
    my( $a, $b, $c );

But another person reading your code might appreciate clarity over
cleverness.



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

Date: 10 Mar 2004 17:24:35 -0800
From: scooterm@hotmail.com (valued customer)
Subject: what's the easiest way to do a SQL-like query against a native perl data 'psuedo-table'
Message-Id: <1b347673.0403101724.53a62ff6@posting.google.com>

### PROBLEM:
    What is the fastest, easiest way to allow SQL-like queries
    against perl-centric data structures that neither originate
    from, nor are submitted to a relational database.

    In other words, is it possible to get the perl snippet
    below to produce the desired output with some minor
    (yet functionally complete) modification?

    (Note: a database is *never* involved here, and the goal
    is to avoid complicated libraries or unecessary overhead)

### EXAMPLE: suppose I have some perl code like this ...

### INIT pragma
    use strict;
    use warnings;

### INIT lib
    use Data::Dumper;

### INIT vars
    my  $sampledata = [];
    my  $query_result = [];
    my  $query_string = "";

### DO SOME STUFF
    $sampledata    =
    [
        {fname=>'fred',lname=>'flintstone'  , age=>33},
        {fname=>'wilma',lname=>'flintstone' ,age=>28},
        {fname=>'betty',lname=>'rubble'     ,age=>30},
        {fname=>'barney',lname=>'rubble'    ,age=>29},
        {fname=>'barney',lname=>'the_dinosaur'  , age=>12},
    ];

    $query_string = "
        SELECT  fname,age
        WHERE   lname eq 'flintstone'
                AND
                fname   eq 'fred'
        ";

    $query_result   = &ThisDoesNothingYet($sampledata,$query_string);

    sub ThisDoesNothingYet{ return [] }

    print Data::Dumper->Dump([$query_result], [qw(output)]);

__DATA__
### DESIRED OUTPUT
$output = [
            {
              'fname' => 'fred',
              'age' => 33
            }
          ];


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

Date: Thu, 11 Mar 2004 02:27:11 GMT
From: David Wall <dwall@fastmail.fm>
Subject: Re: what's the easiest way to do a SQL-like query against a native perl data 'psuedo-table'
Message-Id: <%7Q3c.1447$i76.26429@attbi_s03>

valued customer wrote:
> ### PROBLEM:
>     What is the fastest, easiest way to allow SQL-like queries
>     against perl-centric data structures that neither originate
>     from, nor are submitted to a relational database.
> 
>     In other words, is it possible to get the perl snippet
>     below to produce the desired output with some minor
>     (yet functionally complete) modification?
> 
>     (Note: a database is *never* involved here, and the goal
>     is to avoid complicated libraries or unecessary overhead)

Try DBI and one of DBD::SQLite, DBD::CSV, or DBD::RAM.

-- 
David Wall


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

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


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