in reply to Re^3: Yet another config file editing programme : Tell me how to make it better !
in thread Yet another config file editing programme : Tell me how to make it better !

Hi

Thanks for reviewing the code.
The input file includes 2 lines for DNS that are converted to one line for the dhcpcd.conf output file.
This happens in the code under the comment  # Convert 2 lines DNS to 1 line DNS


The error message reports that hash value $1 isn't initialised. This is confirmed by the test print statement immediately prior.
I think the code should be stepping through the hash but I don't know how that should be done in the context of this code. Is it implied, or should it be explicitly stated?



Dazz
  • Comment on Re^4: Yet another config file editing programme : Tell me how to make it better !
  • Download Code

Replies are listed 'Best First'.
Re^5: Yet another config file editing programme : Tell me how to make it better !
by tybalt89 (Monsignor) on Sep 08, 2021 at 23:21 UTC

    You print out all that nice debug from Data::Dump and yet you don't show it here :)

      Hi
      Here is the printout after running the program.
      I have added some hand typed comments out towards the right of the print out.
      $ perl ip3.pl ( "ip_params", # This is confirming the input +file has been correctly read. { domain_name_server_1 => "8.8.8.9", domain_name_server_2 => "8.8.4.9", interface => "eth0", ip_address => "192.168.10.9/24", routers => "192.168.9.91", }, ) ( "ip_params", # This is confirming that the f +ormat is correct for the output file. { domain_name_servers => "8.8.8.9 8.8.4.9", interface => "eth0", ip_address => "192.168.10.9/24", routers => "192.168.9.91", }, ) found section for eth0 at line 8 Use of uninitialized value within %ip_params in concatenation (.) or s +tring at ip3.pl line 73, <> line 9. ip param key : # a print of the hash key $0 is + blank Use of uninitialized value $1 in hash element at ip3.pl line 74, <> li +ne 9. Use of uninitialized value within %ip_params in concatenation (.) or s +tring at ip3.pl line 74, <> line 9. ip param val : # printing the hash value $1 is + blank. set ip_address to 192.168.10.9/24 Use of uninitialized value within %ip_params in concatenation (.) or s +tring at ip3.pl line 73, <> line 10. ip param key : Use of uninitialized value $1 in hash element at ip3.pl line 74, <> li +ne 10. Use of uninitialized value within %ip_params in concatenation (.) or s +tring at ip3.pl line 74, <> line 10. ip param val : set routers to 192.168.9.91 Use of uninitialized value within %ip_params in concatenation (.) or s +tring at ip3.pl line 73, <> line 11. ip param key : Use of uninitialized value $1 in hash element at ip3.pl line 74, <> li +ne 11. Use of uninitialized value within %ip_params in concatenation (.) or s +tring at ip3.pl line 74, <> line 11. ip param val : set domain_name_servers to 8.8.8.9 8.8.4.9 ending changes at line 12

      So I can't figure out where or how $1 should be initiated.

      Dazz