Find the answer to your Linux question:
Results 1 to 2 of 2
The script : #!/usr/bin/perl $index = `egrep '(function|procedure)' *.p | gawk '{print $1}' `; print $index; The script output : conv.p:function isdigit(c : character) : boolean; conv.p:function itoc( n : ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2005
    Posts
    1

    [Perl] Quoting(shell interpolation,(``))


    The script :
    #!/usr/bin/perl

    $index = `egrep '(function|procedure)' *.p | gawk '{print $1}' `;

    print $index;
    The script output :
    conv.p:function isdigit(c : character) : boolean;
    conv.p:function itoc( n : integer; var s : string; i:integer) : integer;
    conv.p:function ctoi(var s : string;var i : integer) : integer;
    conv.procedure putdec(n,w:integer);
    stdio.p:function getc(var c : character) : character;
    stdio.procedure putc(c : character);
    The desired output:
    conv.p:function
    conv.p:function
    conv.p:function
    conv.procedure
    stdio.p:function
    stdio.procedure
    The Konsole gets it right (egrep '(function|procedure)' *.p | gawk '{print $1}' ), but perl it seems, doesn't run the gawk part.

  2. #2
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Why are you using perl to do this when a simple shell script would work? Perl's for the complicated stuff that shells can't handle!
    If you're going to use perl for this, you'be better off processing the input within perl rather than just having perl run a shell for you.

    To answer your question, it seems to me that perl may be treating gawk's "$1" as a perl variable (although the single quotes ought to preclude that), resulting in the gawk command being just a print with no arguments.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •