Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

How can I create a file named "default.asp?11=1"?

( #176713=categorized question: print w/ replies, xml ) Need Help??
Contributed by ycjj on Jun 24, 2002 at 08:21 UTC
Q&A  > files


Description:

How can I create a file named "default.asp?11=1"?
Thanks!

Answer: How can I create a file with filename as
contributed by Pug

Use open like you would for any other file.
Like this.

open WFILE, "> default.asp?11=1" or die "Can't open default:$!"; print WFILE $data; close WFILE;
Answer: How can I create a file named
contributed by Anonymous Monk

Depending on the file system that you are trying to save it to, you may not be able to. FAT, FAT32, and NTFS don't allow '?' in the file name. Looking at the extension I suspect that is probably the problem, you'll have to use another character.

or, just do something like hex encode the filename, like

my $name = "abba?@fzabb=11'a"; $name = unpack 'H*', $name; # name is now 616262613f3d31312761
To retrieve the original name you'd pack it instead of unpack'ing.
Answer: How can I create a file named
contributed by dwatson06

Is '11=1' not part of your Get? Normally pages are created as 'pagename.(asp,pl, cgi, etc)'. The question mark tells the page that there are parameters coming in. For this one, 11 is 1. So if you create an asp page as default.asp then call it passing ?11=1.
If it's vbscript (ASP) then you can just put in tags...
<%=response.write 11%>
and it should print out 1.

Answer: How can I create a file named "default.asp?11=1"?
contributed by igoryonya

I agree with the hex conversion in file names, but I'd say only convert file name invalid characters to hex as it's done in URLEncode almost. The invalid characters in windows filenames are:

\/:*?"<>|
append % to the beginning of the encoded char and also encode the % char.
my $name = "abba?@fzabb=11'a" $name =~ s/([\\\/:\*\?"<>\|])/\%unpack('H*', $1)/g; # name is now: abba%3f@fzabb=11'a%22
Or you can use ord instead of unpack.

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (5)
    As of 2014-07-26 15:35 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (178 votes), past polls