Sponsored Content
Top Forums Programming perl: code execution via specially crafted regular expression. It it possible ? Post 302599163 by Corona688 on Thursday 16th of February 2012 10:49:31 AM
Old 02-16-2012
I don't think so. It depends what your code actually is of course, if you do silly things like throw 'eval' around then there could be holes everywhere..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular expression help in perl

Hi all, I am trying to match a multi line string and return the matching string in one line. Here is the perl code that I wrote: #!/usr/bin/perl my $str='<title>My title</title>'; if ($str =~ /(<title>)(+)(<\/title>)/ ){ print "$2\n"; } It returns : My title I want the... (3 Replies)
Discussion started by: sdubey
3 Replies

2. Shell Programming and Scripting

perl regular expression

letz say that my file has 7 records with only one field. So my file has: 11111111 000000000000000 1111 aaaabbbccc 1111111222000000 aaaaaaaa zz All i need is: 1. when the field has a repetition of the same instance(a-z or 0-9), i would consideer it to be invalid.... (1 Reply)
Discussion started by: helengoldman
1 Replies

3. Shell Programming and Scripting

regular expression in perl

hi, i want to extract the sessionID from this line. QnA Session Id : here the output should be-- QnA_SessionID=128589 Thanks NT (3 Replies)
Discussion started by: namishtiwari
3 Replies

4. Shell Programming and Scripting

PERL regular expression

Hello all, I need to match the red expressions in the following lines : MACRO_P+P-_scrambledServices_REM_PRC30.xml MACRO_P+P-_scrambledServices_REM_RS636.xml MACRO_P+P-_scrambledServices_REM_RS535.xml and so on... Can anyone give me a PERL regular expression to match those characters ? ... (5 Replies)
Discussion started by: lsaas
5 Replies

5. Shell Programming and Scripting

perl regular expression

Dear all, I have a simple issue on a perl regular expression. I want to get the characters in red from the next lines : POWER_key LEFT_key RIGHT_key OK_key DOWN_key and so on... Thanks in advance for reply. Ludo (1 Reply)
Discussion started by: lsaas
1 Replies

6. Shell Programming and Scripting

Regular expression in Perl

Hi, I need and expression for a word like abc_xyz_ykklm The expresion should indicate that the word starts with abc and end with ykklm but does not contain xyz string in the middle. Example: abc_tmn_ykklm is ok and abc_xyz_ykklm is not Ok. Please help. Regards. (1 Reply)
Discussion started by: asth
1 Replies

7. Shell Programming and Scripting

Need perl regular expression

Hi, I am looking for a Perl regular expression to match the below pattern of a java script file. var so = object.device.load('camera','value'); I want to grep out such lines present in the *.js files. The conditions are: a) the line may start with blank space(s) b) always the... (3 Replies)
Discussion started by: royalibrahim
3 Replies

8. Shell Programming and Scripting

Perl regular expression and %

Could you help me with this please. This regular expression seems to match for the wrong input #!/usr/bin/perl my $inputtext = "W1a$%XXX"; if($inputtext =~ m/+X+/) { print "matches\n"; } The problem seems to be %. if inputtext is W1a$XXX, the regex doesnot match.... (5 Replies)
Discussion started by: suppandi7
5 Replies

9. Shell Programming and Scripting

Hidden Characters in Regular Expression Matching Perl - Perl Newbie

I am completely new to perl programming. My father is helping me learn said programming language. However, I am stuck on one of the assignments he has given me, and I can't find very much help with it via google, either because I have a tiny attention span, or because I can be very very dense. ... (4 Replies)
Discussion started by: kittyluva2
4 Replies

10. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies
AnyEvent::FAQ(3pm)					User Contributed Perl Documentation					AnyEvent::FAQ(3pm)

NAME
AnyEvent::FAQ - frequently asked questions The newest version of this document can be found at <http://pod.tst.eu/http://cvs.schmorp.de/AnyEvent/lib/AnyEvent/FAQ.pod>. My program exits before doing anything, what's going on? Programmers new to event-based programming often forget that you can actually do other stuff while "waiting" for an event to occur and therefore forget to actually wait when they do not, in fact, have anything else to do. Here is an example: use AnyEvent; my $timer = AnyEvent->timer (after => 5, cb => sub { say "hi" }); The expectation might be for the program to print "hi" after 5 seconds and then probably to exit. However, if you run this, your program will exit almost instantly: Creating the timer does not wait for it, instead the "timer" method returns immediately and perl executes the rest of the program. But there is nothing left to execute, so perl exits. To force AnyEvent to wait for something, use a condvar: use AnyEvent; my $quit_program = AnyEvent->condvar; my $timer = AnyEvent->timer (after => 5, cb => sub { $quit_program->send }); $quit_program->recv; Here the program doesn't immediately exit, because it first waits for the "quit_program" condition. In most cases, your main program should call the event library "loop" function directly: use EV; use AnyEvent; ... EV::loop; Why is my "tcp_connect" callback never called? Tricky: "tcp_connect" (and a few other functions in AnyEvent::Socket) is critically sensitive to the caller context. In void context, it will just do its thing and eventually call the callback. In any other context, however, it will return a special "guard" object - when it is destroyed (e.g. when you don't store it but throw it away), tcp_connect will no longer try to connect or call any callbacks. Often this happens when the "tcp_connect" call is at the end of a function: sub do_connect { tcp_connect "www.example.com", 80, sub { ... lengthy code }; } Then the caller decides whether there is a void context or not. One can avoid these cases by explicitly returning nothing: sub do_connect { tcp_connect "www.example.com", 80, sub { ... lengthy code }; () # return nothing } Why do some backends use a lot of CPU in "AE::cv->recv"? Many people try out this simple program, or its equivalent: use AnyEvent; AnyEvent->condvar->recv; They are then shocked to see that this basically idles with the Perl backend, but uses 100% CPU with the EV backend, which is supposed to be sooo efficient. The key to understand this is to understand that the above program is actually buggy: Nothing calls "->send" on the condvar, ever. Worse, there are no event watchers whatsoever. Basically, it creates a deadlock: there is no way to make progress, this program doesn't do anything useful, and this will not change in the future: it is already an ex-parrot. Some backends react to this by freezing, some by idling, and some do a 100% CPU loop. Since this program is not useful (and behaves as documented with all backends, as AnyEvent makes no CPU time guarantees), this shouldn't be a big deal: as soon as your program actually implements something, the CPU usage will be normal. Why does this FAQ not deal with AnyEvent::Handle questions? Because AnyEvent::Handle has a NONFAQ on its own that already deals with common issues. How can I combine Win32::GUI applications with AnyEvent? Well, not in the same OS thread, that's for sure :) What you can do is create another ithread (or fork) and run AnyEvent inside that thread, or better yet, run all your GUI code in a second ithread. For example, you could load Win32::GUI and AnyEvent::Util, then create a portable socketpair for GUI->AnyEvent communication. Then fork/create a new ithread, in there, create a Window and send the "$WINDOW->{-Handle}" to the AnyEvent ithread so it can "PostMessage". GUI to AnyEvent communication could work by pushing some data into a Thread::Queue and writing a byte into the socket. The AnyEvent watcher on the other side will then look at the queue. AnyEvent to GUI communications can also use a Thread::Queue, but to wake up the GUI thread, it would instead use "Win32::GUI::PostMessage $WINDOW, 1030, 0, """, and the GUI thread would listen for these messages by using "$WINDOW->Hook (1030 (), sub { ... })". My callback dies and... It must not - part of the contract betwene AnyEvent and user code is that callbacks do not throw exceptions (and don't do even more evil things, such as using "last" outside a loop :). If your callback might die sometimes, you need to use "eval". If you want to track down such a case and you can reproduce it, you can enable wrapping (by calling "AnyEvent::Debug::wrap" or by setting "PERL_ANYEVENT_DEBUG_WRAP=1" before starting your program). This will wrap every callback into an eval and will report any exception complete with a backtrace and some information about which watcher died, where it was created and so on. Author Marc Lehmann <schmorp@schmorp.de>. perl v5.14.2 2012-04-05 AnyEvent::FAQ(3pm)
All times are GMT -4. The time now is 10:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy