prat7434 has asked for the wisdom of the Perl Monks concerning the following question:

Please excuse me if I am posting irrelevant question. I wan to search the source code of PERL builtin functions e.g. "reverse" function(which reverses a list ot string). How can I see that on my machine or on web? I went to github repository of perl project but I ma unable to search that. Please help me.

Replies are listed 'Best First'.
Re: Perl built-in functions source code
by davido (Cardinal) on Feb 06, 2015 at 07:32 UTC
      Thanks a Lot. It helped!!
Re: Perl built-in functions source code
by Happy-the-monk (Canon) on Feb 06, 2015 at 07:19 UTC

    I don't know if the sources are available for reading and searching on the web, but they are available for downloading:

    Look for the current Perl source code here.

    Cheers, Sören

    Créateur des bugs mobiles - let loose once, run everywhere.
    (hooked on the Perl Programming language)

Re: Perl built-in functions source code
by salva (Canon) on Feb 06, 2015 at 07:44 UTC
    See pp_reverse in pp.c, line 5508.
Re: Perl built-in functions source code
by ikegami (Patriarch) on Feb 06, 2015 at 17:48 UTC

    Use perl -MO=Concise,-exec -e'...code...' to find the name of the operators into which your code compiles. Then grep the Perl source for pp_name.

    For example, you asked about reverse.

    $ perl -MO=Concise,-exec -e'@b = reverse @a' 1 <0> enter 2 <;> nextstate(main 1 -e:1) v:{ 3 <0> pushmark s 4 <0> pushmark s 5 <#> gv[*a] s 6 <1> rv2av[t4] lK/1 7 <@> reverse[t5] lK/1 <----------- 8 <0> pushmark s 9 <#> gv[*b] s a <1> rv2av[t2] lKRM*/1 b <2> aassign[t6] vKS c <@> leave[1 ref] vKP/REFC -e syntax OK $ grep -nR pp_reverse . ./lib/B/Deparse.pm:3130:sub pp_reverse { listop(@_, "reverse") } ./opcode.h:1143: Perl_pp_reverse, ./pp.c:5508:PP(pp_reverse) <----------- ./pp_proto.h:215:PERL_CALLCONV OP *Perl_pp_reverse(pTHX); $ perl -ne'print if 5508 .. /^}/' pp.c PP(pp_reverse) { dSP; dMARK; ... RETURN; }
Re: Perl built-in functions source code
by Anonymous Monk on Feb 06, 2015 at 07:49 UTC
    Interesting, what are you trying to learn? Do you speak C?
      I do know to read C, but not speak!! I did not know that code of core functions are written in C. Now I know. Are there any core functions which are written in Perl (some simpler functions!!).
        Perl is written in C. All of the operators ("core functions") are implemented in C.

        It was said that glob was written in Perl, but it's pp_glob in pp_sys.c. (*Sometimes*, this does result in Perl getting executed, but not always.)

        It was said that dbmopen was written in Perl, but it's pp_dbmopen in pp_sys.c. (Granted, this does result in Perl code getting executed.)

        There are many core and non-core modules written in Perl, but the functions in perlfunc are necessarily written in C.