Thread: explaining the code
Results 1 to 4 of 4
Related
-
add code for font size under php echo code Forum: PHP Forum
Replies: 0 -
Code Help. Forum: Myspace Forum
Replies: 0 -
I need help with this code. Forum: HTML Forum
Replies: 1 -
Ignore code and link greeting note code Forum: HTML Forum
Replies: 3 -
need code. Forum: HTML Forum
Replies: 1
-
08-02-2005, 04:54 AM #1
explaining the code
Can someone explain for me what this code does. thanks
Code:read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; }
-
08-02-2005, 09:40 AM #2
Re: explaining the code
i will explain this line by line:
Code:#this line reads from the input that the script recieved into the variable "$buffer". the $ENV means "enviromental variables", so it is getting the enviromental var. 'content_length', which is the length of a file/string/exc... read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); #this line splits the string $buffer into an array (named "pairs"). the /&/ is telling it to split the file using "&" as the seperator. (example if $buffer equaled "this&that&there" it would split the array "pairs" into 3 with the outcome like this: $pairs[0]=this $pairs[1]=that $pairs[2]=there @pairs = split(/&/, $buffer); #this line is telling it to loop though this code as many times as there are arrays in $pairs. this line also tells it to temporarly use $pair for the current value of $pairs that it is on. foreach $pair (@pairs) { #this line is telling it to split $pair (the current "$pairs" array that it is on) into two variables, $name and $value, splitting it by the "=" sign. for example: if $pair equaled "hello=goodbye", then the outcome would be: $name=hello $value=goodbye ($name, $value) = split(/=/, $pair); #this line takes out any occance of "+" in $value and replaces it with a space. (the "tr" is different than using "s" because "tr" replaces it by character, and "s" replaces the whole thing) $value =~ tr/+/ /; #this line takes out any occurance of "a" through "f" (both higher and lower case) and "0 though "9" with 2 values besieds eachother, with the ascii value of the caracter that it is on. the "C" is telling it with: "An unsigned char value". this line is much harder to explain, but this example may help: if $value equaled "4A" then it will change it to equal "J", which has the ascii value of 112 which in hex is "4A", did that help? $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; #this changes the value of the form (which has been submitted) with the name of the value that is stored in $name with the translated value. $FORM{$name} = $value; #and last the eassiest line, tells it to stop the loop here. }
Last edited by ALL; 08-02-2005 at 09:50 AM.
-
08-11-2005, 12:34 AM #3
Re: explaining the code
Thank you so much! Now I have some problems to trouble you. I am doing the project that can collect all the errors from the receiver. there are 4 errors need to be monitor which are RF DRop, ASL,CSL, EFR. What I want now is using perl script to create the web page that lets user to see how often each error occur. For example, Let say today is Monday. I will collect all errors and saved in to a textfile A.txt. I will use the data that I collected to draw a graph to see how often the error occur for example there are 2 EFR error, 4 ASL,5CSL,6RFDrop, so I can draw the graph according to that information.
Once again, I thank for your help and hope that you can help me to solve this problem as well
-
08-13-2005, 07:43 PM #4
Re: explaining the code
are you wanting me to make it collect the errors from the same script, or is there an input for another script?
or do you already have that part figured out, and you need me to display the errors from the file as a graph?
do you have some code already made up?
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum