comp.lang.perl.misc
  Home FAQ Contact Sign in
comp.lang.perl.misc only
 
Advanced search
April 2008
motuwethfrsasuw
 123456 14
78910111213 15
14151617181920 16
21222324252627 17
282930     18
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.perl.misc Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  FAQ 8.26 Why doesn't open() return an error when a pipe open fails?         


Author: PerlFAQ Server
Date: Apr 6, 2008 18:03

This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

8.26: Why doesn't open() return an error when a pipe open fails?

If the second argument to a piped open() contains shell metacharacters,
perl fork()s, then exec()s a shell to decode the metacharacters and
eventually run the desired program. If the program couldn't be run, it's
the shell that gets the message, not Perl. All your Perl program can
find out is whether the shell itself could be successfully started. You
can still capture the shell's STDERR and check it for error messages.
See "How can I capture STDERR from an external command?" elsewhere in
this document, or use the IPC::Open3 module.

If there are no shell metacharacters in the argument of open(), Perl
runs the command directly, without using the shell, and can correctly
report whether the command started.

--------------------------------------------------------------------
Show full article (1.79Kb)
no comments
  FAQ 8.33 Is there a way to hide perl's command line from programs such as "ps"?         


Author: PerlFAQ Server
Date: Apr 6, 2008 12:03

This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

8.33: Is there a way to hide perl's command line from programs such as "ps"?

First of all note that if you're doing this for security reasons (to
avoid people seeing passwords, for example) then you should rewrite your
program so that critical information is never given as an argument.
Hiding the arguments won't make your program completely secure.

To actually alter the visible command line, you can assign to the
variable $0 as documented in perlvar. This won't work on all operating
systems, though. Daemon programs like sendmail place their state there,
as in:

$0 = "orcus [accepting connections]";

--------------------------------------------------------------------
Show full article (1.62Kb)
no comments
  Graph, Math and Stats Online Software         


Author: Dexter
Date: Apr 6, 2008 10:46

have designed and developed Graphing tools and Math/Stats online
software that is available on internet. Most of my visitor are from US
academia. The list of programs include the following

1. Graphing Rectangular 2D
2. Graphing Rectangular 3D
3. Graphing Polar
4. Graphing 2D Parametric curves
5. Graphing 3D Parametric curves
6. Graphing 3D Parametric surfaces
Show full article (0.99Kb)
1 Comment
  can the script find itself?         


Author: fossildoc
Date: Apr 6, 2008 08:53

I'm running build 813 on 'doze XP/Home. I want my Perl script to
determine the directory from which it was run. This is equivalent to
retrieving the command line. For example, from a DOS window I type:
>\perl\bin\perl c:\mydir\myscript.pl
I want the script to be able to retrieve the string "c:\mydir".

There is a Win32 function, Find, that can look for files, but it only
searches the INC directories, so it is not reliable.

Any ideas, please.
3 Comments
  FAQ 8.27 What's wrong with using backticks in a void context?         


Author: PerlFAQ Server
Date: Apr 6, 2008 06:03

This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

8.27: What's wrong with using backticks in a void context?

Strictly speaking, nothing. Stylistically speaking, it's not a good way
to write maintainable code. Perl has several operators for running
external commands. Backticks are one; they collect the output from the
command for use in your program. The "system" function is another; it
doesn't do this.

Writing backticks in your program sends a clear message to the readers
of your code that you wanted to collect the output of the command. Why
send a clear message that isn't true?

Consider this line:

`cat /etc/termcap`;

You forgot to check $? to see whether the program even ran correctly.
Even if you wrote
Show full article (2.18Kb)
no comments
  FAQ 8.39 How do I set CPU limits?         


Author: PerlFAQ Server
Date: Apr 6, 2008 00:03

This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

8.39: How do I set CPU limits?

(contributed by Xho)

Use the "BSD::Resource" module from CPAN. As an example:

use BSD::Resource;
setrlimit(RLIMIT_CPU,10,20) or die $!;

This sets the soft and hard limits to 10 and 20 seconds, respectively.
After 10 seconds of time spent running on the CPU (not "wall" time), the
process will be sent a signal (XCPU on some systems) which, if not
trapped, will cause the process to terminate. If that signal is trapped,
then after 10 more seconds (20 seconds in total) the process will be
killed with a non-trappable signal.

See the "BSD::Resource" and your systems documentation for the gory
details.
Show full article (1.68Kb)
no comments