Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting with perl 1

Status
Not open for further replies.

inforeqd

Technical User
Jan 8, 2001
95
US
Heres the simple problem. I am using the perl open(IN,asfasf) and open(OUT,asfasf) to do just that. But what i need to do is add a unix sort -r to this before I do the print OUT. Does anyone have a quick and dirty answer to this. Additionally, any informatoin or examples of adding unix commands into perl would be helpful since the next step is to take this sorted output and do alot of awk things and greps.

TIA and i hope im not to vague in what im asking.
Inforeg
 
This is directly from :
perldoc File::Glob

NAME
File::Glob - Perl extension for BSD glob routine

SYNOPSIS
use File::Glob ':glob';
@list = glob('*.[ch]');
$homedir = glob('~gnat', GLOB_TILDE | GLOB_ERR);
if (GLOB_ERROR) {
# an error occurred reading $homedir
}

## override the core glob (core glob() does this automatically
## by default anyway, since v5.6.0)
use File::Glob ':globally';
my @sources = <*.{c,h,y}>

## override the core glob, forcing case sensitivity
use File::Glob qw:)globally :case);
my @sources = <*.{c,h,y}>

## override the core glob forcing case insensitivity
use File::Glob qw:)globally :nocase);
my @sources = <*.{c,h,y}>
File::Glob implements the FreeBSD glob(3) routine, which
is a superset of the POSIX glob() (described in IEEE Std
1003.2 &quot;POSIX.2&quot;). The glob() routine takes a mandatory
`pattern' argument, and an optional `flags' argument, and
returns a list of filenames matching the pattern, with
interpretation of the pattern modified by the `flags'
variable. The POSIX defined flags are:

`GLOB_ERR'
Force glob() to return an error when it encounters a
directory it cannot open or read. Ordinarily glob()
continues to find matches.

`GLOB_MARK'
Each pathname that is a directory that matches the
pattern has a slash appended.

`GLOB_NOCASE'
By default, file names are assumed to be case
sensitive; this flag makes glob() treat case
differences as not significant.



Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
Wow, Thanks for the reply I will add this to my notes. However, I should have recalled that post because right after i posted the information I figured out how to do it.

Thanks anyhow, your response is greatly appreciated.

Once again this board proves its worth, not only in solutions, but in making a person think.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top