[25622] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7864 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 7 18:05:52 2005

Date: Mon, 7 Mar 2005 15:05:21 -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           Mon, 7 Mar 2005     Volume: 10 Number: 7864

Today's topics:
    Re: another problem with look-around <abigail@abigail.nl>
        Categories of Perl questions <darkon.tdo@gmail.com>
    Re: comparing two numbers <usaims@yahoo.com>
    Re: convert gb18030 to utf16 <william@wilbur.25thandClement.com>
        Dreamweaver (or some such) and HTML::Template? newsbot@cox.net
    Re: Dreamweaver (or some such) and HTML::Template? <ebohlman@omsdev.com>
    Re: Dreamweaver (or some such) and HTML::Template? <pilkowsk@informatik.uni-marburg.de>
        environment inheritance <abc@invalid.com>
        HTML::Mason (Terry)
    Re: HTML::Mason <emschwar@pobox.com>
    Re: IO::Scalar insanity <ebohlman@omsdev.com>
        Net::Google error handling s_p_a_m_mob@hotmail.com
    Re: Net::Google error handling s_p_a_m_mob@hotmail.com
        pp syntax issue? <noeldamonmiller@gmail.com>
        shmem & complex data? <dkoleary@olearycomputers.com>
    Re: shmem & complex data? <emschwar@pobox.com>
    Re: TCP/UDP Question <jgibson@mail.arc.nasa.gov>
        use a hash from a module within a main program without  <semura@gmx.de>
    Re: use a hash from a module within a main program with <jl_post@hotmail.com>
    Re: use a hash from a module within a main program with xhoster@gmail.com
    Re: use a hash from a module within a main program with <emschwar@pobox.com>
        Win32::OLE - Excelo files hidden after SaveAs <woland99@yahoo.com>
    Re: Win32::OLE - Excelo files hidden after SaveAs <lawshouse.public@btconnect.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 07 Mar 2005 22:27:08 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: another problem with look-around
Message-Id: <slrnd2pl9s.v9v.abigail@alexandra.abigail.nl>

Charles DeRykus (ced@bcstec.ca.boeing.com) wrote on MMMMCCVI September
MCMXCIII in <URL:news:ICz3sp.E3H@news.boeing.com>:
##  In article <1110052073.746293.186530@g14g2000cwa.googlegroups.com>,
##  <eric.hall@gmail.com> wrote:
## >Sorry for the newbie questions
## >
## >I need a one-line regexp that only return a match if the test string
## >only exists once in the input. For example, find 'abc' if no other
## >occurrences of 'abc' exist anywhere in the input string of 'abc abc
## >abc'. This should be simple, but I'm having a lot of trouble with
## >limiting the scope.

Yes, that's pretty simle.

## >/(?!(abc)).*abc.*/ doesn't work, because that traps the last instance
## >(which is not followed by anything). /.*abc.*(?<!(abc))/ has the same
## >problem in reverse. Adding them together for
## >/(?!(abc)).*abc.*(?<!(abc))/ traps 'bc abc ab' in the middle, which is
## >not what I want (I need to return a match only if it exists in
## >isolation).

But now I'm confused. 'bc abc ab' contains 'abc' exactly once, so why
shouldn't it match?

Anyway, the "stock" regex for matching strings that contain exactly 
'abc' exactly once is:

    /^(?:(?!abc).)*abc(?:(?!abc).)*$/

However, that's quite slow. It can be made faster by doing some loop
unrolling:

    /^[^a]*(?:a(?!bc)[^a]*)*abc[^a]*(?:a(?!bc)[^a]*)*$/

But I'm not sure whether you want to match strings not containing 'abc',
or something else.

Also, neither regexp works very well on large strings. If I match it
against the string:

    ("a" x $N) . "abc"

the first regexp gives (with perl 5.8.6) a segfault if $N > 4156.
The second regex allows $N to be 8313. Older versions of Perl allow
for much larger strings. 5.000 for instances allows $N to be 32755
for the former regexp, or 43675 for the latter.

Now, the numbers will vary from system to system, since they are related
to once limits. But the ratios should be about the same on different
systems.

## >This gets even harder if the input has lots of other noise in the
## >input. For example, 'abc def abc def abc'. Suffice it to say that my
## >input has lots of junk, including non-word characters.
## >
## >I thought that something like this would be a fairly stock regexp but I
## >haven't been able to locate anything in google that seems relevant.
## >
##  
##  Can't you simply use:
##  
##      $count++ while $input =~ /$test_string/g;
##      print $count==1 ? "once" : "nope";
##  
##  Or, is this strictly a one-liner...  If so, I suspect the
##  one-liner will be slower.


But that doesn't interpolate inside a larger regexp.



Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


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

Date: Mon, 07 Mar 2005 16:15:34 -0000
From: "David K. Wall" <darkon.tdo@gmail.com>
Subject: Categories of Perl questions
Message-Id: <Xns96127289B9ADCdkwwashere@216.168.3.30>

While cleaning up the hard drive and deleting old files, I found one 
I created some time ago as a casual attempt to categorize the kinds 
of questions asked in comp.lang.perl.misc.  In the hope that some 
here might find it interesting, here's what I came up with:



Some ad-hoc categories of Perl questions

OP should not be programming (earthquake guy)
Not Perl-related (CGI, "You folks are rude")
No code or too much code ("Write my program for me")
Code is hopeless
OP isn't familiar with standard idioms and is unwilling to learn
self-answering question ("How do I find the length of a string?")
FAQ/RTFM ("Does \s in a regex mean whitespace?")
strictures and warnings would have found the error
use a module
OP isn't familiar with standard idioms but is willing to learn
can get a solution with a little thought or experimenting
solution would take some time and effort, but is conceptually easy
solution would take some time and effort, conceptually difficult
some ideas for solution, but reluctant to offer possibly 
    erroneous advice
not familiar with problem area
no clue how to help



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

Date: 7 Mar 2005 07:52:31 -0800
From: "usaims" <usaims@yahoo.com>
Subject: Re: comparing two numbers
Message-Id: <1110210751.395504.244060@z14g2000cwz.googlegroups.com>


A. Sinan Unur wrote:
> "usaims" <usaims@yahoo.com> wrote in news:1109968646.156295.113790
> @o13g2000cwo.googlegroups.com:
>
> > Hi, I'm new to Perl and I have limited programming skills. I'm
trying
> > to see if numbers in a list are not identical, for example:
> >
> > 1207553365
> > 1207553365
> > 1207553365
> > 1207553365
> > 1207553365
> > 1207553365
> > 1207553365
> > 1207553366
> >
> > Noticed that the last one is different, I want perl to tell me
that. A
> > little kick in the butt would be greatly appreciated. Thanks in
> > advance.
>
> Then you need to specify the problem a little better. For example,
given
> the input below, what output would you like your program to produce?

I would like the program to tell me which number is different. Each
number represents a unique number to a physical server.

>
> Please do read the posting guidelines to find out how you can help
others
> help you.
>
> You will need to better describe what you are trying to do and make
an
> effort yourself if you are to get the maximum possible help here.

Basically, the numbers that I produced below where parsed from a log
file.

EXAMPLE:
<Endpoint ep='10.50.19.77:9876'>
<SoapVersion>1207553365</SoapVersion>
 <Status>ok</Status>
</Endpoint>
</Control>
<Control>
<Endpoint ep='10.15.19.78:9876'>
<SoapVersion>1207553365</SoapVersion>
 <Status>ok</Status>
</Endpoint>
</Control>
<Control>
<Endpoint ep='10.15.19.79:9876'>
<SoapVersion>1207553365</SoapVersion>
 <Status>ok</Status>
</Endpoint>

This is the code I used to parse it:

my $start_tag = '<SoapVersion>';
my $end_tag   = '</SoapVersion>';

open(FILE, '/tmp/test.whatever') || die "can't open the file: $!";
my $line = <FILE>;
while(defined ( $line = <FILE> ) ) {

if ( $line =~ m/$start_tag(.+?)$end_tag/g )


99% of the time all these numbers are identical, when one is different
from the other, I want Perl to tell me that.
>
> Here is something that might do what you are after. Please study it
(not
> as a great example of programming) to try and understand in what ways
it
> meets your specs, and in what ways it doesn't, and then formulate
your
> next attempt based on that new understanding.

I'm in the process of studying your example, thank you.
>
> #! /usr/bin/perl
>
> use strict;
> use warnings;
>
> if(defined(my $prev = <DATA>)) {
>     chomp($prev);
>     while(defined(my $curr = <DATA>)) {
>         chomp $curr;
Can you explain to me what 'last unless length $curr' ????

>         last unless length $curr;
>         unless($curr == $prev) {
>             print "$.: $curr not equal to $prev\n";
>             $prev = $curr;
>         }
>     }
> }
>
> __END__
> 1207553365
> 1207553365
> 1207553365
> 1207553365
> 1207553365
> 1207553365
> 1207553365
> 1207553366
> 1207553365
> 
> Sinan

I want to learn from you guys, thanks in advance.



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

Date: Mon, 7 Mar 2005 10:14:32 -0800
From: William Ahern <william@wilbur.25thandClement.com>
Subject: Re: convert gb18030 to utf16
Message-Id: <89iuf2-rvc.ln1@wilbur.25thandClement.com>

Xah Lee <xah@xahlee.org> wrote:
> Can you tell me when did this module became part of Perl? (what
> version)
>
> (i haven't been active in Perl since 2004)
>
> Thanks.

I don't know. I've only recently been concerned with language/script
encoding in Perl so I'm almost as new as you are in this area.



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

Date: 7 Mar 2005 08:38:26 -0800
From: newsbot@cox.net
Subject: Dreamweaver (or some such) and HTML::Template?
Message-Id: <1110213506.344130.244510@l41g2000cwc.googlegroups.com>

I'm a long-time user of HTML::Template for creating large and small
sites alike.  But since my graphic design and layout skills extend only
to intermediate at best and I need to create some fairly nice HTML
layouts, I've considered using Dreamweaver (or some such) to create my
overall look and feel, then place my HTML::Template tags accordingly in
the resulting HTML.

I'm looking for something on the order of Dreamweaver that will ignore
-- as in line with the design goal of the HTML::Template module writer
-- HTML::Template "tags".  Can anyone recommend or provide their
experience with something like this?

I realize my question is NOT specifically "Perl" related per se, but I
need this audience since none or very precious few outside of it are
going to have ANY idea what HTML::Template is for Perl.  Template
Toolkit would also be an option, though I am much more familiar (and
content) with the simplicty and approach of HTML::Template.

Thanks,
-ceo



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

Date: 7 Mar 2005 18:17:07 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Dreamweaver (or some such) and HTML::Template?
Message-Id: <Xns96127E1BDBCB6ebohlmanomsdevcom@130.133.1.4>

newsbot@cox.net wrote in news:1110213506.344130.244510
@l41g2000cwc.googlegroups.com:

> I'm a long-time user of HTML::Template for creating large and small
> sites alike.  But since my graphic design and layout skills extend only
> to intermediate at best and I need to create some fairly nice HTML
> layouts, I've considered using Dreamweaver (or some such) to create my
> overall look and feel, then place my HTML::Template tags accordingly in
> the resulting HTML.
> 
> I'm looking for something on the order of Dreamweaver that will ignore
> -- as in line with the design goal of the HTML::Template module writer
> -- HTML::Template "tags".  Can anyone recommend or provide their
> experience with something like this?

HTML::Template allows you to embed its special tags in HTML comments, 
which any decent editor will leave alone (see "Notes" in the 
documentation).

However, I'd suggest that you learn to use CSS for your layouts rather 
than a "WYSIWYG" tool.  You're already separating your document structure 
from your code by using templates; the next logical step is to separate 
your layout/styling from your document structure using stylesheets.  The 
less intertwingling, the easier the whole thing is to maintain.




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

Date: Mon, 7 Mar 2005 19:20:16 +0100
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: Dreamweaver (or some such) and HTML::Template?
Message-Id: <MPG.1c96b9cb52bcb25a9898bd@news.individual.de>

newsbot@cox.net wrote:
> 
> I'm looking for something on the order of Dreamweaver that will ignore
> -- as in line with the design goal of the HTML::Template module writer
> -- HTML::Template "tags".  Can anyone recommend or provide their
> experience with something like this?

You can write your HTML::Template-tags like

    <tmpl_var name="param">

also as HTML comment

    <!-- tmpl_var name=param -->

to generate valid HTML syntax. Have a look at the docs at

    http://search.cpan.org/~samtregar/HTML-Template-2.7/Template.pm

where this feature is described in a paragraph named "NOTES".

regards,
fabian


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

Date: Mon, 07 Mar 2005 22:50:35 GMT
From: ktom <abc@invalid.com>
Subject: environment inheritance
Message-Id: <%U4Xd.30904$SE2.1606@fe2.texas.rr.com>

when executing a 'system( some_other program );' from within a perl 
script the environment it inherits, specifically the path, is unexpected.

i login to the work station and an environment is defined and used for 
subsequent shells.  and so it seems it is used for the 'system' command.

i would prefer that it use the environment of the shell from which the 
perl script is called.  as they are different (i intentionally changed 
it) and changing the other, the login environment, requires that i log 
out and login once more.

is there a way to make the system call use the current environment..

thanks..

kevin


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

Date: 7 Mar 2005 06:45:39 -0800
From: terryintransit@yahoo.com (Terry)
Subject: HTML::Mason
Message-Id: <e8e29af9.0503070645.412cc92a@posting.google.com>

Hi All,

Im having a strange problem with Mason, a segmentation fault is
generated in the erro_log when I attempt to view a page in the
browser. Without the Mason entry in httpd.conf the apache server works
fine.

Terry

Details
=======

AIX		4.3
Apache	        1.3.33 (Unix) 
mod_perl	1.29
Mason		1.28

Entry in httpd.conf

PerlModule HTML::Mason::ApacheHandler

# bring in the handler.pl file       
PerlRequire /usr/local/apache/lib/mason/handler.pl 

 	# servers these files through Mason
<LocationMatch "(\.html|\.txt|\.pl)$">
   	 SetHandler   perl-script
       PerlHandler  HTML::Mason::ApacheHandler
</LocationMatch>

 	# blocks these files from being served
<LocationMatch "(\.m(html|txt|pl)|dhandler|autohandler)$">
   	 SetHandler perl-script
   	 PerlInitHandler Apache::Constants::NOT_FOUND
</LocationMatch>



Error generated in error_log
   [notice] child pid 44052 exit signal Segmentation fault (11)

Some difficulties were experienced when I was installing the various
prerequisite modules – this may/not be relevant to this issue


Cache-Cache-1.02

Problems with make test.

>make test
        PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/1_test_cache_interface...................ok
t/2_test_memory_cache......................ok
t/3_test_file_cache........................ok
t/4_test_shared_memory_cache...............ok 1/35IPC::ShareLite
fetch() error: A system call received a parameter that is not valid
 . at /opt/docket/docket_install_20050215/Cache-Cache-1.02/blib/lib/Cache/SharedMemoryBackend.pm
line 98


Apache::Test

Problems with make test


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

Date: Mon, 07 Mar 2005 10:42:13 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: HTML::Mason
Message-Id: <etomztf1hfu.fsf@wilson.emschwar>

terryintransit@yahoo.com (Terry) writes:
> Im having a strange problem with Mason, a segmentation fault is
> generated in the erro_log when I attempt to view a page in the
> browser. Without the Mason entry in httpd.conf the apache server works
> fine.

This has happened to me before.  In my case, the problem was that I
had forgotten to enable libapreq2 in my Apache2 config.  Make sure
you've LoadModule'd it-- in the case of Debian, or a derived distro,
you can just symlink apreq.load from /etc/apache2/mods-available to
/etc/apache2/mods-enabled to enable it.

If that's not it, then I'll bet it's going to be something similar,
even if not identical-- trying to call into some library that isn't
loaded into apache.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: 7 Mar 2005 18:03:08 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: IO::Scalar insanity
Message-Id: <Xns96127BBD3AB4Debohlmanomsdevcom@130.133.1.4>

bill <please_post@nomail.edu> wrote in
news:d0f7fe$k7m$1@reader1.panix.com: 

> This appears to be the way to go (assuming v5.8 is available).  I
> first tried (wishfully)
> 
>   open(STDIN, '<', \$input)
> 
> which failed (for reasons I don't understand, but I imagine have
> to do with the old fileno issue you mentioned), but this worked
> 
>   open(my $SH, '<', \$input); # or die, etc.
>   *STDIN = $SH;

Your first attempt will work if you close STDIN first.


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

Date: 7 Mar 2005 08:02:25 -0800
From: s_p_a_m_mob@hotmail.com
Subject: Net::Google error handling
Message-Id: <1110210658.032886.271040@l41g2000cwc.googlegroups.com>

Hi there,

Do any of you know how to catch any error from Net::Google (or
underlying SOAP::Lite?). I created a basic script to retrieve files
from Google, and if my internet connexion gets down, I can't catch
neither an exception nor an error code. It just seems to output some
debugging informations...

my $google = Net::Google->new(key=>$key);
my $search = $google->search();
$search->query($query);
$search->max_results(MAXRESULTS);
$search->filter(1);

$results = $search->results(); # that method returns an ARRAY in any
case


Thanks in advance,

Marc-Olivier BERNARD



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

Date: 7 Mar 2005 08:05:54 -0800
From: s_p_a_m_mob@hotmail.com
Subject: Re: Net::Google error handling
Message-Id: <1110211554.157682.309460@g14g2000cwa.googlegroups.com>


My poorman solution is to catch and analyse the warnings:

$SIG{__WARN__} = sub {
my $message = join('',@_);
  if ($message =~ m/500 Can't connect to api.google.com:80/){
    # log message and wait to retry
    sleep 180;
  }
};



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

Date: 7 Mar 2005 14:01:41 -0800
From: "noeldamonmiller@gmail.com" <noeldamonmiller@gmail.com>
Subject: pp syntax issue?
Message-Id: <1110229796.839735.153850@l41g2000cwc.googlegroups.com>

All,


I am having difficulty creating a standalone executable from the perl
script

http://cvs.sourceforge.net/viewcvs.py/eimmunesys/eimmunesys/stable/

I am running the following command to make the archive (Fedora Core 3)

pp -o eis -M Net::Pcap.pm -M Tk -M Tk::Button -M Tk::Checkbutton -M
Tk::FileSelect -M Tk::Frame -M Tk::Menubutton -M Tk::Text -M
Tk::ColorEditor -M Tk::Config -M Tk::Dirtree -M Tk::Event -M Tk::FBox
-M Tk::Image eis.pl -M Tk::Mainwindow -M Tk::Submethods -M Tk::Widget
-M Tk::Canvas -M Tk::Optionmenu -M Tk::Scale -M Tk::Tree -M
Tk::Event::IO -M Tk::IconList -M Tk::Dialog -M Tk::LabEntry -M
Tk::Listbox -M Tk::Toplevel -M Tk::Wm -M Tk::widgets -M Tk::Configure
-M Tk::Derived -M Tk::CmdLine -M Tk::Menu -M Tk::Menu::Item -M
Tk::Clipboard -M Tk::DialogBox -M Tk::Entry -M Tk::Label -M
Tk::Radiobutton -M Tk::Text::Tag -M Tk::HList -M Tk::Adjuster -M
Tk::After -M Tk::Pixmap -M Tk::Pretty -M Tk::Scrollbar -M
Tk::DummyEncode -M POSIX -l ncurses -l libpcap eis.pl

After it's creation I have copied it to a similar Linux Distro (RH
Enterprise 3)

Running it has this error:

Uncaught exception from user code:
        Can't load
'/tmp/par-MYUSERNAME/cache-a290eaf4f90148119d1b4b5f160fe7746dbcc0c4/d871a3e5.so'
for module Net::Pcap: libpcap.so.0.8.3: cannot open shared object file:
No such file or directory at
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/DynaLoader.pm line 230.
 at ../blib/lib/PAR/Heavy.pm line 107
Compilation failed in require at script/eis.pl line 7.
BEGIN failed--compilation aborted at script/eis.pl line 7.
BEGIN failed--compilation aborted at -e line 835.
 at -e line 835

I have tried to include all dependencies, but it doesn't seem to make
any difference because the executable is trying to use a library it
cached on the old machine. Is that an accurate assessment? If so, what
do I do about it? If not, what is going on here?


Thank you very much in advance. 

Noel



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

Date: Mon, 07 Mar 2005 20:38:17 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: shmem & complex data?
Message-Id: <slrnd2peq8.co.dkoleary@linux.attbi.com>

Hey;

I'm trying to design a web based application which will maintain
a complex set of data.  There are a number of different pieces that
I'm trying to fit together.

The one with which I'm currently wrestling is interprocess communcications.

An example process flow:

1.  The user hits the url link to the application.  The app runs, loads
    the data into a data structure, displays the initial menu.
2.  User selects add a new host.  App displays a new window or frame (TBD)
    obtains the requisite information, then, upon getting submitted,
    updates the data structure.

There are at least five separate items that can/should be added, updated,
or deleted.

Due to the stateless nature of http, the various functions, even if in
the same script, won't be in the same instance therefore they won't have
access to the data that's being maintained.  Enter interprocess
comms.

I am very new to scripting IPCS.  I've read the relevant entries in 
Programming Perl, and the Perl cookbook and, from that, found 
IPC::Shareable.  Initially, that sounded like just what I was looking for.

I'm able to get the very simple test scripts listed in the IPCS::
Shareable and the cookbook running.  I'm pretty sure I understand them
too.  Back in the web app script, I have the following:

my $nagios;
my $ipcs = tie $nagios, 'IPC::Shareable',
   { key => 'data', create => 1, destroy => 1 };
$ipcs->shlock();

// functions which load data structure into %{$nagios}

$ipcs->shunlock();
while (1)
{  print "Zhdu\n";
   sleep 300;
}

When I run the script, it runs for maybe 20 seconds, then displays:

Could not create semaphore set: No space left on device
 at ./nadmin line 173

Without the IPCS, to load and dump about 100k worth of data is < 2 seconds.

Within the IPC::Shareable docs, there is a section on references which 
states:

Secondly, since a new shared memory segment is created for each thingy
being referenced, the liberal use of references could cause the system
to approach its limit for the total number of shared memory segments
allowed.

I understand that to mean everytime there's a new reference (and there
are *ALOT* of them), I'm creating a new shmem segment.  

Long winded background to get to the questions:

1.  Am I understanding the IPC::Shareable correctly which means that I'm
running into the max number of segments?

2.	  If the understanding is correct, is there a way to circumvent
this issue using IPC::Shareable?

3.   Am I perhaps barking up the wrong tree in trying to use IPCS 
to maintain a complex data structure?

Thanks for any hints/tips/suggestions.

Doug O'Leary


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

Date: Mon, 07 Mar 2005 14:01:25 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: shmem & complex data?
Message-Id: <etoy8czb26y.fsf@wilson.emschwar>

Doug O'Leary <dkoleary@olearycomputers.com> writes:
> I'm trying to design a web based application which will maintain
> a complex set of data.  There are a number of different pieces that
> I'm trying to fit together.

<snip>

> Due to the stateless nature of http, the various functions, even if in
> the same script, won't be in the same instance therefore they won't have
> access to the data that's being maintained.  Enter interprocess
> comms.

And hopefully, exit stage left.  IPC really only makes sense when you
have multiple processes running at the same time that all need to
communicate with each other.  This won't be the case with your setup
here, because once the user hits submit, a process retrieves the data
from the form, does stuff with it, and returns.  User hits submit
again, and repeat.  Nowhere in this process flow does the user do
multiple things at the same time.

> 3.   Am I perhaps barking up the wrong tree in trying to use IPCS 
> to maintain a complex data structure?

Yes.  You want to use any of the available session modules on CPAN to
generate a unique session ID, and store all the complex data on the
server, either in a file or database (there's always Cache::Mem, I
suppose).  When the user hits "submit", in your example, add the new
host to the data structure on the server, and redirect to a url that
displays the new information, which will draw on the data structure
you stored on the server somehow, and so on.

You'll want to talk to someone on comp.infosystems.www.authoring.cgi
about taking this further, most likely, as this sort of problem is
generic to any web-based application.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Mon, 07 Mar 2005 13:16:03 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: TCP/UDP Question
Message-Id: <070320051316034688%jgibson@mail.arc.nasa.gov>

In article <d0chtd$tam$1@news.astound.net>, Snail <snail@localhost.com>
wrote:

> I've been playing around with the following example code:
> 

[udp code snipped]

> And similar examples for tcp using accept().
> 
> My question is (mainly for TCP servers), if you fork the server, how can 
> you then communicate between multiple connected clients?

You normally fork the server to deal with one client on a short-term
(query-response) basis. The client connects and either supplies data,
asks for data, or both. The server responds and breaks the connection.
The server would fork if responding takes awhile and it needs to deal
with other clients in the meantime.

Clients do not normally communicate with each other, unless the server
is explicitly designed to allow that service (e.g., a messaging system
or a publish-and-subscribe server). In that case, the server does not
fork, but keeps a set of connected clients. The server can then send
and receive data from/to each client independently.

> 
> Seems to that, say if one client conencts, then at soem point issues a 
> command like "view all" there seems to be no way to itterate through the 
> clients to send backa reponse. In other words, client A is forked, data 
> is recieved from it, but since it is forked, it wont know of the other 
> clients. Even if the server's process (the original/main process) 
> maintains a list of all clients, when a client is forked, and then other 
> clients connect, then the version of the list the forked client "sees" 
> will be not be updated as new clients connect (or if old ones 
> disconenct.)
> 
> What is a good solution for this?

Don't fork.


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: Mon, 7 Mar 2005 19:47:35 +0100
From: "Sebastian Marants" <semura@gmx.de>
Subject: use a hash from a module within a main program without passing by reference or value
Message-Id: <d0i7mp$56d$1@beech.fernuni-hagen.de>

Hello,

i have a module and my program that uses it.
i want to use the hash which is only declared
in my module within the main program.
I want the output to be
one
two
two
one

but it prints nothing
anyone can help me out and teach me the
scope of variables when using modules?
in other words: how can i make %MYCOOLHASH
available in test.pl without passing it by reference
or value.

thanks in advance
Sebastian

--- test.pl ------------------
use mycoolmodule;

print "$MYCOOLHASH{'test1'}\n";
print "$MYCOOLHASH{'test2'}\n";
&changeValues();
print "$MYCOOLHASH{'test1'}\n";
print "$MYCOOLHASH{'test2'}\n";
exit;
----------------------------------------

--- mycoolmodule.pm ------------------

my %MYCOOLHASH;
$MYCOOLHASH{'test1'} = "one";
$MYCOOLHASH{'test2'} = "two";

sub changeValues
{
$MYCOOLHASH{'test1'} = "two";
$MYCOOLHASH('test2'} = "one";
}
1;
exit;
----------------------------------------




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

Date: 7 Mar 2005 11:57:39 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: use a hash from a module within a main program without passing by reference or value
Message-Id: <1110225459.542903.64220@z14g2000cwz.googlegroups.com>

Sebastian Marants wrote:
>
> i have a module and my program that uses it.
> i want to use the hash which is only declared
> in my module within the main program.
> I want the output to be
> one
> two
> two
> one
>
> but it prints nothing
>
> --- test.pl ------------------
> use mycoolmodule;
>
> print "$MYCOOLHASH{'test1'}\n";
> print "$MYCOOLHASH{'test2'}\n";
> &changeValues();
> print "$MYCOOLHASH{'test1'}\n";
> print "$MYCOOLHASH{'test2'}\n";
> exit;
> ----------------------------------------
>
> --- mycoolmodule.pm ------------------
>
> my %MYCOOLHASH;
> $MYCOOLHASH{'test1'} = "one";
> $MYCOOLHASH{'test2'} = "two";
>
> sub changeValues
> {
> $MYCOOLHASH{'test1'} = "two";
> $MYCOOLHASH('test2'} = "one";
> }
> 1;
> exit;
> ----------------------------------------


Dear Sebastian,

   Try declaring %MYCOOLHASH with "our" instead of "my".  Using "my"
makes %MYCOOLHASH accessible only to the "mycoolmodule.pm" file,
whereas using "our" makes it accessible to the entire "main" package.

   I also recommend using "use strict;" and "use warnings;".  If you
had used them, they would have let you know that %MYCOOLHASH did not
exist in the "test.pl" file.

   I hope this helps, Sebastian.

   -- Jean-Luc Romano



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

Date: 07 Mar 2005 20:54:20 GMT
From: xhoster@gmail.com
Subject: Re: use a hash from a module within a main program without passing by reference or value
Message-Id: <20050307155420.289$Qp@newsreader.com>

"Sebastian Marants" <semura@gmx.de> wrote:
> Hello,
>
> i have a module and my program that uses it.
> i want to use the hash which is only declared
> in my module within the main program.

Why?  If you want to do this, it often means that you
haven't designed your module boundaries very well.


> I want the output to be
> one
> two
> two
> one
>
> but it prints nothing

I bet it prints *something*.

> anyone can help me out and teach me the
> scope of variables when using modules?

The docs can probably teach you that.  If you read
the apparently relevant docs and still don't know, it would be best
if you tell us that in your post.

See:

perldoc -f my
perldoc perlsub
perldoc perlmod

And, because the answer to your question (other than "don't do that")
is to use package rather than lexical variables, you should probably
also see:

perldoc -f our

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


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

Date: Mon, 07 Mar 2005 13:09:42 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: use a hash from a module within a main program without passing by reference or value
Message-Id: <eto4qfncj5l.fsf@wilson.emschwar>

"Sebastian Marants" <semura@gmx.de> writes:
> i have a module and my program that uses it.
> i want to use the hash which is only declared
> in my module within the main program.
> I want the output to be
> one
> two
> two
> one
>
> but it prints nothing
> anyone can help me out and teach me the
> scope of variables when using modules?

In this case, it's no different than the scope of anything else.  'my'
variables are lexically scoped, and therefore not accessible from
outside your module.  'perldoc -f my' to read more about this.

> in other words: how can i make %MYCOOLHASH
> available in test.pl without passing it by reference
> or value.

As a general principle, You Don't Want To Do This(tm).  There are a
few places where global variables are required, but almost every place
they're used, they're not needed.  In this case, I would probably use
an accessor and a setter function, which I will explain below.


> --- test.pl ------------------
> use mycoolmodule;

use warnings;
use strict;

> print "$MYCOOLHASH{'test1'}\n";
> print "$MYCOOLHASH{'test2'}\n";

print GetHashVal('test1');
print GetHashVal('test2');

> &changeValues();

You don't want to call functions with & unless you know what it does
and why.  I will bet your next paycheck that you don't.  This isn't a
crime, so just educate yourself by reading 'perldoc perlsub'.

> print "$MYCOOLHASH{'test1'}\n";
> print "$MYCOOLHASH{'test2'}\n";

See above.  Also, all-upper-case names read as if you're shouting, and
are by convention reserved for constants in Perl.  This clearly isn't
a constant, since you're changing it, so perhaps

%my_cool_hash

would be better here.

> exit;
> ----------------------------------------
>
> --- mycoolmodule.pm ------------------
>
> my %MYCOOLHASH;
> $MYCOOLHASH{'test1'} = "one";
> $MYCOOLHASH{'test2'} = "two";
>
> sub changeValues
> {
> $MYCOOLHASH{'test1'} = "two";
> $MYCOOLHASH('test2'} = "one";
> }

In general, I'd avoid making global variables here, too.

Maybe something like:

our %MYCOOLHASH;

sub changeValues
{
   my (%hash) = @_;

   $hash{test1} = 'two';
   $hash{test2} = 'one';

   return %hash;
}

Then you could do in your main program:

%MYCOOLHASH = changeValues(%MYCOOLHASH);

or even

%my_switched_hash = changeValues(%my_cool_hash);

in case you want to save the original to compare the switched one with
later.

> 1;
> exit;

This can't be your real code; this exit here will cause your main
program to exit as soon as it is encountered.  Please cut and paste
real code.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: 7 Mar 2005 13:01:39 -0800
From: "Woland99" <woland99@yahoo.com>
Subject: Win32::OLE - Excelo files hidden after SaveAs
Message-Id: <1110229299.578306.214080@l41g2000cwc.googlegroups.com>

Hi, I use Win32::OLE to read in and manipulate data from
Excel files. When I try to SaveAs modified file and then
reopen it I always have to Unhide it.
For example:
$wbook = ....

in a loop....
{
 ....
$wsheet->Cells($row_num,$col_num)->{Value} = "$cell_value";
 ....
}

and then:
$wbook->SaveAs($fullname_output_file);

makes $fullname_output_file hidden.
I do not see any property I can set on $wbook to Unhide it
(same way as from Windows menu in Excel).

Thanks for any pointers,

JT



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

Date: Mon, 07 Mar 2005 21:47:03 +0000
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: Win32::OLE - Excelo files hidden after SaveAs
Message-Id: <nqip21dsiv0281o0c7vordu3020vgrk8df@4ax.com>

On 7 Mar 2005 13:01:39 -0800, "Woland99" <woland99@yahoo.com> wrote:

>Hi, I use Win32::OLE to read in and manipulate data from
>Excel files. When I try to SaveAs modified file and then
>reopen it I always have to Unhide it.

>I do not see any property I can set on $wbook to Unhide it
>(same way as from Windows menu in Excel).

This is almost certainly an Excel COM problem rather than a Perl one,
which means that you will probably get better help in a Microsoft COM
group rather than here (but you may need to hide the fact that you're
programming the COM object in such a sensible language as Perl!)

But if you Google in the groups for a post entitled "Win32::OLE hiding
Excel sheets" (dated April 2003) you'll see some suggestions.


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

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


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