Sponsored Content
Top Forums Shell Programming and Scripting change function structure with perl (regExp) Post 302085774 by cbkihong on Saturday 19th of August 2006 10:20:37 AM
Old 08-19-2006
Depending on the format/syntax of your args, a full regexp may be too complex for this. You probably wish to do the lex'ing first, then reconstruct the replacement string dynamically with the lex'ed tokens.

I don't have much experience in lex'ing. You may start your research here:

http://www.perl.com/pub/a/2006/01/05/parsing.html
http://search.cpan.org/~ovid/HOP-Lex...b/HOP/Lexer.pm
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need Help with Perl REGEXP

I need help with a Perl regular expression. The following string blows up my program: <david(greg jim)> If I type this string, there is no problem: <david(greg_jim)> or type david(gregjim) or type <david greg jim> the CGI program does not complain. For some reason that I do not understand the... (1 Reply)
Discussion started by: mh53j_fe
1 Replies

2. Shell Programming and Scripting

perl regexp

What is the easiest way to get full address of *.jpg images from html file using perl? example: http://farm3.static.flickr.com/2397/2126443111_65a810004c.jpg (1 Reply)
Discussion started by: mirusnet
1 Replies

3. Shell Programming and Scripting

rename - change n'th character of regexp

Hi, I wonder if its possible to do the following task using rename (perl v5.8.8). I want to find filenames matching the specific pattern and then change chosen character of this pattern to a given character, e.g. do the following renaming: regexp: 'ab' -----> 'a0b' What's the simplest... (0 Replies)
Discussion started by: pms
0 Replies

4. Shell Programming and Scripting

perl regexp matching

Hello, I cannot see what's wrong in my code. When I run code below, it just print an empty string. my $test = "SWER~~ERTGSDFGTHAS_RTAWGA_DFAS.x4-234253454.in"; if ($test = ~ m/\~{1,2}.*4/) { print "$1\n"; } else { print "No match...\n"; } Anyone know what I'm doing wrong? ... (4 Replies)
Discussion started by: urandom
4 Replies

5. Shell Programming and Scripting

perl regexp: no match across newlines

Hi. Here's a tricky one (at least to me): I have a file named theFile.txt (UTF-8) that contains the following: a b cWhen I execute perl -pe 's|a.*c|d|sg' theFile.txtin bash 3.2 on MAC OS X 10.6, I get no match, i.e. the result is a b cagain. Any clues why? (2 Replies)
Discussion started by: BatManWSL
2 Replies

6. Programming

structure pointer array as function parameters

if i create an array of pointers to a structure "struct node" as: struct node *r; and create "n" number of "linked lists" and assign it to the various struct pointers r using some function with a return type as structure pointer as: r=multiplty(.......) /*some parameters*/ is... (2 Replies)
Discussion started by: mscoder
2 Replies

7. Shell Programming and Scripting

Change XML file structure script

Hi to all, Maybe someone could help me. I want to transform the structure of a xml file. I have this input.xml: <?xml version="1.0" encoding="utf-8"?> <votings> <file name="Reference 19762"> <case id="No. 3 Div. 870"> <j v="1">Peter</j> <j v="1">Ely</j> <j... (10 Replies)
Discussion started by: cgkmal
10 Replies

8. Shell Programming and Scripting

Perl regexp help

Hi, I have file like below: 1|1212|34353|5fdf 6575||dfgdg sfsdf |afsf||4|aasfbc|~1213~~~~~ 1|1212|34353|5fdf 6575||dfgdg sfsdf |affsf| |4|abc|~rwarw~~asa~~~123~312313 1|1212|34353|5fdf 6575||dfgdg sfsdf |afasfs||4|aasfdbc|~564564~~~~ 1|1212|34353|5fdf 6575||dfgdg sfsdf... (1 Reply)
Discussion started by: sol_nov
1 Replies

9. Shell Programming and Scripting

Perl regexp to extract first and second column

Hi, I am trying with the below Perl one-liner using regular expression to extract the first and second column of a text file: perl -p -e "s/\s*(\w+).*/$1/" perl -p -e "s/\s*.+\s(.+)\s*/$1\n/" whereas the text file's data looks like: Error: terminated 2233 Warning: reboot 3434 Warning:... (3 Replies)
Discussion started by: royalibrahim
3 Replies

10. Shell Programming and Scripting

find and Replace String in Perl - Regexp

Trying to find and replace one string with another string in a file #!/usr/bin/perl $csd_table_path = "/file.ntab"; $find_str = '--bundle_type=021'; $repl_str = '--bundle_type=021 --target=/dev/disk1s2'; if( system("/usr/bin/perl -p -i -e 's/$find_str/$repl_str/' $csd_table_path")... (2 Replies)
Discussion started by: cillmor
2 Replies
HTML::Mason::Lexer(3pm) 				User Contributed Perl Documentation				   HTML::Mason::Lexer(3pm)

NAME
HTML::Mason::Lexer - Generates events based on component source lexing SYNOPSIS
my $lexer = HTML::Mason::Lexer->new; $lexer->lex( comp_source => $source, name => $comp_name, compiler => $compiler ); DESCRIPTION
The Lexer works in tandem with the Compiler to turn Mason component source into something else, generally Perl code. As the lexer finds component elements, like a tag or block, it calls the appropriate event methods in the compiler object it was given. It has only a few public methods. You can replace this lexer with one of your own simply by telling the Compiler to use a different lexer class. Your lexer class simply needs to call the appropriate methods in the Component Class's API as it scans the source. METHODS
The lexer has very few public methods. new This method creates a new Lexer object. This methods takes no parameters. lex ( comp_source => ..., name => ..., compiler => ... ) This method tells the lexer to start scanning the given component source. All of these parameters are required. The "name" parameter will be used in any error messages generated during lexing. The "compiler" object must be an object that implements the Mason Component API. line_number The current line number that the lexer has reached. name The name of the component currently being lexed. throw_syntax_error ($error) This throws an "HTML::Mason::Exception::Syntax" error with the given error message as well as additional information about the component source. This method is used by both the Lexer and the Compiler. SUBCLASSING
Any subclass of the lexer should declare itself to be a subclass of "HTML::Mason::Lexer", even if it plans to override all of its public methods. If you want your subclass to work with the existing Compiler classes in Mason, you must implement the methods listed above. If you plan to use a custom Compiler class that you're writing, you can do whatever you want. We recommend that any parameters you add to Lexer be read-only, because the compiler object_id is only computed once on creation and would not reflect any changes to Lexer parameters. perl v5.14.2 2012-02-04 HTML::Mason::Lexer(3pm)
All times are GMT -4. The time now is 08:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy