Ed Mancebo wrote:
> I have a short perl script, it goes like this:
Shelling out to call "echo" is quite possibly the most horribly inefficient
way I can imagine to store $line in a file. But I'm assuming that this is
just a minimal example as suggested in the posting guidelines, so I'm
answering the question as given, rather than suggesting an entirely
different approach.
> #!/usr/bin/perl
use warnings;
use strict;
> $line = <STDIN>;
my $line = <STDIN>;
# Or, more simply:
my $line = <>;
> print $line;
> `echo $line > output`;
Store and print the results of that command - I think you'll find it
enlightening.
my $output = `echo $line > output`;
print $output;
Then, have a look at "perldoc -f chomp" to find out how to get rid of the
trailing newline in $line.
(BTW, if you really *are* using backticks and echo to write to a file, you
have a *lot* to learn. Have a look at "perldoc perlopentut".)
sherm--
--
Cocoa programming in Perl:
http://camelbones.sourceforge.net
Hire me! My resume:
http://www.dot-app.org