generating perl code from awk

Discussion in 'Perl Misc' started by Farhat Habib, Jul 12, 2006.

  1. Farhat Habib

    Farhat Habib Guest

    Hi,

    I have rather simple awk script which I would like to convert to Perl. I
    am using a2p but unfortunately it gives me a syntax error.

    ----
    syntax error in file tntvenn.awk at line 22
    Translation aborted due to syntax errors.
    ----


    for ( char in chars )
    { common = 1 ; out = ""
    for ( name in names )
    => if ( (name,char) in data )
    out = out char ": " data[name,char] "\n"
    else
    common = 0
    if ( common )
    print out
    }
    }

    Line 22 is the line starting with =>

    Any clues as to what's problem?

    Thanks,
    -F
    Farhat Habib, Jul 12, 2006
    #1
    1. Advertising

  2. Farhat Habib

    -berlin.de Guest

    Farhat Habib <> wrote in comp.lang.perl.misc:
    > Hi,
    >
    > I have rather simple awk script which I would like to convert to Perl. I
    > am using a2p but unfortunately it gives me a syntax error.
    >
    > ----
    > syntax error in file tntvenn.awk at line 22
    > Translation aborted due to syntax errors.
    > ----
    >
    >
    > for ( char in chars )
    > { common = 1 ; out = ""
    > for ( name in names )
    > => if ( (name,char) in data )
    > out = out char ": " data[name,char] "\n"
    > else
    > common = 0
    > if ( common )
    > print out
    > }
    > }
    >
    > Line 22 is the line starting with =>


    That is incorrect awk code. The "in" keyword is only valid in a "for"
    statement, not with "if".

    Anno
    -berlin.de, Jul 12, 2006
    #2
    1. Advertising

  3. Farhat Habib

    Farhat Habib Guest

    -berlin.de wrote:
    > Farhat Habib <> wrote in comp.lang.perl.misc:
    >
    >>Hi,
    >>
    >>I have rather simple awk script which I would like to convert to Perl. I
    >>am using a2p but unfortunately it gives me a syntax error.
    >>
    >>----
    >>syntax error in file tntvenn.awk at line 22
    >>Translation aborted due to syntax errors.
    >>----
    >>
    >>
    >> for ( char in chars )
    >> { common = 1 ; out = ""
    >> for ( name in names )
    >>=> if ( (name,char) in data )
    >> out = out char ": " data[name,char] "\n"
    >> else
    >> common = 0
    >> if ( common )
    >> print out
    >> }
    >>}
    >>
    >>Line 22 is the line starting with =>

    >
    >
    > That is incorrect awk code. The "in" keyword is only valid in a "for"
    > statement, not with "if".
    >


    It seems to work with GNU awk. Is there a replacement for this that
    would work with a2p?

    Thanks,

    -F
    Farhat Habib, Jul 12, 2006
    #3
  4. Farhat Habib

    -berlin.de Guest

    Farhat Habib <> wrote in comp.lang.perl.misc:
    > -berlin.de wrote:
    > > Farhat Habib <> wrote in comp.lang.perl.misc:
    > >
    > >>Hi,
    > >>
    > >>I have rather simple awk script which I would like to convert to Perl. I
    > >>am using a2p but unfortunately it gives me a syntax error.


    [...]

    > > That is incorrect awk code. The "in" keyword is only valid in a "for"
    > > statement, not with "if".
    > >

    >
    > It seems to work with GNU awk. Is there a replacement for this that
    > would work with a2p?


    Good question, wrong newsgroup.

    Anno
    -berlin.de, Jul 12, 2006
    #4
    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. NNTP

    sed awk or perl for this?

    NNTP, Sep 11, 2003, in forum: Perl
    Replies:
    13
    Views:
    3,473
    Alan Connor
    Sep 30, 2003
  2. gorda
    Replies:
    2
    Views:
    542
    Andrew Shitov
    Oct 21, 2003
  3. Thorsten Gottschalk

    awk's NF in Perl

    Thorsten Gottschalk, Mar 5, 2004, in forum: Perl
    Replies:
    1
    Views:
    3,661
    Jim Gibson
    Mar 5, 2004
  4. NNTP
    Replies:
    2
    Views:
    943
    rakesh sharma
    Apr 7, 2004
  5. engineer

    Tool for perl script to awk

    engineer, Jun 14, 2004, in forum: Perl
    Replies:
    1
    Views:
    871
    Joe Smith
    Jun 14, 2004
Loading...

Share This Page