Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: chomp it chomp it good

by sflitman (Hermit)
on Jun 03, 2009 at 05:26 UTC ( [id://767892]=note: print w/replies, xml ) Need Help??


in reply to chomp it chomp it good

It uses Magic.

If you check the perl source, you'll see that it is implemented as Perl_do_chomp in doop.c and it takes a pointer to an SV (which is fed to it from the top of the stack down since chomp can take multiple arguments) and that pointer is the C equivalent of a reference.

St. Larry be praised, there is much magic to make our lives easier in Perl.

HTH,
SSF

Replies are listed 'Best First'.
Re^2: chomp it chomp it good
by perlsaran (Sexton) on Jun 03, 2009 at 09:22 UTC
    It will be great if you can post the code snippet of the c code..
      Here's an analogy:
      my $bar = 41; foo($bar); print $bar; use Inline C => <<'EOC'; void foo(SV* bar) { int b = (int)SvIV(bar); b++; sv_setiv(bar,b); } EOC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-24 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found