Hacking Thy Fearful Symmetry

Hacker, hacker coding bright

Embperl 2.0 chdir quirkiness

September 14, 2006
perl embperl

ah AH! It took me almost one year, but I finally got the sucker!

In the PerlWar web interface, I have this Embperl upload page. Except that ever since its conception, the little devil fails something like once every five times, without any visible reason.

Well, the reason, it turns out, is that Embperl 2 doesn't chdir to the page's directory (whereas Embperl 1 did). So if you're trying to open a file using a relative path, it'll work or not depending of the mood and state of the apache process the request is riding.

The solution? Add the following to the top of the page:

    [-

$path = $epreq->component->cwd;

chdir $path or die "couldn't chdir to $path: $!";

-]
comments powered by Disqus

About the author

Yanick Champoux
Perl necrohacker , ACP writer, orchid lover. Slightly bonker all around. he/him/his