AWK in Perl 
Author Message
 AWK in Perl

Hi,

    How can I write an awk command in a perl script. Since I do not know
what is wrong with the following script.

#!/usr/local/gnu/bin/perl -w
.....
$abc = 'awk \'{FS = \"|\"} {if ($7 == 105) print $1}\' xyz.txt';

Thanks



Tue, 10 Dec 2002 03:00:00 GMT  
 AWK in Perl

Quote:
>Hi,

>    How can I write an awk command in a perl script. Since I do not know
>what is wrong with the following script.

>#!/usr/local/gnu/bin/perl -w
>.....
>$abc = 'awk \'{FS = \"|\"} {if ($7 == 105) print $1}\' xyz.txt';

$'s should be escaped, since they're perl keychars. Just at a glance that
could{*filter*}up stuff.
Phil.


Tue, 10 Dec 2002 03:00:00 GMT  
 AWK in Perl

Quote:


> >Hi,

> >    How can I write an awk command in a perl script. Since I do not know
> >what is wrong with the following script.

> >#!/usr/local/gnu/bin/perl -w
> >.....
> >$abc = 'awk \'{FS = \"|\"} {if ($7 == 105) print $1}\' xyz.txt';

> $'s should be escaped, since they're perl keychars. Just at a glance that
> could{*filter*}up stuff.
> Phil.

When I use:
        $abc = 'awk \'{FS = \"|\"} {if (\$7 == 105) print \$1}\' xyz.txt';
        printf $abc;

I get:
        awk \'{FS = \"|\"} {if (\$7 == 105) print \$1}\' xyz.txt



Tue, 10 Dec 2002 03:00:00 GMT  
 AWK in Perl

   >Hi,
   >How can I write an awk command in a perl script. Since I do not know
   >what is wrong with the following script.
Why do you want to write awk commands in a perl script?  I don't know perl,
but I would bet that there are perl commands to do the same thing as that
awk command.  I wonder, does perl use `back ticks` like in shell scripts?

   >#!/usr/local/gnu/bin/perl -w
   >......
   >$abc = 'awk \'{FS = \"|\"} {if ($7 == 105) print $1}\' xyz.txt';
   >Thanks

Net-Tamer V 1.08X - Test Drive



Tue, 10 Dec 2002 03:00:00 GMT  
 AWK in Perl

Quote:


>    >Hi,
>    >How can I write an awk command in a perl script. Since I do not know
>    >what is wrong with the following script.
> Why do you want to write awk commands in a perl script?  I don't know
perl,
> but I would bet that there are perl commands to do the same thing as that

Perl can do everything that awk can...less elegantly, but more flexibly
I can't understand what the FS value should be? "|"?

Quote:
> awk command.  I wonder, does perl use `back ticks` like in shell scripts?

yes it does
Quote:

>    >#!/usr/local/gnu/bin/perl -w
>    >......
>    >$abc = 'awk \'{FS = \"|\"} {if ($7 == 105) print $1}\' xyz.txt';
>    >Thanks

> Net-Tamer V 1.08X - Test Drive



Wed, 11 Dec 2002 03:00:00 GMT  
 AWK in Perl


Quote:



>> >Hi,

>> >    How can I write an awk command in a perl script. Since I do not know
>> >what is wrong with the following script.

>> >#!/usr/local/gnu/bin/perl -w
>> >.....
>> >$abc = 'awk \'{FS = \"|\"} {if ($7 == 105) print $1}\' xyz.txt';

>> $'s should be escaped, since they're perl keychars. Just at a glance that
>> could{*filter*}up stuff.
>> Phil.

>When I use:
>        $abc = 'awk \'{FS = \"|\"} {if (\$7 == 105) print \$1}\' xyz.txt';
>        printf $abc;

>I get:
>        awk \'{FS = \"|\"} {if (\$7 == 105) print \$1}\' xyz.txt

Try using double quotes instead:

$abc = "awk \'{FS = \"|\"} {if (\$7 == 105) print \$1}\' xyz.txt";
printf $abc;

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.



Wed, 11 Dec 2002 03:00:00 GMT  
 AWK in Perl
Amr,

I have been trying to figure out exactly the same thing.  I have read these
replies with interest, did the back ticks work.  I am going to try a few
cominations, if I have any luck I will let you know.

Good Luck,

Steve

Quote:

>Hi,

>    How can I write an awk command in a perl script. Since I do not know
>what is wrong with the following script.

>#!/usr/local/gnu/bin/perl -w
>.....
>$abc = 'awk \'{FS = \"|\"} {if ($7 == 105) print $1}\' xyz.txt';

>Thanks



Tue, 24 Dec 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. AWK vs PERL - splitting fields

2. problem with awk in perl script

3. Wanted AWK To Perl Translater A2P.exe for cygnus/WIN32

4. awk with perl-style re?

5. Awk, SH, Perl -- Worth learning?

6. Awk vs Perl

7. Learn awk before perl?

8. awk to perl syntax errors

9. awk to perl

10. AWK vs Perl For Misc Data Processing Tasks

11. awk to perl problems

12. a2p awk-to-Perl question ...

 

 
Powered by phpBB® Forum Software