473,698 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Perl coding. please help

1 New Member
Hello perl programmers. i have the following code in one of my scripts.
i dont have any idea about what does most of the code do. i will put some notes regarding which parts i dont undrestand. could anybody please explain in details ???

almost 3 parts of this code which are the most important parts are not undrestood. thnx in advance


Expand|Select|Wrap|Line Numbers
  1. @a=();
  2. $advert=0;
  3. open(che,"namess/list.txt");
  4. while (<che>) {
  5. @a=();
  6. $advstr="";
  7.  
  8.  
  9. ###### what is being splite ?#####
  10. @a = split(//,$_);
  11.  
  12.  
  13. foreach $let (@a) {
  14. if ($let eq "l" || $let eq "i" || $let eq "1") {
  15.  
  16. #### what does the following mean ? please in details specially [\\W_]  #####
  17. $advstr .= "*[il1|!]+[\\W_]"; 
  18. #########################################
  19.  
  20. } elsif ($let eq "o" || $let eq "0") {
  21. $advstr .= "*[o0]+[\\W_]";
  22. } elsif ($let eq "a" || $let eq "@") {
  23. $advstr .= "*[a@]+[\\W_]";
  24. } else {
  25. $advstr .= "\*$let\+[\\W_]";
  26.    }
  27.  }
  28.  
  29.  
  30.  
  31. ######### im asking alot but these lines are not undrestood ####
  32. $advstr =~ s/\+\[\\W\_\]\*\s+\+\[\\W\_\]$//ig;
  33. $advstr =~ s/^\*//ig;
  34. $advstr =~ s/\./\\\./ig;
  35. $advstr =~ s/\@/\\\@/ig;
  36. $advstr =~ s/\$/\\\$/ig;
  37. $advstr =~ s/\-/\\\-/ig;
  38. ############################################
  39.  
  40.  
  41. if ($IN{'msg'} =~ /$advstr/ig){
  42. $advert++;
  43.  
  44. }
  45. close(che);
  46.  
Sep 21 '08 #1
3 1355
Icecrack
174 Recognized Expert New Member
For:

Expand|Select|Wrap|Line Numbers
  1. ######### im asking alot but these lines are not undrestood ####
  2. $advstr =~ s/\+\[\\W\_\]\*\s+\+\[\\W\_\]$//ig;
  3. $advstr =~ s/^\*//ig;
  4. $advstr =~ s/\./\\\./ig;
  5. $advstr =~ s/\@/\\\@/ig;
  6. $advstr =~ s/\$/\\\$/ig;
  7. $advstr =~ s/\-/\\\-/ig;
  8. ############################################
Look Up Perl Regular Expressions Tutorial in your favorite search engine.

For your information this part is canceling perl's special characters, and cleaning up text.

But for a better understanding follow my advice on Reg Exp.

Ice
Sep 22 '08 #2
KevinADC
4,059 Recognized Expert Specialist
i have the following code in one of my scripts.
If its your script, why don't you understand the code? Didn't you write it?
Sep 22 '08 #3
numberwhun
3,509 Recognized Expert Moderator Specialist
I agree with Kevin, if you don't understand those regex's, then you didn't write this code.
Sep 22 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

31
4792
by: surfunbear | last post by:
I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is great for pattern matching, text processing, and automated testing. Our company is really fixated on risk managnemt and the only way I can do enough testing without working overtime (which some people have ended up doing) is by automating my...
1
1956
by: Robert V | last post by:
Hi all, I could use some help programming on of my Perl script to handle different submit buttons within the same form. Here is what I have so far. A user goes to a Web form and inputs some data into a textarea box. Below this box there are two buttons ... one that is labelled "Save & Exit" and other that is labelled "Save and Preview" On submit of either button, the form data is sent to the same perl script. What I need to have happen is...
2
2503
by: PapaBear | last post by:
Hi y'all, I'm handling Apache errors through seperate shtml files. That surely looks better than the standard error pages by the browser etc. I did this by coding in httpd.conf lines like: ErrorDocument 403 http://levi.prodeo/errors/err_403.shtml ErrorDocument 404 http://levi.prodeo/errors/err_404.shtml ErrorDocument 405 http://levi.prodeo/errors/err_405.shtml
0
9739
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile. I need it to be compiled with threads. Anyone have any wisdom on how best to do this? Here's a transcript of my latest attempt. It's long; you might want to skip to the bottom, where I try "make" and the fatal errors start happening.
2
15991
by: kelly | last post by:
Hi, I don't have a code to show you, what I need are references or algorithms so that I'm in a right track. By the way, thanks for introducing me the array or arrays. Now I can continue my script. Now I want to delete a line from a file. Line being the strings I got/saved to/from array of arrays.
1
1220
by: SriniBala | last post by:
I have write coding from flat file to mysql via Perl. But I do not know Perl coding. Kindly help me to write proper Perl coding with in a week.
1
2187
by: crawfordr | last post by:
Hello, I have created a perl script that connects to a specific socket (Ip address/port) using protocall of TCP. It is the server socket script. There is also coding to manage multiple handles by usung the select() in the coding. This was needed due to the fact we expect a large volume of transactions at any given time on the client's side. The script's purpose is to connect to the client's port and listen for connections, accept the...
0
1606
by: crawfordr | last post by:
Hello, I have created a perl script that connects to a specific socket (Ip address/port) using protocall of TCP. It is the server socket script. There is also coding to manage multiple handles by usung the select() in the coding. This was needed due to the fact we expect a large volume of transactions at any given time on the client's side. The script's purpose is to connect to the client's port and listen for connections, accept the...
0
1007
by: Reedick, Andrew | last post by:
<snip> I have a Perl background and have found the O'Reilly books to be useful. The Learning Python book (or whatever it's called) is good because it covers the paradigm shifts and potential gotchas that you won't even consider thinking about otherwise. Only downside is wading through the novice 'how to program' parts. The Cookbook is also good for getting 'standard' apps up and running quickly (meaning you know how to do it in Perl,...
1
47460
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9023
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.