I wrote a script that's supposed to take several package names cd to that directory and run make clean install (for freebsd). The problem is with chdir(). Maybe someone can figure out why this is not doing what I thought it would.
[code]
#!/usr/bin/perl -w
use strict;
my($location, $exitstat, $file);
print "Enter filename: ";
chomp($file = );
open(FILE, $file) or die "Could not open $file $!
";
while () {
$location = `whereis $_`;
if (chdir($location) == 0) {
print "Unable to cd to $_";
next;
}
$exitstat = system("make clean install");
#next two lines were to
$exitstat /= 256;
#learn the exitstatus of
#the system function
}
[/code]
This gives me the if branch of chdir even if I set chdir($location) == 0) to chdir($location) == 1. I've tried quoting $location too.
Comments
: that directory and run make clean install (for freebsd). The problem
: is with chdir(). Maybe someone can figure out why this is not doing
: what I thought it would.
:
: [code]
: #!/usr/bin/perl -w
:
: use strict;
:
: my($location, $exitstat, $file);
:
: print "Enter filename: ";
: chomp($file = );
: open(FILE, $file) or die "Could not open $file $!
";
: while () {
: $location = `whereis $_`;
: if (chdir($location) == 0) {
: print "Unable to cd to $_";
: next;
: }
: $exitstat = system("make clean install"); #next two lines were to
: $exitstat /= 256; #learn the exitstatus of
: #the system function
: }
: [/code]
: This gives me the if branch of chdir even if I set chdir($location) ==
: 0) to chdir($location) == 1. I've tried quoting $location too.
:
The docs say that "It returns true upon success, false otherwise.", so it's not returning a number and therefore doing == (numerical compare) against it is dubious anyway. You can just do:-
if (chdir($location)) { ... }
Work?
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.");
: : I wrote a script that's supposed to take several package names cd to
: : that directory and run make clean install (for freebsd). The problem
: : is with chdir(). Maybe someone can figure out why this is not doing
: : what I thought it would.
: :
: : [code]
: : #!/usr/bin/perl -w
: :
: : use strict;
: :
: : my($location, $exitstat, $file);
: :
: : print "Enter filename: ";
: : chomp($file = );
: : open(FILE, $file) or die "Could not open $file $!
";
: : while () {
: : $location = `whereis $_`;
: : if (chdir($location) == 0) {
: : print "Unable to cd to $_";
: : next;
: : }
: : $exitstat = system("make clean install"); #next two lines were to
: : $exitstat /= 256; #learn the exitstatus of
: : #the system function
: : }
: : [/code]
: : This gives me the if branch of chdir even if I set chdir($location) ==
: : 0) to chdir($location) == 1. I've tried quoting $location too.
: :
: The docs say that "It returns true upon success, false otherwise.", so it's not returning a number and therefore doing == (numerical compare) against it is dubious anyway. You can just do:-
:
: if (chdir($location)) { ... }
:
: Work?
:
: 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.");
:
: