in reply to Re^3: Programming Language to generate Perl Scripts
in thread Programming Language to generate Perl Scripts

I need to generate separate perl scripts, based on the values within the XML file. I am a n00b to perl. What do I need to do say if I want to write $samaadhi(not the value, the text) into a file.

Wouldn't it be a mess of single quotes and double quotes? Still giving a thought of using perl. XML::Twig seems cool.

  • Comment on Re^4: Programming Language to generate Perl Scripts

Replies are listed 'Best First'.
Re^5: Programming Language to generate Perl Scripts
by marto (Cardinal) on May 14, 2010 at 15:59 UTC
Re^5: Programming Language to generate Perl Scripts
by JavaFan (Canon) on May 14, 2010 at 16:13 UTC
    Wouldn't it be a mess of single quotes and double quotes?
    Maybe. Why do you think it will be less of a mess of single quotes and double quotes if you would program it in a different language?

    # Perl print '$samaadhi'; # Prints the text, not the value. # shell echo '$samaadhi'; /* C */ #include <stdio.h> printf("$samaadhi"); // Java System.out.print("$samaadhi"); # Python print "$samaadhi"; { Pascal } Write("$smaadhi"); // C++ #include <iostream> std::cout << "$samaadhi"; -- Haskell putStrLn "$samaadhi"; # MMIX string BYTE "$samaadhi", 0 Main GETA $255,string TRAP 0,Fputs,StdOut
    Seems it's not any easier in another language.
Re^5: Programming Language to generate Perl Scripts
by ikegami (Patriarch) on May 14, 2010 at 16:50 UTC

    Wouldn't it be a mess of single quotes and double quotes?

    No. For the reasons I already gave, it would be less of a mess in Perl.

    Perl: print($fh q{for (keys(%h)) { print("$_: $h{$k}\n"); }}); C: fprintf(fh, "for (keys(%%h)) { print(\"$_: $h{$_}\\n\"); }"); fprintf(fh, "%s", "for (keys(%h)) { print(\"$_: $h{$_}\\n\"); }"); fputs("for (keys(%h)) { print(\"$_: $h{$_}\\n\"); }", fh);

    3 or 4 extra escapes in C.