in reply to Re: Save form data with decoded URL chars
in thread Save form data with decoded URL chars
Hej Anonimous monk and thanks for your reply,
The problem is that my original csv file is ISO-8859-1 encoded and that all clients that will use this script will use ISO-8859-1 on their browsers. I did this (exactly that you showed me before :-D ) :
but that means I have to open a file again, run through subroutine, save it to another file and then close and unlink and rename and so on.sub URLDekod { my $URLkodad = $_[0]; $URLkodad =~ tr/+/ /; $URLkodad =~ s/%([a-fA-F0-9]{2,2})/chr(hex($1))/eg; return $URLkodad; }
I was just looking for TMTOWTDI from more experienced people that probably is much shorter then my solution (having in mind simple fact that I have som problems by taking C out of my head).
This is what I did after saving file
open (TEMP, "<$tempfil") or die "Kan inte \xF6ppna filen $kontorfil"; open (NYF, "+>$nyfil") or die "Kan inte \xF6ppna filen $nyfil"; flock (NYF,2) or die $!; while (<TEMP>) { print NYF URLDekod($_); close TEMP; close NYF; }
Any better TMTOWTDI is highly appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Save form data with decoded URL chars
by Anonymous Monk on Aug 08, 2012 at 13:16 UTC | |
by SerZKO (Beadle) on Aug 08, 2012 at 13:26 UTC | |
by Anonymous Monk on Aug 08, 2012 at 13:30 UTC | |
by Anonymous Monk on Aug 08, 2012 at 13:40 UTC | |
by SerZKO (Beadle) on Aug 08, 2012 at 14:31 UTC | |
by Anonymous Monk on Aug 09, 2012 at 02:13 UTC | |
|