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