Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: line pro line match with Win32::Clipboard

by citromatik (Curate)
on Jun 12, 2007 at 14:05 UTC ( [id://620726]=note: print w/replies, xml ) Need Help??


in reply to line pro line match with Win32::Clipboard

My script reloads everytime the whole file and i find always the first match.

Think carefully what the script is doing:

  • You get your text to analyze with $text = Win32::Clipboard::GetText();
  • You are assigning the variable $text to the variable $zoektekst (completely useless, use your preferred variable in the first place: $zoektekst=Win32::Clipboard::GetText();
  • While the string in $zoektekst is not empty you will be looping. while ($zoektekst) {
  • If you match that regular expression, you copy the match in the $_ variable, delete one part and print another. The problem is that your substitution is made in the variable $_ that holds a copy of the previous match ($_=$&), but you are not changing the original variable $zoektekst at all. So, in the next iteration of the while loop, $zoektekst has the same content. You should be written:
    $zoektekst=~s%(d{13})\s+CG1%%; print $1;
  • The same for the next if

Hope this helps

citromatik

Update: Be sure you provide an exit to the while loop.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://620726]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-25 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found