Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Using Inline::C in a package

by syphilis (Canon)
on Sep 05, 2013 at 12:26 UTC ( #1052556=note: print w/ replies, xml ) Need Help??


in reply to Using Inline::C in a package

cannot seem to figure out how to embed the C code in a perl package

Incidentally, you can have multiple packages in the one Inline::C script (just as you can with perl scripts):

package FOO; use Inline C => <<'EOC'; void hello() { printf("Hello from FOO\n"); } EOC package BAR; use Inline C => <<'EOC'; void hello() { printf("Hello from BAR\n"); } EOC package FUBAR; use Inline C => <<'EOC'; void hello() { printf("Hello from FUBAR\n"); } EOC FOO::hello(); BAR::hello(); FUBAR::hello(); hello();
Which outputs:
Hello from FOO Hello from BAR Hello from FUBAR Hello from FUBAR
Cheers,
Rob


Comment on Re: Using Inline::C in a package
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1052556]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2014-12-21 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (100 votes), past polls