Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

How to use select

by agynr (Acolyte)
on Mar 05, 2005 at 07:24 UTC ( #436866=perlquestion: print w/replies, xml ) Need Help??
agynr has asked for the wisdom of the Perl Monks concerning the following question:

Hello all, I have a problem. I want to use the POSIX:SELECT in my perl script but the problem is that I m not able to find the required ppd file for that but when I m installing the particular file thru ppm(I m using Windows XP) it gives the following message
Error installing package 'POSIX:select': Could not locate a PPD file f +or package POSIX:select
Can anyone help me for the same. Also plz let me know that where installer looks for the particular ppds. Thanx

Replies are listed 'Best First'.
Re: How to use select
by Zaxo (Archbishop) on Mar 05, 2005 at 07:32 UTC

    You probably want one of the two builtin selects.

    The one-argument form sets the default output file. The four-argument form awaits I/O availability. The latter is nicely wrapped in IO::Select.

    The POSIX module comes with perl, but it has no select function.

    What are you trying to do?

    After Compline,

Re: How to use select
by Corion (Pope) on Mar 05, 2005 at 07:35 UTC

    At least does not know of a package called POSIX::SELECT. Where did you find the name of that package? If you can't find a precompiled package, you will have to compile it yourself. Most likely, guessing from its name, POSIX::Select tries to provide POSIX semantics for select, but on Win32, select does not work for filehandles, only for sockets. Maybe the module caters for Win32 separately, but I would doubt that from its name.

    So, if you don't find POSIX::Select, maybe you can tell us what problem you want to solve, so we can recommend alternatives?

      What I want is to use select statement as in other languages like C or C++ ..... I want to select from a no. of choices. Please let me know if it is possible or not . If it is possible then what is the ppd file to use.
        Ah, then what you want is a switch like statement .
        There's a module : switch .

        Or you can do it in a great number of various ways, the most common one is using a named block with last:

        SWITCH: { if (expression) { statement(s); last SWITCH; } if (expression) { statement(s); last SWITCH; } default statement(s); }
        update : don't try to be funky by using that switch module :) just use the if / last style ! See the answers by corion , holli and virtualsue !!

Re: How to use select
by tphyahoo (Vicar) on Mar 05, 2005 at 13:07 UTC
    Another way to do it using last.
    for ($animal) { /camel/ and do Humps(2), last; /dromedary/ and do Humps(1), last; }
    from "perl idioms" web page. Don't have the url but just google on my code.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://436866]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2017-04-30 22:35 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (543 votes). Check out past polls.