Perl

Moderators: Jonathan
Number of threads: 1259
Number of posts: 3644

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
execute Posted by generalen on 19 Oct 2004 at 1:39 PM
Hi there! Iam on my task with my shell...

At this time I have written exactly this code :

#!/usr/bin/perl -w

print $ENV{'HOMEPATH'};
print ">";
chomp($newdir = <stdin>);
chdir($newdir) ||
die "cannot chdir to $newdir: $!";
opendir(DOT, ".") ||
die "cannot open dir . $!";
foreach (sort readdir(DOT)) {
print "$_\n";
}
closedir (DOT);


the program starts in my home catalog..I also can list the directories in my system. But if I want to execute one of my program how I do then??

Iam a complete noob the programming so easy answers are appreciated =)

/ Thanks
Report
Re: execute Posted by Jonathan on 19 Oct 2004 at 4:21 PM
: Hi there! Iam on my task with my shell...
:
: At this time I have written exactly this code :
:
: #!/usr/bin/perl -w
:
: print $ENV{'HOMEPATH'};
: print ">";
: chomp($newdir = <stdin>);
: chdir($newdir) ||
: die "cannot chdir to $newdir: $!";
: opendir(DOT, ".") ||
: die "cannot open dir . $!";
: foreach (sort readdir(DOT)) {
: print "$_\n";
: }
: closedir (DOT);
:
:
: the program starts in my home catalog..I also can list the directories
: in my system. But if I want to execute one of my program how I do
: then??
:
Do you mean execute another program from your script? There are a few ways.

The easy way if you want to collect the output of the program is to use backticks:-

$result = `ping 127.0.0.1`;

Alternatively, you can use system to run the program, which is probably what you'll want to do.

system('ping 127.0.0.1');

: Iam a complete noob the programming so easy answers are appreciated =)
:
Just yell if I say something you don't understand. I've been doing this for quite a while and it's easy to forget what is and isn't obvious.

Jonathan

###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.