Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old February 27th, 2001, 01:35 AM
Dups Dups is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 30 Dups User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Hello there,

Here i have a code which accepts data from an html page.
The user inputs like "a & b " in the edit box is read as
"a %26 b " and so on. How can i read the input as " a & b" itself.

When i use the following function
$content=~ tr/%(..)/pack("c",hex($1))/;

I am getting "a p26 b " as output for the input "a & b".

Could u please suggest some solution for my problem.

Will any other arguments for pack function solve the problem.

Thanks in advance.
Dups


Reply With Quote
  #2  
Old February 27th, 2001, 08:27 AM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
Wink

Look for a function or extension that deals with URL encoding. I think that sort of thing is covered in Programming CGI with Perl by O'Reilly. I am sure there are also some online.

Also, it may not be working because you are using pack wrong for that type of conversion. You are dealing with Hex, as you seem to be aware of so the first argument to pack should be ["H*"]. The H indicates a hex string, high nibble first. The star is there in place of a number which can be specified as a repeat count. If there were a number, pack would convert as many values from the list as the number specified. The star tells pack to go all the way through.

So, after all that the code that you would need to do that sort of pack would be:
Code:
$char = pack "H*", "26";

In your case, i tried using it in a regular expression to see if it work(had a hunch it wouldn't) and it did not.

Hope some of this helps.
__________________
- dsb -
Perl Guy

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > regarding pack function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway