Hi, i'd like to be able to search and replace a substring within a multiline string.
for example, if i've got the following text.
[CODE]
struct xyz {
unsigned x;
unsigned y;
unsigned z;
}
struct abc {
unsigned x;
unsigned y;
unsigned z;
}
[\CODE]
i'd like to replace only the 'x' variable within...
User Profile
Collapse
-
replace an expression inside multiline string
-
Hi Miller,
many thanks for your comprehensive response, it's definitely more readable than what i did :-) -
using eval statement inside regexp :
Hi, i'm looking for a way to use eval expression in perl regexp. for example. if i want to match the following pattern X_(X+1)_(X+2) using a single code line, where X represent a numeric value. i.e. 1_2_3 but not 1_2_2
i'd like to know if the following pseudo code can be written in perl:
Code:([0-9]+)_eval(\1+1)_eval(\1+2)
-
excel spreadshit parser :
Hi, i'm looking for a way to parse xls files in perl for unix.
perhaps you can advise me, based on experience, which module is most suitable for this task.
thanks -
remapping elements in array :
Hi, i need to sort an array of elements according to certain mapping i get as input.
for example if my array is : A B C D E
and the mapping table is : 1 2 5 4 3
then the result will be : A B E D C
atomic operation : swap(a,b) - also uses 1 memory space a temporal storing place.
i need a method the perform the above function in minimal memory consumption, minimal number of atomic operations,... -
temp string manipulation :
HI,
i'd like to use regexp replacement without changing variable value.
for example : in the following code i'd like to preseve the value of $key, but i need to change it's value in order to use it as an hash key. however, the hash key is only temporal and can be destroyed right after getting the hash.
Code:my $key = "aaa.bbb.ccc"; my $temp =~ s/\.ccc//; print $hash{$temp};
-
thanks for the help !
the tie package really suits my requirements.
btw, sorry for not following the guidelines this time, i'll make sure it won't happen again.Leave a comment:
-
how 2 edit file like list of lines :
Hi, i'd like to have an easy way of doing IO operation in files :
my main 2 tasks are :
1. reading line from file. for this i've created the following function :
Code:sub read_line { my $filename = shift; my $index = shift; open FILE, $filename or die "can't open $filename"; my @text = <FILE>; return $text[$index]; }
-
-
hey, thanks for the help ! i really appreciate it.
can you explain what does the '\u' symbol means, i haven't found it in any perl documentationLeave a comment:
-
how to replace each first letter of a word into capital letter :
Hi all, i'm currently struggling to perform the above mentioned replacement.
i already know how to catch the first letter in each word and determined if it's regular or capital.
however, i don't know how to replace this letter with it's corresponding capital letter.
perhaps there is an option to change the ascii value of the a character in perl regexp ?
for example :
... -
i'll definetly give it a shot, i'll let you know if i found someting useful,
thanksLeave a comment:
-
making perl script an executable program.
Hello,
i've installed some modules in my unix machine which i'm using in my scripts. however, i'd like to make those scripts executable from any machine, with minimal requirements of perl installed. is it possible ?
thanks, -
-
Hi,
#define used as macro in C. it's simply replace the first argument with the string represented by the second argument. format type is as follows :
definition :
#define ABC(X,Y,Z) BLA(X) + BLA(Y) + BLA(Z)
#define FIVE 5
usage :
ABC(5,2,1) = BLA(5) + BLA(2) + BLA(1)
x = 1 + FIVELeave a comment:
-
looking for perl synonym to #define in C/C++
Hello,
i'm looking for the equivalent perl symbol that match #define in C/C++
anybody have an idea if any such feature exists ...
thanks, -
Hi,
i accidently placed the extra $. removing it solved the problem.
thanks,Leave a comment:
-
Hello Kevin,
i'm sorry i've made a wrong impression on you. but in fact your replies were very helpful, and i didn't see any point to response since it supplied all my needs.
although it's not part of any formal site regulation, i guess it was impolite behavior, and i'm sorry for that. please accept my apology.
thanks ,Leave a comment:
-
uninitialized string :
Hi
Code:my $x = "1-6"; if ($x =~ /^\s*([0-9]+)\-([0-9]+)$\s*$/) { print "SUCCEED \n"; } else { print "FAILED \n"; }
-
find index of an element in a list
Hello,
how can i find the index of an existing element in a list ?
thanks,
No activity results to display
Show More
Leave a comment: