hi, I have an xml file and I need to replace the tags with different names all at a time here is what I have
<cevalue>
<cevalue1>
<cevalue2>
<cevalue3>
<cevalue4>
<cevalue5>
and I need these like these...
<cevalue>
<cevalue>
<cevalue>
<cevalue>
<cevalue>
<cevalue>
I tried a few but... (2 Replies)
I have a series of folders /temp/a /temp/b /temp/c
In folders a, b, and c, I have files
a1.txt..........a20.txt
b1.txt..........b40.txt &
c1.txt..........c60.txt
Each file has the same data format :-
Line 1 AAAAA aaaa
Line 2 BBB bbbbbb
Line 3 CCCC cccccc
Etc etc
I need to write a... (13 Replies)
I'm writing a script which word counts the number of lines in two files. If one file is bigger than the other I'd like to edit one of the files to delete some lines to make both the same. It does not matter where in the file the lines are deleted from. It's expected that this will be ran from... (3 Replies)
Hi
I have a file which looks like this
//string = "abcd"; //info
//string = "*pqrs"; //add
string = "#123"; //sub
//string = "#1234567890"
data = check(string)
//string = "#1234567890"
I want to modify this as
string = "#987"; //mult
data = check(string)
How do i do that? (1 Reply)
Hi Penchal,
I would appreciate if you can provide me a brief explanation on what you are trying to do in the commnad below.
echo "6-9-2008" | sed 's/\(.\)-\(.\)-\(.*\)/\3-0\2-0\1/g'
Thanks
Amit (1 Reply)
I have done a script using sed which replaces a string in file.
I face 2 problems, while using sed command.
1)last line of the file is missing.
2)if i am are using wild card character in the command, Its not taking the next matching pattern ie if I am giving the pattern abc*def to be replaced... (2 Replies)
I have a sed query.
There is a line which has tilde and I want to separate this line using sed.
The line is:
ABP_ETC_ROOT=~xdmadm
The query to get this line is:
sed -n '/\(.*\)~\(.*\)/p' infile
I want to get xdmadm from this line and I am using this sed command:
sed -n... (5 Replies)
Hello Im fairly familiar with using the sed command for substitution, however I have been passed a script which checks the logged on username and directory type with a sed section which I cant figure out. The sed function has me baffled and I cant find out from the man page what its trying to do... (1 Reply)
Hi all, I am trying to use SED to input lines to a file in a specific place.
So far I have;
sed '/#NewEntry/ i\Insert this line' myfile.txt
The output is printing to screen correctly but what is the best way to write it back to the file without overwriting everything?
I tried adding >... (6 Replies)
Hi all, I am trying to remove quite a lot of numbers for a file I have which looks something along the lines of;
1,2,3,4,5,6 etc
I have a list of numbers I want removing looking like;
10000
10987
16572
etc
etc
and have been trying to run;
for id in `cat list` ; do sed -i -e... (8 Replies)
Discussion started by: JayC89
8 Replies
LEARN ABOUT DEBIAN
perlx::maybe
PerlX::Maybe(3pm) User Contributed Perl Documentation PerlX::Maybe(3pm)NAME
PerlX::Maybe - return a pair only if they are both defined
SYNOPSIS
You once wrote:
my $bob = Person->new(
defined $name ? (name => $name) : (),
defined $age ? (age => $age) : (),
);
Now you can write:
my $bob = Person->new(
maybe name => $name,
maybe age => $age,
);
DESCRIPTION
Moose classes (and some other classes) distinguish between an attribute being unset and the attribute being set to undef. Supplying a
constructor arguments like this:
my $bob = Person->new(
name => $name,
age => $age,
);
Will result in the "name" and "age" attributes possibly being set to undef (if the corresponding $name and $age variables are not defined),
which may violate the Person class' type constraints.
(Note: if you are the author of the class in question, you can solve this using MooseX::UndefTolerant. However, some of us are stuck using
non-UndefTolerant classes written by third parties.)
To ensure that the Person constructor does not try to set a name or age at all when they are undefined, ugly looking code like this is
often used:
my $bob = Person->new(
defined $name ? (name => $name) : (),
defined $age ? (age => $age) : (),
);
or:
my $bob = Person->new(
(name => $name) x!!(defined $name),
(age => $age) x!!(defined $age),
);
A slightly more elegant solution is the "maybe" function:
"maybe $x => $y, @rest"
This function checks that $x and $y are both defined. If they are, it returns them both as a list; otherwise it returns the empty list.
If @rest is provided, it is unconditionally appended to the end of whatever list is returned.
The combination of these behaviours allows the following very sugary syntax to "just work".
my $bob = Person->new(
name => $name,
address => $addr,
maybe phone => $tel,
maybe email => $email,
unique_id => $id,
);
This function is exported by default.
BUGS
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=PerlX-Maybe <http://rt.cpan.org/Dist/Display.html?Queue=PerlX-Maybe>.
SEE ALSO
Syntax::Feature::Maybe.
MooseX::UndefTolerant, PerlX::Perform, Exporter.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2012 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
perl v5.14.2 2012-05-03 PerlX::Maybe(3pm)