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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Problem with awk
by DamnDirtyApe (Curate) on Aug 14, 2002 at 20:52 UTC

    How about dropping the calls to ls and gawk, and getting the list of files to iterate over in Perl?

    opendir DH, '.' or die "Couldn't open dir: $!" ; my @files = sort { $a cmp $b } map { ( split /\./ )[0] } grep { /\.pdl$/ } readdir DH ; close DH ;

    _______________
    DamnDirtyApe
    Those who know that they are profound strive for clarity. Those who
    would like to seem profound to the crowd strive for obscurity.
                --Friedrich Nietzsche
      Or maybe even
      opendir DH, '.' or die "Couldn't open dir: $!" ; my @files = sort { $a cmp $b } map /^([^.]*).*\.pdl$/, readdir DH ; close DH;
      Non-matches automatically disappear from the results of a map /(reg)ex/, @list

      Makeshifts last the longest.

Re: Problem with awk
by belg4mit (Prior) on Aug 14, 2002 at 20:46 UTC
    Why do you need awk to extract columns and split? Simply do your own glob-bing and use tr within perl.

    --
    perl -pew "s/\b;([mnst])/'$1/g"

Re: Problem with awk
by FoxtrotUniform (Prior) on Aug 14, 2002 at 20:58 UTC
    foreach my $PDL (split/\s+/,`ls *.pdl | tr '.' ' ' | gawk '{print $1}' +`)

    $1 is being interpolated into the backticked string.

    --
    F o x t r o t U n i f o r m
    Found a typo in this node? /msg me
    The hell with paco, vote for Erudil!

      thanks all :) thats really help