logo
down
shadow

How can I parse this configuration file format (allowing comments) in Perl?


How can I parse this configuration file format (allowing comments) in Perl?

By : birdheist
Date : November 21 2020, 07:01 PM
Hope this helps Unless you are doing this as a learning exercise, the best approach is to use a config parsing module from CPAN. Here's an illustration using Config::General, which is flexible enough to accommodate your unusual delimiter, and it provides a nice OO-style access to config parameters. [Note: To use this example, you'll need to install the Config::General module first. I mention this because it looks like you had trouble running Sinan's example, which also requires that you install a module from CPAN.]
code :


Share : facebook icon twitter icon
How can I parse this file format in Perl?

How can I parse this file format in Perl?


By : Pete Ferrell
Date : March 29 2020, 07:55 AM
Hope that helps Maybe someone have idea for perl script with very strong irregular expression that match only lines with uniqe rule ( [param_name] [separator] [any_value] ) , Here is one way:
code :
#!/usr/bin/perl

use strict; use warnings;
use File::Slurp;

while ( my $line = <DATA> ) {
    my $save = $line;
    $line =~ s/\s*;.*\z//s; # ignore comments

    my ($p, $v) = map { s/^\s+//; s/\s+\z//; $_ } split /=/, $line, 2;

    if ( defined($v) and $p =~ /^[^0-9].*\z/ and $v =~ /^[^=]+\z/ ) {
        append_file 'valid.txt', \ $save;
    }
    else {
        append_file 'invalid.txt', \ $save;
    }
}

__DATA__
parameter=1
parameter.1=1 2 3
MY_Name.2= A B C
parameter =1 * * $ @
Home_NAME =MOON
param1=1 2 3 + * *
Param_A = 73826.32863
PARAM_STAR    =   23.84 (2.d) 12 & {0} (8) 100%
Param120A = ~1.33454656
@param =90%
P1= -39546
My_param=#
My_P = # #123
MY_Parameter =   <34> 2 3 4 5 6 7 8 9 A "ededefec" $100
uniq_param=?
T = 0
GH.@=%
PORT_NUM= 123 / 98775 /  554 / 34545 / 54
ADDRESS  = 172.19.0.1
PARAM== 100
Param = 276 =
276 = 2652
= 234
Name =
PARAMETER = ;
Param_is_file 123
port 19463
David_name
243546
=
635A
10Param
*&^
= &^#$>:
A 123
What is a good plain text configuration file format shared by PHP and Perl?

What is a good plain text configuration file format shared by PHP and Perl?


By : Krittika Kae
Date : March 29 2020, 07:55 AM
wish helps you Pick any of ini, xml, yaml or json. There are libraries for working with any of these formats in Perl and PHP.
Configuration file format, complex datastructures (list, dictionaries), comments, editable

Configuration file format, complex datastructures (list, dictionaries), comments, editable


By : user3423137
Date : March 29 2020, 07:55 AM
like below fixes the issue As Chazeon and jme indicate you should take a look at YAML. It supports nested data structures ( list (sequence in YAML), dict (mapping) and various primitives ( integers, float, string, date ).
YAML also supports end-of-line comments ( introduced with #) but the "standard" PyYAML parser mentioned by Chazeon throws these away while reading data in (and cannot write these).
How to parse the java comments of a groovy file to html format?

How to parse the java comments of a groovy file to html format?


By : Ladislav Musel
Date : March 29 2020, 07:55 AM
like below fixes the issue There exists Groovydoc which is roughly the equivalent of Javadoc, just for Groovy.
As your setup is not that (you already have comments, probably not in Groovydoc format, and you have half the tooling), there are still multiple ways open to you. As you already extract the documentation from groovy, if I were you, I would do a minimal post-formatting, if necessary, and output the documentation as markdown (e.g., github markdown) or asciidoc (e.g., asciidoctor). Then you can use any preferred tool to convert the post-formatted documentation into HTML.
Perl - How to crawl a directory, parse every file in the directory and extract all comments to html file

Perl - How to crawl a directory, parse every file in the directory and extract all comments to html file


By : Anand Kumar
Date : March 29 2020, 07:55 AM
I wish this help you PPI can be used to parse Perl code files. This should get you started on getting Perl files in a directory (assuming they have .pl extensions) and grabbing the comments. I'm not sure what you mean about the HTML piece:
Related Posts Related Posts :
  • Troubleshooting Perl CGI app - Can't locate object method "new" via package
  • How To Avoid a Perl script calling an Another Perl Script
  • Perl - Internal File (create and execute)
  • How can I call a PL/Perl function from another PL/Perl function?
  • How can I terminate a system command with alarm in Perl?
  • When should I use a factory to wrap a constructor in Perl?
  • How can I extract sentences with a particular phrase, in Perl?
  • Getting the inner hash in Perl
  • Dequeue an array in perl with thread::queue
  • How do I tell perl to execute a piece of generated Perl code?
  • Why does a positive lookahead lead to captures in my Perl regex?
  • In a digital photo, how can I detect if a mountain is obscured by clouds?
  • How can I take a reference to specific hash value in Perl?
  • How can I determine which package my constructor was called from?
  • What does "!" mean before a variable in perl
  • How do I install Perl's Lingua::Lid?
  • How can I copy a directory but ignore some files in Perl?
  • How can I build something like Amazon S3 in Perl?
  • How can I get the high-res mtime for a symbolic link in Perl?
  • How can I get the ultimate URL without fetching the pages using Perl and LWP?
  • I want to replace last / by ,
  • How can I create a new file using a variable value as the name in Perl?
  • Why does my Perl CGI program fail with "Software error: ..."?
  • Strange regular expression
  • How can I handle -r=<pattern> with Perl's Getopt::Long?
  • Is there a way that I can force mod_perl to re-use buffer memory?
  • Can I pass a regex to isa() with Moose-based objects?
  • How can I tell Perl's IO::Socket::INET which interface to use?
  • How do I print a hash structure in Perl?
  • perl : can't require $value from other perl file and use it in 3rd perl file
  • What reasons could there be for converting Perl to Java?
  • What does perl -pe "s|$PASSWORD|<PASSWORD>|g"?
  • How to do unary and/reduction of bus to a bit in Perl?
  • How to resolve @INC related issue in Perl
  • Perl DBI case insensitive methods
  • Unable to get page via HTTPS with LWP::Simple in Perl
  • Using Perl's File::Basename to rename a file extension
  • using an array as a reference is deprecated in perl
  • How to get unicode code points in perl v5.24?
  • Get array in perl from json_encode
  • perl print to a file and STDOUT which is the file
  • How to process variable dimension array in Perl
  • How to fetch a one table from HTML source file using lwp module?
  • Using Win32::Env perl module, environment variable not setting permanently in windows
  • why doesn't make -C change $PWD as seen through a scripting language such as Perl?
  • Assign temp file from cgi and read it in .sh
  • Displaying 12-h time in Perl using DateTime
  • Using Perl to replace empty string with space
  • Why Perl ignores spaces between a sigil and variable name?
  • how get the last directory using perl?
  • Perl parsing email body without parts using MIME::Parser
  • Graph.pm - how to get all paths with particular length?
  • Count tandem repeats in Perl
  • How to install Filter::Crypto module for perl under ubuntu
  • I'm facing problem with the email program in Perl
  • Use tr with arrays
  • How do I concisely check warning categories up to the root of the hierarchy in my package?
  • Is there a way to host a webServer in perl which should in HTTPS
  • Can't open perl script "Build.PL": No such file or directory in response to perl Build.PL
  • Query about how to unpack a packed binary data
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk