Recent Notes
Displaying keyword search results 1 - 3
Created by Dr. Xi on December 05, 2009 20:12:16
Last update: December 05, 2009 20:46:45
It's quite easy for Perl to open a pipe and read from it:
$file = "nospace.txt";
open(IN, "cat $file |") ...
But the code breaks when the file name contains a space:
# This does not work!
$file = "yes space.txt";
...
On Windows, these don't work either:
# This does not work!
$file = "yes space.txt";
...
You need to use a technique called Safe Pipe Opens :
$file = "yes space.txt";
$prog = "cat";
...
Created by Dr. Xi on December 04, 2009 04:33:05
Last update: December 04, 2009 04:33:05
Variable Meaning $_ The default or implicit variable. @_ Within a subroutine the array @_ contains the parameters passed to that subroutine. $a, $b Special package variables when using sort() $<digit> Contains the subpattern from the corresponding set of capturing parentheses from the last pattern match, not counting patterns matched in nested blocks that have been exited already. $. Current line number for the last filehandle accessed. $/ The input record separator, newline by default. $| If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; $| tells you only whether you've asked Perl explicitly to flush after...
Created by Dr. Xi on May 29, 2007 03:48:01
Last update: May 29, 2007 03:49:54
The following applies to Bourne, Korn and Bash:
$var or ${var} Replaced by the value of var . Use braces to avoid ambiguity.
${var-value} Use the value of var if set, use value otherwise.
${var+value} Use the value of value if var is set, use nothing otherwise.
${var=value} Use the value of var if set, other wise, use value and assign value to var .
${var?value} Use the value of var ; otherwise, print value to standard error and exit the current shell. If value is omitted, a standard error message is printed instead.