"Singh, Ajit p" wrote:

> Comrades,
>
> I have a function which takes up arguments as shown below:
>
> $str = "./place_order -t " .
>         "/thus/axioss/serviceID:\"" . $self->{serviceID} . "\" " .
>         "/thus/axioss/supplierProduct:\"" . $self->{supplierProduct} . "\" "
> .
>         "/thus/axioss/web/installationTelephoneNumber:\"" .
> $self->{installationTelephoneNumber} . "\n";

Okay, how are the hash keys getting assigned?

The code above shows you using the values of these hash elements, but we don't
see how the value get into them.  That is the place where you probably want to
make changes to eliminate the need for these hard-coded values.

>
>
> My problem is to get away with the hard coded values i.e
> /thus/axioss/serviceID:,/thus/axioss/supplierProduct:, and
> /thus/axioss/web/installationTelephoneNumber:

That should be easy enough.  See below.

>
>
> I am fetching the above arguments from a file which contains these values as
> shown below.
>
> /thus/axioss/serviceID:123456
> /thus/axioss/supplierProduct:BT IPStream 500
> /thus/axioss/web/installationTelephoneNumber:020837111663

There should be very little question here of how to eliminate the hard-coded
values--don't use them.

If your file already contains the key-value pairs shown, you should capture them
into variables as you load them.  As a matter of fact it looks like you had to
pick them apart to get your hash keys.  Furthermore, you must have extracted all
keys the same way, by removing the base directory from the string.
Unfortunately it is not  the same base directory in each case.  This means that
you will probably have to store the base directory strings for each key,
possibly by keeping those, along with the value extracted, in an anonymous hash,
and stroing a reference to the hash for each key.

Something about the structure of the key value pairs strikes me wierd, though.
What does that arrangement actually mean.

It looks like you are storing filenames as keys for the values.  Or are those
Registry-type keys?  In iether case, the operations on the base path should be
about the same.  I just would not see the sense in using filenames as hash keys.



> How can I do away with the hard coded keys?

Just throw away less of the information your program takes in while reading the
file, and there should be no need for them.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to