Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 203569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:23:25+00:00 2026-05-11T17:23:25+00:00

I have a test generator written in Perl. It generates tests that connect to

  • 0

I have a test generator written in Perl. It generates tests that connect to a simulator. These tests are themselves written in Perl and connect to the simulator via its API. I would like the generated code to be human-readable, which means I’d like it to be properly indented and formatted. Is there a good way to do it?

Details follow, or you can skip to the actual question below.

This is an example:


my $basic =  ABC
        TRIGGER        => DELAY(
            NUM            => 500,
            ),
        )
BASIC

my $additional =  STATE_IS(
        STATE          => DEF,
        INDEX          => 0,
        ),

ADDITIONAL

I’d like the command ABC to be executed with a delay of 500 (units aren’t relevant just now) after I call &event, and the state of index 0 is DEF. Sometimes I’ll also want to wait for indeces 1, 2, 3 etc…

For only one index I’d like to see this in my test:


    &event(
        CMD            => ABC
        TRIGGER        => DELAY(
            NUM            => 500,
            TRIGGER        => STATE_IS(
                STATE          => DEF,
                INDEX          => 0,
                ),
            ),
        )

For two indeces I’d like to see:


    &event(
        CMD            => ABC
        TRIGGER        => DELAY(
            NUM            => 500,
            TRIGGER        => STATE_IS(
                STATE          => DEF,
                INDEX          => 0,
                TRIGGER        => STATE_IS(
                    STATE          => DEF,
                    INDEX          => 1,
                    ),
                ),
            ),
        )

So basically I’m adding a block of:


            TRIGGER        => STATE_IS(
                STATE          => DEF,
                INDEX          => 0,
                ),

for each index, and the index number changes.

Here’s how I’m doing it:


for $i (0..$num_indeces) {
    # update the index number
    $additional =~ s/(INDEX\s*=>\s*)\d+,/$1 $i,/;

    $basic =~ s/(
                (\),\s*)  # capture sequences of ),
                +         # as many as possible 
                \)\s*     # end with ) without a , 
}               )/$additional $1/sx; # replace with the additional data

Here’s the actual question

The problem here is that the code comes out poorly indented. I’d like to run the resulting $basic through a prettifier like this:

&prettify($basic, "perl");

Which would format it nicely according to Perl’s best practices. Is there any good way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:23:25+00:00Added an answer on May 11, 2026 at 5:23 pm

    I have used this:

    use Perl::Tidy;
    sub Format {
        my $source = shift;
        my $result;
        Perl::Tidy::perltidy(
            source      => \$source,
            destination => \$result,
            argv        => [qw(-pbp -nst)]
        );
        return $result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 246k
  • Answers 246k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Simple method: module MyModule def self.my_method(*args) MyModule::MyClass.my_method(*args) end end Harder… May 13, 2026 at 8:28 am
  • Editorial Team
    Editorial Team added an answer I think my problem involves FF 3.5. May 13, 2026 at 8:28 am
  • Editorial Team
    Editorial Team added an answer Use LoadControl(), which is an instance method on the Page… May 13, 2026 at 8:28 am

Related Questions

How can the output rate be higher than hard disk write rate? Update 1
I would be thankful for any help on this: I want to write an
I have a web application written in C# that consumes several internal web services.
I have a simple function written in Oracle 9i (version 9.2.0.4.0) to simulate an

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.