perl as awk replacement in a script.

Hey all, Im trying to write a script on windows, which Im not too familiar with. Im generally a bash scripting guy but am using perl for this case.

My question is...

I have this exact output:

               2 Dir(s)   6,380,429,312 bytes free

and I just need to get the number out of that line. So, in unix I would just use `awk '{print $3}' filename.txt` but thats not an option in this case... is see many one line examples for perl, but none work which I assume is due to the whitepaces. and ontop of that I cant figure out how to take those one line statements and put them into a script :confused:

here is all I have got so far (its not much :o ).

$dirinfo = `dir | find "bytes free"`;
open diskinfo, ">diskinfo.txt";
print diskinfo $dirinfo;
close diskinfo;

This is a Windows question; why are you not asking it in a Windows forum?

because it is a perl question.

Echo your awk line through a2p to convert to perl....

$ echo '{print $3}' | a2p
#!/usr/bin/perl5.8.8
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
    if $running_under_some_shell;
                        # this emulates #! processing on NIH machines.
                        # (remove #! line above if indigestible)

eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;
                        # process any FOO=bar switches

$, = ' ';               # set output field separator
$\ = "\n";              # set output record separator

while (<>) {
    ($Fld1,$Fld2,$Fld3) = split(' ', $_, -1);
    print $Fld3;
}

ohh, I did not even know about a2p just looked it up. I should be able to figure this out now. Thanks!

Thanks!