[28226] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9590 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 11 03:05:44 2006

Date: Fri, 11 Aug 2006 00:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 11 Aug 2006     Volume: 10 Number: 9590

Today's topics:
        flock not locking xargle@eh.org
    Re: flock not locking xhoster@gmail.com
    Re: flock not locking <benmorrow@tiscali.co.uk>
    Re: geometry problem <carlston88@gmail.com>
    Re: How to send command line options into test scripts? <mgarrish@gmail.com>
    Re: How to send command line options into test scripts? <tadmc@augustmail.com>
    Re: How to send command line options into test scripts? <yusufm@gmail.com>
    Re: How to send command line options into test scripts? <kkeller-usenet@wombat.san-francisco.ca.us>
        module install question <a@mail.com>
    Re: module install question <tintin@invalid.invalid>
    Re: My code only works for 1st line in a file..need you <tadmc@augustmail.com>
        new CPAN modules on Fri Aug 11 2006 (Randal Schwartz)
    Re: regex and utf8 characters (german umlauts) <ext-dirk.heinrichs@nokia.com>
    Re: regex and utf8 characters (german umlauts) <ext-dirk.heinrichs@nokia.com>
        Storing multiple selections <spamvivek@gmail.com>
    Re: Storing multiple selections <simon@unisolve.com.au>
    Re: win32::printer and text formatting <benmorrow@tiscali.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 10 Aug 2006 15:25:24 -0700
From: xargle@eh.org
Subject: flock not locking
Message-Id: <1155248724.468235.54850@m73g2000cwd.googlegroups.com>

I'm using perl 5.8.5 under RHEL 4, and trying to produce a quick
sockets server with 240 forked processes all accepting from a listener
socket. Which fork gets to accept is governed by who gets the flock,
which would normally be a flock on the listener socket, but as that
didn't work I tried using a file in /tmp and flocking that. This is
apparently what apache does. This is an attempt at optimising an
existing application to reduce load as connections to the server are
very short and very regular, so the constant forking is undesirable...

>From the entry point the code looks like this :

my $kid;
my $socket = IO::Socket::INET->new(
        LocalPort => '4576',
        Proto => 'tcp',
        Listen => SOMAXCONN,
        Reuse => 1)
    or die "Failed to listen: $!";
my $i=0;

# ignore the kids, they're noisy little gits
$SIG{CHLD} = 'IGNORE';

# open a temp file to provide us with a locking mechanism as
# perl doesn't appear to like us locking socket handles
sysopen(LOCKFILE, "/tmp/test.lock", O_WRONLY | O_CREAT) || die "Can't
open lock file /tmp/test.lock\n";

STDOUT->autoflush(1);

while ($i < $tofork)
{
  sleep 1;
  $i++;
  # fork here, if we're the parent just loop
  next if $kid = fork;

  print STDOUT "Forked worker on pid " . getpid() . "\n";

  while(1)
  {
    print STDOUT getpid() . " requesting LOCK_EX\n";
    flock LOCKFILE,2 or die "cant flock: $!"; # 2 = LOCK_EX, exclusive
lock
    print STDOUT getpid() . " has gained LOCK_EX\n";
    my $client = $socket->accept();
    print STDOUT getpid() . " accepted connection from " .
$client->sockhost . " and will unlock listener\n";
    flock LOCKFILE,8 or die "cant flock: $!"; # 8 = LOCK_UN, unlock

    process_connection($client);
    print STDOUT getpid() . " session is done\n";
  }

  while(1)
  {
    sleep(60);
  }
}

The while(1) sleep is a desperate measure whilst attempting to get the
locking working in case the parent thread exiting was the issue, ditto
the sleep 1 between starting the threads.

What happens is the 240 threads start, but the flock LOCK_EX (2)
doesn't block at all and returns no error, so all the forks end up
trying to accept which is precisely what I don't want to occur.

Am I missing something here? Does flock work in 5.8.5? Is it something
to do with the forking?

Any advice would be greatly appreciated.

--
Tony



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

Date: 10 Aug 2006 23:00:23 GMT
From: xhoster@gmail.com
Subject: Re: flock not locking
Message-Id: <20060810191001.004$ZF@newsreader.com>

xargle@eh.org wrote:
> I'm using perl 5.8.5 under RHEL 4, and trying to produce a quick
> sockets server with 240 forked processes all accepting from a listener
> socket. Which fork gets to accept is governed by who gets the flock,
> which would normally be a flock on the listener socket, but as that
> didn't work I tried using a file in /tmp and flocking that. This is
> apparently what apache does. This is an attempt at optimising an
> existing application to reduce load as connections to the server are
> very short and very regular, so the constant forking is undesirable...

 ...
>
> # open a temp file to provide us with a locking mechanism as
> # perl doesn't appear to like us locking socket handles
> sysopen(LOCKFILE, "/tmp/test.lock", O_WRONLY | O_CREAT) || die "Can't
> open lock file /tmp/test.lock\n";
>
> STDOUT->autoflush(1);
>
> while ($i < $tofork)
> {
>   sleep 1;
>   $i++;
>   # fork here, if we're the parent just loop
>   next if $kid = fork;

Each child has to open the tmp file anew, to get an independent handle onto
the file.  When you open the file before forking, every forked process is
sharing the same handle, and thus they can't lock each other out.

So just move the sysopen into the loop, after the fork.

Xho

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


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

Date: Fri, 11 Aug 2006 04:10:28 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: flock not locking
Message-Id: <429tq3-ltb.ln1@osiris.mauzo.dyndns.org>


Quoth xargle@eh.org:
> I'm using perl 5.8.5 under RHEL 4, and trying to produce a quick
> sockets server with 240 forked processes all accepting from a listener
> socket. Which fork gets to accept is governed by who gets the flock,
> which would normally be a flock on the listener socket, but as that
> didn't work I tried using a file in /tmp and flocking that. This is
> apparently what apache does. This is an attempt at optimising an
> existing application to reduce load as connections to the server are
> very short and very regular, so the constant forking is undesirable...
> 
> >From the entry point the code looks like this :

Further to what Xho said (each child needs to open the file itself),
here is some more advice:

> my $kid;

Don't declare variables before you need them.

> my $socket = IO::Socket::INET->new(
>         LocalPort => '4576',
>         Proto => 'tcp',
>         Listen => SOMAXCONN,
>         Reuse => 1)
>     or die "Failed to listen: $!";
> my $i=0;

Variables are automatically initialized to undef, which is 0 in numeric
context. However see below...

> # ignore the kids, they're noisy little gits
> $SIG{CHLD} = 'IGNORE';
> 
> # open a temp file to provide us with a locking mechanism as
> # perl doesn't appear to like us locking socket handles

It's not perl, it's the OS. On most OSen, sockets don't accept locks.

> sysopen(LOCKFILE, "/tmp/test.lock", O_WRONLY | O_CREAT) || die "Can't
> open lock file /tmp/test.lock\n";

It's better to use lexical filehandles. These work with sysopen as well
as open

    sysopen (my $LOCKFILE, '/tmp/test.lock', O_WRONLY|O_CREAT)
        or die "can't open lock file /tmp/test.lock: $!\n";

I've kept your parens, but if you use or instead of || you can drop
them.

> STDOUT->autoflush(1);

I *really* don't like this. STDOUT is not an object, even though it
pretends to be. Learn how to use the special variables.

> while ($i < $tofork)

This is just an unwrapped C-style for loop, without the subtlety of
using a continue block to do the increment. It is better written in Perl
as

    for (1..$tofork) {

> {
>   sleep 1;
>   $i++;
>   # fork here, if we're the parent just loop
>   next if $kid = fork;
> 
>   print STDOUT "Forked worker on pid " . getpid() . "\n";

The current pid is available as $$.

>   while(1)
>   {
>     print STDOUT getpid() . " requesting LOCK_EX\n";
>     flock LOCKFILE,2 or die "cant flock: $!"; # 2 = LOCK_EX, exclusive
> lock

Don't *ever* hardcode flock values. Get them from the Fcntl module:

    use Fcntl qw/:flock/;

    flock LOCKFILE, LOCK_EX;

>     print STDOUT getpid() . " has gained LOCK_EX\n";
>     my $client = $socket->accept();
>     print STDOUT getpid() . " accepted connection from " .
> $client->sockhost . " and will unlock listener\n";
>     flock LOCKFILE,8 or die "cant flock: $!"; # 8 = LOCK_UN, unlock

This may have been one of the rare cases that an explicit LOCK_UN wasn't
a bug, but as you have to reopen the file to get a new lock anyway
you're better off closing it to unlock. If you use lexical FHs you just
need to scope the variable over the piece of code you want under the
lock. As an added bonus if you ever move to threads instead (not
something I'd recommend with the current Perl thread model under Unix)
you won't need to change much.

You may also want to look at the modules on CPAN which do this, such as
Parallel::ForkManager or Proc::Fork.

Ben

-- 
        I must not fear. Fear is the mind-killer. I will face my fear and
        I will let it pass through me. When the fear is gone there will be 
        nothing. Only I will remain.
benmorrow@tiscali.co.uk                                   Frank Herbert, 'Dune'


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

Date: 10 Aug 2006 17:07:53 -0700
From: "IcyMint" <carlston88@gmail.com>
Subject: Re: geometry problem
Message-Id: <1155254872.942640.306660@75g2000cwc.googlegroups.com>

Hi, thank you all for your feedbacks. I'm really glad to be pointed to
all the informations I needed. I think that the Geo::SpaceManager is
quite good, I'll be using it unless something better comes along.
Thanks a lot!



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

Date: 10 Aug 2006 15:05:26 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: How to send command line options into test scripts?
Message-Id: <1155247526.118541.310030@i3g2000cwc.googlegroups.com>


yusuf wrote:

> If you don't want to help just shut up and move along.

Why, this isn't your personal help desk?

Best of luck finding the help the world owes you, though.

Matt



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

Date: Thu, 10 Aug 2006 18:31:50 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to send command line options into test scripts?
Message-Id: <slrnedngf6.r9.tadmc@magna.augustmail.com>

yusuf <yusufm@gmail.com> wrote:
>= 
>> So long!
> 
> Why are you so rude? 


It is a response to _your_ rudeness.


> Not like you helped any.


And I'm glad I didn't too!

Thanks for making me feel better about that.


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


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

Date: 10 Aug 2006 16:51:04 -0700
From: "yusuf" <yusufm@gmail.com>
Subject: Re: How to send command line options into test scripts?
Message-Id: <1155253864.077168.296460@m79g2000cwm.googlegroups.com>

> It is a response to _your_ rudeness.

Well, it wasn't my intention to be rude. Sorry if you felt that way.



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

Date: Thu, 10 Aug 2006 22:30:30 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: How to send command line options into test scripts?
Message-Id: <n8htq3xni4.ln2@goaway.wombat.san-francisco.ca.us>

On 2006-08-10, yusuf <yusufm@gmail.com> wrote:
>
> Well, it wasn't my intention to be rude. Sorry if you felt that way.

If it wasn't your intention to be rude, you might consider reading
and following the Posting Guidelines that are posted periodically
to the newsgroup.

--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information



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

Date: Fri, 11 Aug 2006 06:05:45 GMT
From: "a" <a@mail.com>
Subject: module install question
Message-Id: <Z6VCg.374022$IK3.367968@pd7tw1no>

Hi
According to the instruction of the README for the downloaded module, the
installation procedure always,
perl Makefile.pl
make
make test
make install
I can only do perl Makefile.pl. The make commands are all failed and there
is  no test and install file. Do the last 3 commands necessary?
Thanks




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

Date: Fri, 11 Aug 2006 18:56:04 +1200
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: module install question
Message-Id: <44dc1cd0$0$444$88260bb3@free.teranews.com>


"a" <a@mail.com> wrote in message news:Z6VCg.374022$IK3.367968@pd7tw1no...
> Hi
> According to the instruction of the README for the downloaded module, the
> installation procedure always,
> perl Makefile.pl
> make
> make test
> make install
> I can only do perl Makefile.pl. The make commands are all failed and there
> is  no test and install file. Do the last 3 commands necessary?
> Thanks

What OS are you on?
What are the *exact* error messages you are getting? 



-- 
Posted via a free Usenet account from http://www.teranews.com



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

Date: Thu, 10 Aug 2006 18:34:14 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: My code only works for 1st line in a file..need your help
Message-Id: <slrnedngjm.r9.tadmc@magna.augustmail.com>

Shan <Shani718@gmail.com> wrote:

> Thank you all. I added chop


Then take it out, and replace it with chomp() instead.


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


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

Date: Fri, 11 Aug 2006 04:42:10 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri Aug 11 2006
Message-Id: <J3tH2A.23yu@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Acme-Terror-NL-0.01
http://search.cpan.org/~blom/Acme-Terror-NL-0.01/
Fetch the current NL terror alert level
----
Acme-Terror-UK-0.03
http://search.cpan.org/~rprice/Acme-Terror-UK-0.03/
Fetch the current UK terror alert level
----
Apache2-TomKit-0.01_5
http://search.cpan.org/~tomson/Apache2-TomKit-0.01_5/
Perl Module used to Transform Content
----
Cairo-0.91
http://search.cpan.org/~tsch/Cairo-0.91/
Perl interface to the cairo library
----
Catalyst-Plugin-Session-0.11
http://search.cpan.org/~nuffin/Catalyst-Plugin-Session-0.11/
Generic Session plugin - ties together server side storage and client side state required to maintain session data.
----
Catalyst-Plugin-Session-DynamicExpiry-0.02
http://search.cpan.org/~nuffin/Catalyst-Plugin-Session-DynamicExpiry-0.02/
per-session custom expiry times
----
Chart-Clicker-1.0.2
http://search.cpan.org/~gphat/Chart-Clicker-1.0.2/
Powerful, extensible charting.
----
Class-Constant-0.03
http://search.cpan.org/~robn/Class-Constant-0.03/
Build constant classes
----
DBD-Salesforce-0.04
http://search.cpan.org/~bayside/DBD-Salesforce-0.04/
Treat Salesforce as a datasource for DBI
----
Email-Address-1.870
http://search.cpan.org/~rjbs/Email-Address-1.870/
RFC 2822 Address Parsing and Creation
----
File-Tempdir-0.02
http://search.cpan.org/~nanardon/File-Tempdir-0.02/
----
Hash-Tally-0.02
http://search.cpan.org/~adapay/Hash-Tally-0.02/
Compute the tallies of hash values
----
Image-IPTCInfo-1.94
http://search.cpan.org/~jcarter/Image-IPTCInfo-1.94/
Perl extension for extracting IPTC image meta-data
----
Lab-Instrument-1.1
http://search.cpan.org/~schroeer/Lab-Instrument-1.1/
General VISA based instrument
----
Lab-Tools-1.00
http://search.cpan.org/~schroeer/Lab-Tools-1.00/
----
MDV-Repsys-0.07
http://search.cpan.org/~nanardon/MDV-Repsys-0.07/
----
Mail-Qmail-Queue-0.01
http://search.cpan.org/~giff/Mail-Qmail-Queue-0.01/
----
Mail-Qmail-Queue-0.02
http://search.cpan.org/~giff/Mail-Qmail-Queue-0.02/
----
Mail-Webmail-Gmail-1.09
http://search.cpan.org/~mincus/Mail-Webmail-Gmail-1.09/
An interface to Google's webmail service
----
Math-Random-MT-Auto-5.03
http://search.cpan.org/~jdhedden/Math-Random-MT-Auto-5.03/
Auto-seeded Mersenne Twister PRNGs
----
Nagios-Object-0.09
http://search.cpan.org/~tobeya/Nagios-Object-0.09/
----
Nagios-Object-0.10
http://search.cpan.org/~tobeya/Nagios-Object-0.10/
----
Net-FTP-AutoReconnect-0.2
http://search.cpan.org/~giff/Net-FTP-AutoReconnect-0.2/
FTP client class with automatic reconnect on failure
----
PAR-Repository-0.02
http://search.cpan.org/~smueller/PAR-Repository-0.02/
Create and modify PAR repositories
----
PAR-Repository-Client-0.02
http://search.cpan.org/~smueller/PAR-Repository-Client-0.02/
Access PAR repositories
----
POE-Component-Client-Traceroute-0.20
http://search.cpan.org/~ahoying/POE-Component-Client-Traceroute-0.20/
A non-blocking traceroute client
----
POE-Component-Server-Chargen-1.01
http://search.cpan.org/~bingos/POE-Component-Server-Chargen-1.01/
a POE component implementing a RFC 864 Chargen server.
----
POE-Component-Server-Daytime-1.01
http://search.cpan.org/~bingos/POE-Component-Server-Daytime-1.01/
a POE component implementing a RFC 865 Daytime server.
----
POE-Component-Server-Discard-1.01
http://search.cpan.org/~bingos/POE-Component-Server-Discard-1.01/
a POE component implementing a RFC 863 Discard server.
----
POE-Component-Server-Qotd-1.01
http://search.cpan.org/~bingos/POE-Component-Server-Qotd-1.01/
a POE component implementing a RFC 865 QotD server.
----
POE-Component-Server-Time-1.01
http://search.cpan.org/~bingos/POE-Component-Server-Time-1.01/
a POE component implementing a RFC 868 Time server.
----
POE-Filter-Zlib-1.4
http://search.cpan.org/~bingos/POE-Filter-Zlib-1.4/
A POE filter wrapped around Compress::Zlib
----
Parse-CSV-0.01
http://search.cpan.org/~adamk/Parse-CSV-0.01/
Highly flexible CVS parser for large files
----
Perlbal-1.44
http://search.cpan.org/~bradfitz/Perlbal-1.44/
Reverse-proxy load balancer and webserver
----
Perlbal-1.45
http://search.cpan.org/~bradfitz/Perlbal-1.45/
Reverse-proxy load balancer and webserver
----
Perlbal-1.46
http://search.cpan.org/~bradfitz/Perlbal-1.46/
Reverse-proxy load balancer and webserver
----
Plagger-0.7.7
http://search.cpan.org/~miyagawa/Plagger-0.7.7/
Pluggable RSS/Atom Aggregator
----
Rose-DB-0.723
http://search.cpan.org/~jsiracusa/Rose-DB-0.723/
A DBI wrapper and abstraction layer.
----
Rose-DB-Object-0.75
http://search.cpan.org/~jsiracusa/Rose-DB-Object-0.75/
Extensible, high performance RDBMS-OO mapper.
----
Salesforce-0.57
http://search.cpan.org/~bayside/Salesforce-0.57/
this class provides a simple abstraction layer between SOAP::Lite and Salesforce.com.
----
Test-MockTime-0.04
http://search.cpan.org/~ddick/Test-MockTime-0.04/
Replaces actual time with simulated time
----
Thread-Suspend-1.06
http://search.cpan.org/~jdhedden/Thread-Suspend-1.06/
Suspend and resume operations for threads
----
WWW-TWSMS-0.01
http://search.cpan.org/~snowfly/WWW-TWSMS-0.01/
Perl extension for send sms by TWSMS. (http://www.twsms.com)
----
XML-Atom-Stream-0.04
http://search.cpan.org/~miyagawa/XML-Atom-Stream-0.04/
A client interface for AtomStream
----
XML-Atom-Stream-0.05
http://search.cpan.org/~miyagawa/XML-Atom-Stream-0.05/
A client interface for AtomStream
----
XML-Atom-Stream-0.06
http://search.cpan.org/~miyagawa/XML-Atom-Stream-0.06/
A client interface for AtomStream
----
XML-Atom-Stream-0.07
http://search.cpan.org/~miyagawa/XML-Atom-Stream-0.07/
A client interface for AtomStream
----
rpm-build-perl-0.6.0
http://search.cpan.org/~atourbin/rpm-build-perl-0.6.0/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Fri, 11 Aug 2006 06:14:03 GMT
From: Dirk Heinrichs <ext-dirk.heinrichs@nokia.com>
Subject: Re: regex and utf8 characters (german umlauts)
Message-Id: <LeVCg.35310$_k2.625493@news2.nokia.com>

Ben Morrow wrote:

> As the post arrived here, the section of code represented above by
> '<c4><c4><c4>' is 3 bytes long. This is not valid UTF8, so if these
> three bytes are actually in your file you have a problem. I suspect your
> file is actually encoded in ISO8859-1; you can tell Perl this by putting

This was just the sample code I typed into the shell to test the regex. The
actual input file I want to process is indeed utf-8.

What I've seen was that umlauts and the following character were not
converted to lower case. So it seems umlauts were considered word
boundaries.

However, I finally solved it by adding

use open ':utf8';
binmode(STDOUT, ":utf8");

to my program.

Thanks to anybody for your effords.

Bye...

        Dirk
-- 
Dirk Heinrichs          | Tel:  +49 (0)162 234 3408
Configuration Manager   | Fax:  +49 (0)211 47068 111
Capgemini Deutschland   | Mail: dirk.heinrichs@capgemini.com
Hambornerstraße 55      | Web:  http://www.capgemini.com
D-40472 Düsseldorf      | ICQ#: 110037733
GPG Public Key C2E467BB | Keyserver: www.keyserver.net


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

Date: Fri, 11 Aug 2006 06:17:30 GMT
From: Dirk Heinrichs <ext-dirk.heinrichs@nokia.com>
Subject: Re: regex and utf8 characters (german umlauts)
Message-Id: <_hVCg.35311$_k2.625493@news2.nokia.com>

Dirk Heinrichs wrote:

> Thanks to anybody for your effords.

s/any/every/

Bye...

        Dirk
-- 
Dirk Heinrichs          | Tel:  +49 (0)162 234 3408
Configuration Manager   | Fax:  +49 (0)211 47068 111
Capgemini Deutschland   | Mail: dirk.heinrichs@capgemini.com
Hambornerstraße 55      | Web:  http://www.capgemini.com
D-40472 Düsseldorf      | ICQ#: 110037733
GPG Public Key C2E467BB | Keyserver: www.keyserver.net


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

Date: 10 Aug 2006 17:30:32 -0700
From: "Vivek" <spamvivek@gmail.com>
Subject: Storing multiple selections
Message-Id: <1155256232.726127.290880@p79g2000cwp.googlegroups.com>

Hello,
I have an existing script which generates a GUI. In existing GUI, there
are many parameters which have different options. Currently, one can
select only one option from the parameters.
Now, I have to change the script so as to select multiple options for
one of the parameter.
I am thinking of storing the options selected by user somewhere and
then execute each one by ine.
But, I am not able to transform this into a code. I tried using
curselection, but it returns the options which were selected just
before the execution, but I need to store those selected by the user
from the GUI window.Any suggestions...

Thanks,
Vivek



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

Date: Fri, 11 Aug 2006 11:41:28 +1000
From: Simon Taylor <simon@unisolve.com.au>
Subject: Re: Storing multiple selections
Message-Id: <ebgndq$23d$1@otis.netspace.net.au>

Hello Vivek,

> I have an existing script which generates a GUI. 
[snip]
> But, I am not able to transform this into a code. I tried using
> curselection, but it returns the options which were selected just
> before the execution, but I need to store those selected by the user
> from the GUI window.Any suggestions...

Two things will help you here:

1. Check out the posting guidelines at:

     http://www.augustmail.com/~tadmc/clpmisc.shtml

2. Post a short and complete program that illustrates the problem
    you are having.


Good luck.

- Simon Taylor



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

Date: Fri, 11 Aug 2006 03:51:58 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: win32::printer and text formatting
Message-Id: <ev7tq3-k4b.ln1@osiris.mauzo.dyndns.org>


Quoth "diavolo-verde@libero.it" <diavolo-verde@libero.it>:
> 
> Ben Morrow ha scritto:
> 
> > You need to use either sprintf or POSIX::localeconv or I18N::Langinfo;
> > or possibly there is a CPAN module to make this easier (the POSIX locale
> > interface is rather smelly).
> 
> Thanks Ben, I don't understand. I thought I could use
> win32::printer::write or write2 with their options:
> 
>   # String mode (SM):
>   $height = $dc->Write($text, $x, $y, [$format, [$just_width]]);
>   ($width, $height) = $dc->Write($text, $x, $y, [$format,
> [$just_width]]);
> 
>   # Draw mode (DM):
>   $height = $dc->Write($text, $x, $y, $width, $height, [$format,
> [$tab_stop]]);
>   ($width, $height, $length, $text) = $dc->Write($text, $x, $y, $width,
> $height, [$format, [$tab_stop]]);
> 
> but I can't figure out how to use them.

Maybe you can; I don't know that module.

> How sprintf could help me printing on printer device?

You format the number into a string and then print that. Having looked a
little further, I'd probably use Number::Format:

    use Number::Format;

    my $NF = Number::Format->new(
        -thousands_sep => '.', 
        -decimal_point => ',',
    );

    my $formatted_price = $NF->format_picture(204, '###,##');

then print $formatted-price however you would have before.

Ben

-- 
   If you put all the prophets,   |   You'd have so much more reason
   Mystics and saints             |   Than ever was born
   In one room together,          |   Out of all of the conflicts of time.
benmorrow@tiscali.co.uk                             The Levellers, 'Believers'


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

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


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