Hello,
I have an hash like this:
my %hash1 = (
key1 => 'relative_path',
key2 => {
key21 => 'another_relative_path',
key22 => '/an_absolute_path',
key23 => 'relative_path',
},
key3 => '',
key4 => 4
);
I want to create a new hash that is equal to %hash1, apart from some specific values that
I want to check if these are absolute or relative paths. If they are relative paths I want to add some $home_path,
For example I would want to check only these values:
$hash1{key1}
$hash1{key2}{key22}
$hash1{key2}{key23}
So to obtain:
my %hash2 = (
key1 => "$home_path/relative_path",
key2 => {
key21 => 'another_relative_path',
key22 => '/an_absolute_path',
key23 => "$home_path/relative_path",
},
key3 => '',
key4 => 4
);
It would be useful if I can define the list of values to check with some simple syntax, for example
@list = ('key1','key2:key22','key2:key23');
Thanks for any suggestion!
-
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.