in reply to Re^3: Write in files
in thread Write in files

defined checks whether or not a key is defined in a hash, in this context it will return true if the name was found in your file 1. lc turns a string into lower case, adding a bit of robustness to the code (I assumed you wanted to do case insensitive matching).

Generally, there is excellent documentation at http://perldoc.perl.org should you be unfamiliar with a specific function.

UPDATE: It seems I was a bit tired when writing in this thread. While defined does the job, one really should be using exists. Apologies! A simple introduction into hashes can be found here http://www.tutorialspoint.com/perl/perl_hashes.htm but googling "perl hash" will lead to many more good hits.

Replies are listed 'Best First'.
Re^5: Write in files
by lolz (Initiate) on Nov 18, 2013 at 11:28 UTC
    what will happen if the define check will be false? The line wouldn't be written to the new file, right?

    what does the Connection from  $Verzeichnis{lc $name2}; exactly do? I want to understand all parts of the script :)

      The line from file 2 will be written before the check! If the check is true, the phone number will be appended. Finally, a newline is added independently of the outcome of the check.

      In order to understand $verzeichnis{...} you would need to read up on hashes in Perl.