Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-20-2004, 12:38 PM   #1
LQ Newbie
Registered: Sep 2004
Posts: 11

Rep: Reputation: 0
Issues calling sort from perl using pipe as delimiter

I'm trying sort a file by calling the sort program from w/in Perl.

The issue is that I want to sort on given columns, and my delimiter is the pipe. I can't get the pipe to take.

I've tried:

system("sort -t\| -2 +3 $OUTPUT_DIR/file.txt > OUTPUT_DIR/");


system('sort -t\| -2 +3 $OUTPUT_DIR/file.txt > OUTPUT_DIR/');

Neither seems to work. I've done this in the past with underscores as delimiters, but not w/pipe... worked fine! I really want to avoid doing a hack, changing the given pipe to a more suitable character before I call the sort. I know this can be done, I'm just lost in the syntax. Perhaps something from the perlop would help?
Old 10-20-2004, 10:35 PM   #2
Registered: Apr 2004
Distribution: Dapper
Posts: 167

Rep: Reputation: 31
system("sort -t\| -2 +3 $OUTPUT_DIR/file.txt > OUTPUT_DIR/");
Shouldn't this be
system("sort -t\| -2 +3 $OUTPUT_DIR/file.txt > $OUTPUT_DIR/");
Other than that, I don't see any reason it shouldn't work, unless it's trying to extend your variables beyond their bounds. For example, one time I needed to use ...$var_300... and it assumed my variable wasn't $var but $var_300.

If this happens, this is sort of a hack to get around that.
$tosystem = "sort -t\| -2 +3 " + $OUTPUT_DIR + "/file.txt > " + $OUTPUT_DIR + "/";


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling KDE/C++ functions from python/perl and vice versa yogeshm02 Programming 1 04-30-2005 12:54 PM
calling a c++ binary inside a perl script Blue_muppet Programming 3 08-29-2004 12:31 AM
Hash-sort like in PERL in C++ nyk Programming 4 06-11-2004 09:40 AM
2 Questions: java calling system commands? PERL vs Java? randomx Programming 28 11-28-2003 09:24 PM
calling subs from within Perl bickford Programming 8 08-13-2000 08:10 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:00 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration