08-02-2010
perl substitution
Hello all
I have a strings like
" Watch news 24x7 "."x-wars is glowing"
" Watch news like 24 x 7"."x-mas will be celebrated"
" Dimensions of box is 24x23x47 ".
I have to remove the x(by) in between the number. If i just replace x, it will also remove all x's from text which i do not want. patterns are like 24x7 with no space in between and 24 x 7 with a space in between.
How can i remove these x's.
Please reply
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have lines in a file that look like this:
machine: machinea
machine: machineb
machine: randomwhatevermachine
I want to replace the machine lines with:
machine: machinec
I tried
perl -pi -e "s/#machine:\?*/machine: machinec/" filename
But this ended up doing this:
... (2 Replies)
Discussion started by: Lindarella
2 Replies
2. Shell Programming and Scripting
I've been working on this all night and finally have to ask for help... and not just from my coffee pot.
I need to replace a line of text only when it is proceeded by a line containing only the letter "H"
Input:
H -2.204711 -0.922090 -0.024814
P
6-311+G(d)
****
C
6-311+G(d)... (7 Replies)
Discussion started by: EmperorNorton
7 Replies
3. Shell Programming and Scripting
Hi friends,
I want to substitute "a ='....'," with ":" in everywhere in a string using Perl.
Details:
----------
my $str= " c1='fgfasfgasggfgff.,akhkhahha', c2='bbbn', c3='hg5 sh' ";
Required o/p: $str= " c1:c2:c3 "
I tried as below:
$str=~ s/=\'.*\',/:/g ;
print "str=... (14 Replies)
Discussion started by: Niroj
14 Replies
4. Shell Programming and Scripting
Hi,
I have a template file and want to replace 3 parameters to the values that I want. these values are in a parameter file.
Any idea how to do this in perl?
the parameter file looks like:
host_name = jupiter
PORT = 1562
IPADDRESS = 10.1.34.10
the template file has lots of entry.... (1 Reply)
Discussion started by: melanie_pfefer
1 Replies
5. Shell Programming and Scripting
Hi All,
I need the perl version of the below sed command:
sed 's/abc.*/&.txt/g' <filename>
Because I'm trying to do some replacement recursively using perl and the above replacement is replacing the abc* with "&.txt" exactly.
Thanks,
Arun (9 Replies)
Discussion started by: arun_maffy
9 Replies
6. Shell Programming and Scripting
I have a large text csv file that I'm working with. It will look something like this:
D,",E",C
O,"F,",I
O,gh,R
The second column always has a two digit random code (can be numbers, letters or any characters). When one of the characters happens to be a comma, the string is quoted. I want to... (5 Replies)
Discussion started by: beenny
5 Replies
7. Shell Programming and Scripting
Hi,
I'm new to Perl, and I want to change a few columns in a file in order to insert them into a database.
The input file looks like this:
00001,"01/1234567" ,"Tst2"
00002,"01/4545646" ,"Tst123456"
00003,"01/8979898" ,""
The output should look like this:
01-1234567,00001... (2 Replies)
Discussion started by: Subbeh
2 Replies
8. Shell Programming and Scripting
hi Geeks,
my input file contains data like =>
53 - Deewana Kar Raha Hai.mp3
54 - Hale Dil.mp3
55 - Ishq Sufiyana.mp3
56 - Abhi Kuch Dino Se.mp3
57 - Pee Loon Hoto Ki Sargam.mp3
I had used sed command to remove the prefix from the file name like
sed 's/^\
it gives me the perfect... (4 Replies)
Discussion started by: lohith.dutta
4 Replies
9. Shell Programming and Scripting
Hi,
With the following Perl syntax, how to print the $_ value after the substitution?
s/(\s*|\n)//g foreach (<>);
If I use the below code, it produces some numeric output print s/(\s*|\n)//g foreach (<>); (2 Replies)
Discussion started by: royalibrahim
2 Replies
10. Shell Programming and Scripting
OSX
I have been grinding my teeth on a portion of code. I am building a bash script that edits a html email template. In the template, I have place holders for SED (or whatever program is appropriate) to use as anchors for find and replace, with user defined corresponding html code. The HTML code... (3 Replies)
Discussion started by: sudo
3 Replies
LEARN ABOUT DEBIAN
mason::manual::requestdispatch
Mason::Manual::RequestDispatch(3pm) User Contributed Perl Documentation Mason::Manual::RequestDispatch(3pm)
NAME
Mason::Manual::RequestDispatch - How request paths get mapped to page components
DESCRIPTION
Given the request path
/news/sports/hockey
Mason searches for the following components in order, setting $m->path_info as noted.
/news/sports/hockey.{mp,mc}
/news/sports/hockey/index.{mp,mc}
/news/sports/hockey/dhandler.{mp,mc}
/news/sports/dhandler.{mp,mc} # $m->path_info = hockey
/news/sports.{mp,mc} # $m->path_info = hockey (but see next section)
/news/dhandler.{mp,mc} # $m->path_info = sports/hockey
/news.{mp,mc} # $m->path_info = sports/hockey (but see next section)
/dhandler.{mp,mc} # $m->path_info = news/sports/hockey
where ".{mp,mc}" means either ".mp" (indicating a pure-perl component). or ".mc" (indicating a top-level component).
The following sections describe these elements in more detail.
Autoextended path
The request path is suffixed with ".mp" and ".mc" to translate it to a component path.
/news/sports/hockey.{mp,mc}
Index
An index matches its exact directory, nothing underneath.
/news/sports/hockey/index.{mp,mc}
Dhandlers
A dhandler matches its directory as well as anything underneath, setting "$m->path_info" to the remainder.
/news/sports/hockey/dhandler.{mp,mc}
/news/sports/dhandler.{mp,mc} # $m->path_info = hockey
/news/dhandler.{mp,mc} # $m->path_info = sports/hockey
/dhandler.{mp,mc} # $m->path_info = news/sports/hockey
Partial paths
A component can match an initial part of the URL, setting "$m->path_info" to the remainder:
/news/sports.{mp,mc} # $m->path_info = hockey
/news.{mp,mc} # $m->path_info = sports/hockey
Since this isn't always desirable behavior, it must be explicitly enabled for the component. Mason will call method "allow_path_info" on
the component class, and will only allow the match if it returns true:
<%class>
method allow_path_info { 1 }
</%class>
The default "allow_path_info" returns false.
"allow_path_info" is not checked on dhandlers, since the whole point of dhandlers is to match partial paths.
Routes
It is possible to use route syntax to more elegantly parse "$m->path_info" for dhandlers and partial paths, e.g.
<%class>
route "{year:[0-9]+}/{month:[0-9]{2}}";
</%class>
See Mason::Plugin::RouterSimple.
SEE ALSO
Mason
AUTHOR
Jonathan Swartz <swartz@pobox.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Jonathan Swartz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
perl v5.14.2 2012-05-02 Mason::Manual::RequestDispatch(3pm)