Actually, that won't work. "." is the concatenation operator, and isn't part of a valid Perl identifier (variable name). Secondly, you're missing quotes on the right hand side of that assignment.
perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>);
+$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth
+er_name\n"'
| [reply] [d/l] |
this may also work... (very little difference from above)
system("cp","x.txt","$a_log.txt") && die("$!\n");
if you "use strict" then you do need to declare $a somewhere in the file before you use it. Somebody else said that $a is a special variable so try to use something more descriptive.
| [reply] [d/l] |
open(IN,"ls -l |");
my @IN = <IN>;
close IN
Worx! The @IN array contains output from the system commando "ls -l" giving the file listing.
Erik Østergaard | [reply] |
I think Mr. Østergaard meant this:
# Note -- bad way to do this
open(IN, "ls -l |");
my @IN = <IN>;
close(IN);
For a better way of getting directory contents, see perlfunc:opendir and perlfunc:readdir.
Which is a bit off-topic...
stephen
| [reply] [d/l] |
# $command can be any system command, that would produce an acceptable output
my $string = "my email is";
my $dir = "/home/erik/*";
my $command = "grep -ri '".$string."' ".$dir;
open(IN, $command." |");
my @IN = <IN>;
close(IN);
Better, Stephen? =) I agree, that opening dirs isn't the best purpose for this method.
Erik
| [reply] |