Warning: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in ..../includes/class_bbcode.php on line 2958

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Whoa, it's easy to trap signals in perl!
Page 1 of 6 123 ... LastLast
Results 1 to 10 of 52

Thread: Whoa, it's easy to trap signals in perl!

  1. #1

    Whoa, it's easy to trap signals in perl!



    I was pleasantly surprised

  2. #2
    Guest

    Re: Whoa, it's easy to trap signals in perl!

    why do you do:
    Code:
    while (1==1)
    ?

    Why not just while (1) ? or while (true)?

  3. #3

    Re: Whoa, it's easy to trap signals in perl!

    Why not just while (1) ? or while (true)?
    Because I've been doing a lot of programming on my calculator lately, and any while loop conditions must be in the form of A=B where A and B are either variables or numbers. It never occured to me that I could do "while 1"...

    It doesn't matter, though, because it's still really easy to trap signals in perl

  4. #4
    Guest

    Re: Whoa, it's easy to trap signals in perl!

    J'ai patentÚ ša.

    Code:
    #!/usr/bin/env python
    
    import signal, time, os
    
    def got_sig(*args):
     print "Hey! I got the %d signal!" % args[0]
    
    # You can also use numbers
    signal.signal(signal.SIGTERM, got_sig) 
    signal.signal(signal.SIGSEGV, got_sig)
    
    while 1:
     print "Good day for %d to be alive" % os.getpid()
     time.sleep(10) # I used this so that my CPU wasn't at 100%

  5. #5

    Re: Whoa, it's easy to trap signals in perl!

    I think it's funny that Python needs a whole function to find it's own PID

  6. #6
    Guest

    Re: Whoa, it's easy to trap signals in perl!

    I think it's just bright to seperate things into modules. *Since the PID is an os thing, might as well put it in the os module. *This just adds to the clarity of the whole program. Anyway, $$ is just an alias to a function.

  7. #7

    Re: Whoa, it's easy to trap signals in perl!


    I think it's funny that Python needs a whole function to find it's own PID
    '

    As does Perl. What do you think $$ does? I find it funny that in Python it's easy to see which commands are functions and in Perl you get magical little operators that perform functions when you may not realize it.

  8. #8

    Re: Whoa, it's easy to trap signals in perl!

    Anyway, $$ is just an alias to a function.
    How's that? The way I understand it is that $$ is a scalar variable, just like every other variable that starts with '$'. $$ stores the pid, $0 stores the name of the program, etc etc.

    If you really hate them, you can just use English; and then you get variables with actual names, but that slows down the script.

  9. #9
    Guest

    Re: Whoa, it's easy to trap signals in perl!




    How's that? The way I understand it is that $$ is a scalar variable, just like every other variable that starts with '$'. $$ stores the pid, $0 stores the name of the program, etc etc.
    I would guess ( I couldn't find anything in the source code, but the thing is so messed up I'm not surprised) that when perl starts, it calls functions (getpid, getuid, getgid, etc.) from a module (probably a C module) and stores these values in $ variables.

  10. #10

    Re: Whoa, it's easy to trap signals in perl!

    Oh well.

    You can't deny that $$ is more convenient to type than %d ... " % os.getpid().

Similar Threads

  1. SNMP Trap Broker service in Linux.
    By siddegok in forum Linux - Hardware, Networking & Security
    Replies: 1
    Last Post: 04-04-2006, 12:06 PM
  2. MOVED: trap 00000006 exception problem
    By trickster in forum Linux - General Topics
    Replies: 0
    Last Post: 04-23-2005, 09:13 PM
  3. Whoa! What The?
    By beezlebubsbum in forum General Chat
    Replies: 4
    Last Post: 02-15-2005, 11:30 PM
  4. Easy perl question
    By mcdougrs in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 01-11-2005, 08:25 PM
  5. Whoa, am I dreaming?
    By Feztaa in forum General Chat
    Replies: 49
    Last Post: 03-17-2002, 04:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •