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

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: shell prob
by jettero (Monsignor) on Dec 27, 2006 at 13:33 UTC
Re: shell prob
by SheridanCat (Pilgrim) on Dec 27, 2006 at 13:38 UTC
    This is the third time you've asked your question. You've gotten the answer, but you seem not to be understanding it. Might I suggest you post the code from both scripts so we can see what you're trying to do in context?

    You seem to think you can just call awk from your Perl script, and that isn't going to work.

      This is the third time you've asked your question.

      I hadn't noticed. Now I do. Which reminds me yet another one of my .sigs (it's in Italian, but I'm translating it into English now, and I don't know where it's quoted from), namely:

      Repeating a foolish thing a large number of times doesn't
      make it a pearl of wisdom.
      It only becomes a tiresome foolish thing.

      (With not particular offense to the OP intended, and a better phrasing welcome.)

Re: shell prob
by roboticus (Chancellor) on Dec 27, 2006 at 15:32 UTC
    vineet2004:

    I don't know what shell you're using, but that's not valid syntax for the bash shell. Nor is it valid syntax for Perl. It looks like you're confusing Perl and shell scripting, trying to mix them together to make something.

    --roboticus

Re: shell prob
by blazar (Canon) on Dec 27, 2006 at 16:20 UTC
    hi monks i want to pass a file name generated by a shell script to another one ... the shell script program i want to pipe my filename into ..looks like this

    And why do you want to use Perl to do so? In shell (well, at least in bash - which I'm familiar with) you just use stuff like script2 $(script1). (You can also use backticks, but I just don't like them, and $() has the advantage of allowing nesting.)

    while (my $var = <STDIN>) awk -f work_5messages.awk $var

    This is neither Perl nor shell, although it slightly resembles both. In Perl this could be

    while (my $var = <STDIN>) { chomp $var; system 'awk', -f => 'work_5messages.awk', $var and die "D'Oh! (Do better error checking!!)"; }

    and in (ba)sh,

    while read var; do awk -f work_5messages.awk "$var"; done

    OTOH...

    syntax error near unexpected token `)' `while (my $var = <STDIN>) '

    This looks like a shell error. You should clarify what you're really after, to help us to help you.

Re: shell prob
by swampyankee (Parson) on Dec 27, 2006 at 17:19 UTC

    If all your Perl program is doing is calling an awk script, I would suggest you use a2p and convert work_5messages.awk to Perl. This may require some testing to make sure a2p did the right thing, however in the long run, it will probably be easier than trying to maintain two programs: the Perl wrapper and the awk script.

    emc

    At that time [1909] the chief engineer was almost always the chief test pilot as well. That had the fortunate result of eliminating poor engineering early in aviation.

    —Igor Sikorsky, reported in AOPA Pilot magazine February 2003.
Re: shell prob
by alpha (Scribe) on Dec 27, 2006 at 15:44 UTC
    You might try this: perl -e 'while (my $var = <STDIN>) {$run = "awk -f work_5messages.awk ".$var; `$run`;}'
      perl -e 'while (my $var = <STDIN>) {$run = "awk -f work_5messages.awk ".$var; `$run`;}'

      Apart that you don't need to create a temporary variable like that, and I don't see any particular advantage in doing so, any good reason to use backticks in void context?!? If you really want to stay minimal,

      chomp, system "awk -f work_5messages.awk $_" while <STDIN>;

      or (better)

      chomp, system qw/awk -f work_5messages.awk/, $_ while <STDIN>;

      But even better is to handle possible errors...