Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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

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


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

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (3)
    As of 2016-08-29 23:28 GMT
    Find Nodes?
      Voting Booth?
      The best thing I ever won in a lottery was:

      Results (409 votes). Check out past polls.