Newbie question on require and semaphores

Discussion in 'Perl Misc' started by Gerald Meazell, Dec 29, 2004.

  1. I'm trying to do some semaphore programming but when I put in the line
    'require "ipc.ph"', perl whines that ipc.ph cannot be found in @INC. It
    then goes on to list out the @INC directories. Sure enough, ipc.ph
    isn't in any of them, but it is in some subdirectories of the ones in
    @INC.

    I tried copying the files up one level but that did not work due to a
    compilation error.

    What do I need to do to get this working? I'm using RedHat.

    Thanks!

    --
    Gerald
     
    Gerald Meazell, Dec 29, 2004
    #1
    1. Advertising

  2. Gerald Meazell

    Matt Garrish Guest

    "Gerald Meazell" <> wrote in message
    news:GopAd.3767$...
    > I'm trying to do some semaphore programming but when I put in the line
    > 'require "ipc.ph"', perl whines that ipc.ph cannot be found in @INC. It
    > then goes on to list out the @INC directories. Sure enough, ipc.ph isn't
    > in any of them, but it is in some subdirectories of the ones in @INC.
    >
    > I tried copying the files up one level but that did not work due to a
    > compilation error.
    >
    > What do I need to do to get this working?
    >


    I would imagine specify the path to the file:

    use lib '/path/to/header/file';
    require 'ipc.ph';

    or

    require '/path/to/header/file/ipc.ph';

    Whatever compilation problems you're having likely have nothing to do with
    requiring the ph file, though, and everything to do with the code in that
    file. Without a specific error message and code, however, it's hard to say
    anything more useful than that.

    Matt
     
    Matt Garrish, Dec 29, 2004
    #2
    1. Advertising

  3. Matt Garrish wrote:

    >
    > require '/path/to/header/file/ipc.ph';
    >
    > Whatever compilation problems you're having likely have nothing to do with
    > requiring the ph file, though, and everything to do with the code in that
    > file. Without a specific error message and code, however, it's hard to say
    > anything more useful than that.
    >


    Thanks for your help. Since /path/to/header was already in my @INC, I
    just specified require "file/ipc.ph" and that did the trick - sort of.
    Now it whines that it cannot find "features.ph," mentioned on line 5 of
    ipc.ph. This file does not exist on my system leading me to believe
    that I must compile or install something in order to create it. Any
    ideas what that may be?

    Thanks,

    --
    Gerald
     
    Gerald Meazell, Dec 29, 2004
    #3
  4. Gerald Meazell

    Matt Garrish Guest

    "Gerald Meazell" <> wrote in message
    news:zlGAd.4153$...
    > Matt Garrish wrote:
    >
    >>
    >> require '/path/to/header/file/ipc.ph';
    >>
    >> Whatever compilation problems you're having likely have nothing to do
    >> with requiring the ph file, though, and everything to do with the code in
    >> that file. Without a specific error message and code, however, it's hard
    >> to say anything more useful than that.
    >>

    >
    > Thanks for your help. Since /path/to/header was already in my @INC, I
    > just specified require "file/ipc.ph" and that did the trick - sort of. Now
    > it whines that it cannot find "features.ph," mentioned on line 5 of
    > ipc.ph. This file does not exist on my system leading me to believe that
    > I must compile or install something in order to create it. Any ideas what
    > that may be?
    >


    Sorry, I have no idea what ipc.ph is or where you found it. If this is a
    script you downloaded off the web, you should probably start wherever you
    found it.

    All I can tell you is that the ph extension is normally only used when
    converting C header files to perl. If you're trying to port a C program you
    probably have to convert features.h as well (see h2ph). If you're using a
    program someone else converted then you'll need to find those missing header
    files wherever you found this one.

    Matt
     
    Matt Garrish, Dec 30, 2004
    #4
  5. Matt Garrish wrote:

    > Sorry, I have no idea what ipc.ph is or where you found it. If this is a
    > script you downloaded off the web, you should probably start wherever you
    > found it.
    >
    > All I can tell you is that the ph extension is normally only used when
    > converting C header files to perl. If you're trying to port a C program you
    > probably have to convert features.h as well (see h2ph). If you're using a
    > program someone else converted then you'll need to find those missing header
    > files wherever you found this one.


    Remember, I'm a newbie. I didn't download squat. The files where
    installed on my computer when I installed RedHat.However, you helped me
    by forcing me to realize that h2ph is used to convert C header files to
    perl header files so I just converted whatever files it said it was
    missing. Thanks!

    However, although they now run, the little sample programs I downloaded
    off the internet do not run properly so I am still in the dark as to how
    to implement semaphores in Perl. Googling "Perl And Semaphore" returns
    reams of information but nothing really useful to someone like me.

    I'm not doing fancy thread synchronization. I just want one process to
    create a semaphore, do its business, and release the semaphore and for a
    second process to wait for that semaphore's release before doing it's
    business. Is that so difficult?

    I guess there's less elegant ways of doing this. For example, I could
    have the first process create a file when it's done and the second
    process wait around for that file. I suppose that's what I'll end up
    doing but I'll hang my head in shame every time I think about it. :)

    --
    Gerald
     
    Gerald Meazell, Dec 30, 2004
    #5
  6. Gerald Meazell

    Thomas Kratz Guest

    Gerald Meazell wrote:
    > Matt Garrish wrote:
    >
    >> Sorry, I have no idea what ipc.ph is or where you found it. If this is
    >> a script you downloaded off the web, you should probably start
    >> wherever you found it.
    >>
    >> All I can tell you is that the ph extension is normally only used when
    >> converting C header files to perl. If you're trying to port a C
    >> program you probably have to convert features.h as well (see h2ph). If
    >> you're using a program someone else converted then you'll need to find
    >> those missing header files wherever you found this one.

    >
    >
    > Remember, I'm a newbie. I didn't download squat. The files where
    > installed on my computer when I installed RedHat.However, you helped me
    > by forcing me to realize that h2ph is used to convert C header files to
    > perl header files so I just converted whatever files it said it was
    > missing. Thanks!
    >
    > However, although they now run, the little sample programs I downloaded
    > off the internet do not run properly so I am still in the dark as to how
    > to implement semaphores in Perl. Googling "Perl And Semaphore" returns
    > reams of information but nothing really useful to someone like me.


    Did you do the obvious and look at:

    http://search.cpan.org/search?query=semaphore&mode=all ?

    Thomas


    --
    $/=$,,$_=<DATA>,s,(.*),$1,see;__END__
    s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
    $_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
    '%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
    print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
     
    Thomas Kratz, Dec 30, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fuma
    Replies:
    0
    Views:
    2,831
  2. Kevin McMurtrie

    POSIX semaphores in JNI?

    Kevin McMurtrie, Jul 24, 2004, in forum: Java
    Replies:
    1
    Views:
    924
    Stefan Poehn
    Jul 26, 2004
  3. Jeremy

    Python Threads and C Semaphores

    Jeremy, Jan 16, 2007, in forum: Python
    Replies:
    2
    Views:
    430
    Andrew MacIntyre
    Jan 16, 2007
  4. lnenov
    Replies:
    1
    Views:
    237
    Alain Ketterlin
    Dec 6, 2010
  5. Pete
    Replies:
    10
    Views:
    214
    Nobuyoshi Nakada
    May 17, 2007
Loading...

Share This Page