Hi All,
I have this(.xml) file as:
<!-- define your instance here -->
<instance name='ins_C2Londondev' user='' group='' fullname='B2%20-%20London%20(dev)' >
<property>
</property>
</instance>
I want output as:
<!-- define your instance here -->
<instance... (3 Replies)
Hi All,
I have a log file like this
E Mon Oct 06 00:17:08 2008 xxx2 cm:10614 fm_pi2_svc_iptv_purchase.c:149 1:pin_deferred_act:10601:11:169:1223245028:16
pi2_op_svc_iptv_purchase error
<location=PIN_ERRLOC_FM:5 class=PIN_ERRCLASS_SYSTEM_DETERMINATE:1... (10 Replies)
GNU sed version 4.1.4 on Windows XP SP3 from GnuWin32
I think that I've come across a seemingly simple text file change problem on a INI formatted file that I can't do with SED without side effects edge cases biting me. I've tried to think of various ways of doing this elegantly and quickly... (5 Replies)
Yes, there is a great doc out there that discusses parsing csv files with sed, and this topic has been covered before but not enough to answer my question (unix.com forums).
I'm trying to parse a CSV file that has optional quotes like the following:
"Apple","Apples, are fun",3.60,4.4,"I... (3 Replies)
I don't necessary have a problem, as I have a solution. It is just that there may be a better solution.
GOAL: Part one: Parse data from a file using the "\" as a delimiter and extracting only the last delimiter. Part two: Parse same file and extract everything but the last delimited item.
... (8 Replies)
I have a large xml file as shown below:
<input>
<blah>
<blah>
<atr="blah blah value = "">
<blah>
<blah>
</input>
..2nd chunk...
..3rd chunk...
...4th chunk...
All lines between <input> and </input> is one 'order' and this 'order' is repeated... (14 Replies)
Hello fellows,
Sure you can help this poor guy that is struggling against sed command, being unable to tame it
I have a lot of files like this:
From this one, I need to obtain values highlighted in bold/red
To do so, I am executing this piece of code inside a loop:
... (10 Replies)
Hello.
I am trying to modify a config file which is in windows *.ini type file.
I have found a piece of code here :linux - Edit file in unix using SED - Stack Overflow
As I can't make it doing the job , I am trying to find a solution step by step.
here a modified sample file : my_sample.ini... (1 Reply)
I have a text file with records of the form:
A X1 Y1 X2 Y2 X3 Y3
where A is character length 10, Xi is character length 4 and Yi is numeric length 10.
I want to parse the line, and output records like:
A X1 Y1
A X2 Y2
A X3 Y3
etc
Can anyone please give me an idea of how to do this. ... (4 Replies)
Discussion started by: wvdeijk
4 Replies
LEARN ABOUT DEBIAN
prima::inifile
Prima::IniFile(3) User Contributed Perl Documentation Prima::IniFile(3)NAME
Prima::IniFile - support of Windows-like initialization files
DESCRIPTION
The module contains a class, that provides mapping of text initialization file to a two-level hash structure. The first level is called
sections, which groups the second level hashes, called items. Sections must have unique keys. The items hashes values are arrays of text
strings. The methods, operated on these arrays are get_values, set_values, add_values and replace_values.
SYNOPSIS
use Prima::IniFile;
my $ini = create Prima::IniFile;
my $ini = create Prima::IniFile FILENAME;
my $ini = create Prima::IniFile FILENAME,
default => HASHREF_OR_ARRAYREF;
my $ini = create Prima::IniFile file => FILENAME,
default => HASHREF_OR_ARRAYREF;
my @sections = $ini->sections;
my @items = $ini->items(SECTION);
my @items = $ini->items(SECTION, 1);
my @items = $ini->items(SECTION, all => 1);
my $value = $ini-> get_values(SECTION, ITEM);
my @vals = $ini-> get_values(SECTION, ITEM);
my $nvals = $ini-> nvalues(SECTION, ITEM);
$ini-> set_values(SECTION, ITEM, LIST);
$ini-> add_values(SECTION, ITEM, LIST);
$ini-> replace_values(SECTION, ITEM, LIST);
$ini-> write;
$ini-> clean;
$ini-> read( FILENAME);
$ini-> read( FILENAME, default => HASHREF_OR_ARRAYREF);
my $sec = $ini->section(SECTION);
$sec->{ITEM} = VALUE;
my $val = $sec->{ITEM};
delete $sec->{ITEM};
my %everything = %$sec;
%$sec = ();
for ( keys %$sec) { ... }
while ( my ($k,$v) = each %$sec) { ... }
METHODS
add_values SECTION, ITEM, @LIST
Adds LIST of string values to the ITEM in SECTION.
clean
Cleans all internal data in the object, including the name of the file.
create PROFILE
Creates an instance of the class. The PROFILE is treated partly as an array, partly as a hash. If PROFILE consists of a single item,
the item is treated as a filename. Otherwise, PROFILE is treated as a hash, where the following keys are allowed:
file FILENAME
Selects name of file.
default %VALUES
Selects the initial values for the file, where VALUES is a two-level hash of sections and items. It is passed to read, where it is
merged with the file data.
get_values SECTION, ITEM
Returns array of values for ITEM in SECTION. If called in scalar context, and there is more than one value, the first value in list is
returned.
items SECTION [ HINTS ]
Returns items in SECTION. HINTS parameters is used to tell if a multiple-valued item must be returned as several items of the same
name; HINTS can be supplied in the following forms:
items( $section, 1 ) items( $section, all => 1);
new PROFILE
Same as create.
nvalues SECTION, ITEM
Returns number of values in ITEM in SECTION.
read FILENAME, %PROFILE
Flushes the old content and opens new file. FILENAME is a text string, PROFILE is a two-level hash of default values for the new file.
PROFILE is merged with the data from file, and the latter keep the precedence. Does not return any success values but, warns if any
error is occurred.
replace_values SECTION, ITEM, @VALUES
Removes all values form ITEM in SECTION and assigns it to the new list of VALUES.
section SECTION
Returns a tied hash for SECTION. All its read and write operations are reflected in the caller object, which allows the following
syntax:
my $section = $inifile-> section( 'Sample section');
$section-> {Item1} = 'Value1';
which is identical to
$inifile-> set_items( 'Sample section', 'Item1', 'Value1');
sections
Returns array of section names.
set_values SECTION, ITEM, @VALUES
Assigns VALUES to ITEM in SECTION. If number of new values are equal or greater than the number of the old, the method is same as
replace_values. Otherwise, the values with indices higher than the number of new values are not touched.
write
Rewrites the file with the object content. The object keeps an internal modification flag under name "{changed}"; in case it is
"undef", no actual write is performed.
AUTHORS
Anton Berezin, <tobez@plab.ku.dk>
Dmitry Karasik <dmitry@karasik.eu.org>
perl v5.14.2 2009-02-24 Prima::IniFile(3)