Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Programming Language to generate Perl Scripts

by marto (Cardinal)
on May 14, 2010 at 15:43 UTC ( [id://840021]=note: print w/replies, xml ) Need Help??


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

Use Perl and the module XML::Twig to parse your XML file. Do you actually need to generate separate perl scripts or simply perform a fuction based on values within your XML file?

"It doesn't seem right to use perl to generate perl scripts as it will become very messy."

What makes you think this would be any easier in another language?

Update: fixed typo

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

Replies are listed 'Best First'.
Re^4: Programming Language to generate Perl Scripts
by samaadhi (Initiate) on May 14, 2010 at 15:55 UTC

    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.

      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.

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://840021]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-18 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found