perl pattern matching

Discussion in 'Perl Misc' started by seema, Mar 12, 2005.

  1. seema

    seema Guest

    hi all,

    I am a fresher, learning the Perl programming.
    I have got a problem i just want to match old
    C style function definition,
    for example,
    void hiall()
    int k,j,l,m;
    char *dare;
    {
    //BODY OF THE FUNCTION
    }
    If such old C style function definition exists
    then i just need that function name. Hope somebody will
    help a chinless wonder like me

    Seema Rao
    seema, Mar 12, 2005
    #1
    1. Advertising

  2. seema

    Bob Walton Guest

    seema wrote:

    ....

    > I have got a problem i just want to match old
    > C style function definition,
    > for example,
    > void hiall()
    > int k,j,l,m;
    > char *dare;
    > {
    > //BODY OF THE FUNCTION
    > }
    > If such old C style function definition exists
    > then i just need that function name. Hope somebody will
    > help a chinless wonder like me
    >
    > Seema Rao


    Please read:

    perldoc perlsub

    In Perl, functions are "sub"'s, and variables are declared with
    "my". So it would go something like:

    use warnings;
    use strict;
    #...
    sub hiall{
    my $k,$j,$l,$m,$dare;
    #pick up incoming arguments if any from array @_
    #do stuff
    #return a value with the "return" statement, or
    #otherwise return the value of the last statement
    #executed
    }
    #...

    Note that the type of value a variable may hold is not defined
    ahead of time in Perl. Any variable may take on any valid value
    at any time during program execution (generally string, integer,
    floating point, filehandle, dirhandle, or reference, with
    automatic conversion).

    HTH.

    --
    Bob Walton
    Email: http://bwalton.com/cgi-bin/emailbob.pl
    Bob Walton, Mar 12, 2005
    #2
    1. Advertising

  3. seema

    Tim Heaney Guest

    Bob Walton <> writes:
    >
    > Please read:
    >
    > perldoc perlsub


    I could be wrong, but I think the OP wants to parse C with Perl, not
    duplicate C in Perl.

    If it were ANSI C, something like

    use C::Scan;
    $c = new C::Scan filename => 'seema.c';
    print $_->[1] foreach @{$c->get('parsed_fdecls')};

    would do it, but that doesn't work for K&R C.
    Tim Heaney, Mar 12, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. seema

    perl pattern matching

    seema, Mar 12, 2005, in forum: Perl
    Replies:
    1
    Views:
    737
    Bob Walton
    Mar 12, 2005
  2. Xah Lee
    Replies:
    9
    Views:
    863
    Chris Smith
    Feb 2, 2005
  3. Xah Lee
    Replies:
    4
    Views:
    610
    Aaron Sherman
    Feb 11, 2005
  4. Marc Bissonnette

    Pattern matching : not matching problem

    Marc Bissonnette, Jan 8, 2004, in forum: Perl Misc
    Replies:
    9
    Views:
    231
    Marc Bissonnette
    Jan 13, 2004
  5. Bobby Chamness
    Replies:
    2
    Views:
    225
    Xicheng Jia
    May 3, 2007
Loading...

Share This Page