B
Binand Sethumadhavan
Hi All,
I am writing a program which:
- creates a temporary file using File::Temp
- opens the file in an external editor
- processes the data the user enters in the file
(sort of like "cvs commit" - it opens a /bin/vi buffer where you can
enter the commit log).
I cannot figure out how to get the text typed in the buffer, back in my
perl code. Here is what I'm doing at the moment:
$prefix = "/tmp";
$cmd = "/bin/vi";
use File::Temp qw/tempfile/;
($fh, $filename) = tempfile(DIR => $prefix, UNLINK => 1);
print $fh <<EOF;
[some pre-filled information here]
EOF
$mtime1 = (stat($filename))[9];
system ("$cmd $filename");
$mtime2 = (stat($filename))[9];
if ($mtime2 - $mtime1 > 0) {
# Process the contents of $filename here
}
What I am doing at the moment is @cmdbuf = `cat $filename`; so that I
can continue with the rest of my code, but I'd like to know how to do it
better.
I hope this is not a faq.
Binand
I am writing a program which:
- creates a temporary file using File::Temp
- opens the file in an external editor
- processes the data the user enters in the file
(sort of like "cvs commit" - it opens a /bin/vi buffer where you can
enter the commit log).
I cannot figure out how to get the text typed in the buffer, back in my
perl code. Here is what I'm doing at the moment:
$prefix = "/tmp";
$cmd = "/bin/vi";
use File::Temp qw/tempfile/;
($fh, $filename) = tempfile(DIR => $prefix, UNLINK => 1);
print $fh <<EOF;
[some pre-filled information here]
EOF
$mtime1 = (stat($filename))[9];
system ("$cmd $filename");
$mtime2 = (stat($filename))[9];
if ($mtime2 - $mtime1 > 0) {
# Process the contents of $filename here
}
What I am doing at the moment is @cmdbuf = `cat $filename`; so that I
can continue with the rest of my code, but I'd like to know how to do it
better.
I hope this is not a faq.
Binand