in reply to Re^3: Copying files from one file to another file
in thread Copying files from one file to another file

Can you write comments for the code? Didn't understand dd \%hash; from there
  • Comment on Re^4: Copying files from one file to another file

Replies are listed 'Best First'.
Re^5: Copying files from one file to another file
by shmem (Chancellor) on Feb 20, 2018 at 08:34 UTC

    dd() is a function exported by Data::Dump. Since %hash as argument to dd would be expanded into a flat list, a reference to %hash is passed to dd. That's what the backslash does, it is the reference operator. See perlref.

    The next lines are sample output produced by dd.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re^5: Copying files from one file to another file
by AnomalousMonk (Archbishop) on Feb 20, 2018 at 08:21 UTC
    dd \%hash;

    This statement "dumps" data from a data structure. The data structure must be passed to  dd as a reference, hence  \%hash takes a reference to the hash. See Data::Dump::dd(). (Note: There are many data dumpers. I like Data::Dump, but it's not core. The Data::Dumper module comes as a part of the core Perl "standard" installation.)

    { bar => ["13 : //comment thirteen"], foo => ["12 : //comment twelve ", "5 : //comment five"], }

    This is the output of the  dd \%hash; statement. It appears immediately after the
        c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le " ... "
    command line invocation used to execute the example code.


    Give a man a fish:  <%-{-{-{-<

      any other solution? this is not working for me please, help me.

        this is not working ...

        "This does not work" is almost useless as a problem description. What does not work? Where is your code? Why can you not provide your code and short examples of an input file and expected output file(s)? Please, please, please see Short, Self-Contained, Correct Example for further discussion of why these steps are vital for getting help.


        Give a man a fish:  <%-{-{-{-<