Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

This started off entitled: "issues attempting to use Apache::Admin::Config->save()".

I seem to have fewer and fewer questions around here these days. Once again, stumped for too long, yet writing this out worked me through the steps to resolve this question for myself.

Apparently you can not apply a string substitution on a scalar on the same line where you assign its value to another scalar, or what gets assigned to the result of the string substitution (in my case a 1 for true). Though perhaps they could be wrapped in parens to control priority, don't know.

And I get reminded again to Keep it Simple. So thanks perlmonks for being here, where my last several questions have been aborted by working through this process in a similar way.

at a bash prompt I see:

hesco@marcus8:~/sandbox$ grep `whoami` /etc/passwd hesco:x:1000:1000:Hugh Esco,,,:/home/hesco:/bin/bash hesco@marcus8:~/sandbox$ ls -al t/ total 61 drwxr-xr-x 6 hesco hesco 736 2012-01-22 14:38 . drwxr-xr-x 11 hesco hesco 856 2011-12-24 21:29 .. hesco@marcus8:~/sandbox$ ls -al t/conf/ total 13 drwxr-xr-x 6 hesco hesco 280 2012-01-22 13:50 . drwxr-xr-x 6 hesco hesco 736 2012-01-22 14:38 .. hesco@marcus8:~/sandbox$ ls -al t/conf/etc/ total 0 drwxr-xr-x 3 hesco hesco 72 2011-07-02 00:57 . drwxr-xr-x 6 hesco hesco 280 2012-01-22 13:50 .. hesco@marcus8:~/sandbox$ ls -al t/conf/etc/apache2/ total 1 drwxr-xr-x 3 hesco hesco 80 2011-07-02 00:57 . drwxr-xr-x 3 hesco hesco 72 2011-07-02 00:57 .. hesco@marcus8:~/sandbox$ ls -al t/conf/etc/apache2/sites-available/ total 18 drwxr-xr-x 11 hesco hesco 480 2012-01-22 13:50 . drwxr-xr-x 3 hesco hesco 80 2011-07-02 00:57 .. hesco@marcus8:~/sandbox$ ls -al t/conf/etc/apache2/sites-available/tes +t_suite/ total 1 drwxr-xr-x 2 hesco hesco 48 2012-01-22 13:51 . drwxr-xr-x 11 hesco hesco 480 2012-01-22 13:50 ..

and when running my test script, as indicated, I get:

hesco@marcus8:~/sandbox$ perl t/14-ymd_provision_apache.t snip Use of uninitialized value $parent_directory in substitution (s///) at + lib/Apache.pm line 139. Use of uninitialized value $parent_directory in concatenation (.) or s +tring at lib/Apache.pm line 140. We hope we can write to: at lib/Apache.pm line 140. Use of uninitialized value $parent_directory in -w at lib/Apache.pm li +ne 141. not ok 33 - We got an anticipated result for our new apache vhost path +. # Failed test 'We got an anticipated result for our new apache vhost + path.' # at t/14-ymd_provision_apache.t line 64. # got: 'ERROR: user - 1000 is unable to create t/conf/etc/apa +che2/sites-available/test_suite/test.example.org' # expected: 't/conf/etc/apache2/sites-available/test_suite/test.ex +ample.org' # File [ERROR: user - 1000 is unable to create t/conf/etc/apache2/site +s-available/test_suite/test.example.org] does not exist

from code which looks like this:

my $new_vhost_path = "$apache_vhost_base_path/" . $site->{'vhost_ser +ver_name'}; if( -e $new_vhost_path ){ return 'ERROR: will not overwrite an existing configuration file:' + . $new_vhost_path; } else { my $parent_directory = $new_vhost_path =~ s,^(.*)/(.*),$1,; warn "We hope we can write to: $parent_directory "; if( -w $parent_directory ){ warn "We apparently believe that we can write to: $parent_direct +ory \n"; $self->{'apache'}->save( $new_vhost_path, '-reformat' ); return $new_vhost_path; } else { return 'ERROR: user - ' . $> . ' is unable to create ' . $new_vh +ost_path; } } }

FYI: $self->{'apache'}, in this case isa(Apache::Admin::Config)

And this resolves the bug . . .

- my $parent_directory = $new_vhost_path =~ s,^(.*)/(.*),$1,; + my $parent_directory = $new_vhost_path; + $parent_directory =~ s,^(.*)/.*$,$1,; warn "We hope we can write to: $parent_directory ";

. . . made apparent by informative debug messages.

if( $lal && $lol ) { $life++; }
if( $insurance->rationing() ) { $people->die(); }

In reply to Move along, nothing to see here . . . by hesco

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-19 13:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found