Re^2: redirect output from a command to another command
by Allasso (Monk) on Mar 02, 2011 at 15:33 UTC
|
bummer...
I wanted to avoid writing stuff to disk, as I will be making large numbers of calls to diff and comparing very short strings.
It would get pretty expensive to make so many round trips to the hard drive for such a small file. | [reply] |
|
|
I would think launching diff would be relatively expensive.
The disk cache should eliminate all disk wait for small files.
Have you considered Algorithm::Diff?
| [reply] [d/l] |
|
|
Yes, I thought about that, but I have not been inclined toward the use of Cpan modules. For one, I lose portability. Also, in the past whenever I looked into using one (can't remember which ones now) I always got discouraged by the lack of simple documentation, and instruction on how to implement. All I could ever find was scraps of this and that.
EDIT: Though I must say, the Cpan page on diff is the best I've seen.
| [reply] |
|
|
|
|
|
|
|
| [reply] |
|
|
|
|
|
|
Allasso:
If you write to the file, and then use and delete it shortly thereafter, it may not even get written to the disk at all. It may simply reside in memory buffers. So don't be afraid of short-term temporary files. They can even be handy debugging tools--just comment out the delete, so you can see what the intermediate results were in an operation.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
| [reply] |
|
|
yes, by the results I was seeing, I had a feeling that that was what was happening, ie, they weren't even going to disk. I was getting caught in the paradigm that only variables resided in memory.
Another paradigm that I am wondering if it is fallacious is that calling a system command is more expensive than using a module. Is there really a (significant) difference between forking a process and executing code that is written in from a module? If there is a slight cost to forking, it doesn't seem like it would be that significant. Some one enlighten me.
Anyway, looking at the results of my tests, it is hard to convince me that there is anything to be gained by using Algorithm::Diff, as far as speed goes. Portability, perhaps, as some have pointed out.
| [reply] |
Re^2: redirect output from a command to another command
by Allasso (Monk) on Mar 02, 2011 at 15:48 UTC
|
what version of bash are you using? | [reply] |
|
|
I have no idea. Whatever came with the OS.
| [reply] |
Re^2: redirect output from a command to another command
by ikegami (Patriarch) on Mar 02, 2011 at 17:23 UTC
|
Your bash appears to be configured (built) incorrectly. It can be configured to use a different path, or not use that system at all. | [reply] |
|
|
Then it was incorrectly configured by the OS vendor.
But in any case, even if all bash users were to upgrade to the latest and greatest bleeding edge version, and spend hours tweaking obscure configuration options, that solution still wouldn't be portable, as it doesn't work in some other shells.
| [reply] |
|
|
It has nothing to do with the shell. No shell is used by the Perl code I used. It's an OS feature.
And yes, it wouldn't be portable to other OSes (or differently setup OSes, based on your experience). I didn't mean to imply otherwise.
| [reply] |
|
|
|
|
|
Re^2: redirect output from a command to another command
by Tommy (Chaplain) on Mar 03, 2011 at 16:58 UTC
|
Said bashism works for me -- running ubuntu 10.04 LTS, or Debian 5
STILL... I like IPC::Open2 for things like this.
| [reply] |
|
|
open2 does not provide any assistance in passing pipes to a child that expects file names.
| [reply] |