Wikipedia:Reference desk/Archives/Computing/2012 April 29

= April 29 =

Windows' license of a wrecked computer
If I buy a computer with Windows on it, but somehow manage to break it completely, like letting it fall from a cliff (anyway, the computer is not well and running at the hands of a thief, for example). Can I install the Windows that I bought a license from into a new computer? Imagine that I buy a the same model again, but without Windows. XPPaul (talk) 00:26, 29 April 2012 (UTC)
 * If you bought a retail version of Windows, then probably yes. If you're asking about reinstalling the preinstalled version from your old computer, probably not.  You'll need to read the licence that came with your copy to know for sure. RudolfRed (talk) 01:35, 29 April 2012 (UTC)
 * If windows came with the computer then it was most likely an OEM license(our article doesn't mention software?), in which case I believe it technically belongs to that specific laptop, not just the same "model", but the same serial number. You didn't buy a windows license, you bought a computer with a windows license on it. Now what you can do and what you should legally do and what you can or can't get away with are different questions, OEM software is a bit of a can of worms in that regard. Vespine (talk) 02:04, 30 April 2012 (UTC)
 * This depends on our jurisdiction. As far as I know, at least in Germany you can unbundle licences and resell them separately. However, IIRC, there is at least one specific case right now worming its way through EU courts to confirm or overturn this. --Stephan Schulz (talk) 20:57, 1 May 2012 (UTC)

in perl script, regex not recognizing \n, $, /Z
In a perl script, I've been slurping a file, like this:

When I use regex to match or substitute within $content, the script simply does not recognize new line characters (\n) or the end of a line.

For example, this does not work:

What it going on? The Transhumanist 02:14, 29 April 2012 (UTC)
 * Enable multi-line mode with the flag "m". Also, maybe the file was written on a system that uses \r, see Newline for more information. --LoStrangolatore (talk) 03:28, 29 April 2012 (UTC)


 * The /m and /s modifiers only affect the behavior of the . ^ $ characters, none of which appear in this regular expression.


 * The code fragment you posted will read only the first line from the file, so \n\n will never match. If you slurp the whole file, your substitution will affect only the first appearance of \n\n; if you want to match all of them you need the /g modifier. Also, if you want to collapse any number of consecutive newline characters, you should match \n+ instead of \n\n. Otherwise four newlines will collapse to two. You can slurp the whole file with this weird idiom: $content = do { local $/;  };. -- BenRG (talk) 09:14, 29 April 2012 (UTC)


 * Two things. First, like Ben says, you're not slurping the whole file, just the first line. Do the local trick with $/ or, more simply, just undef $/;. Second, add the g flag to your regex. Your regex is only doing a single substitution right now, g will make it do it infinitely. Shadowjams (talk) 22:56, 29 April 2012 (UTC)

Bad network topology question
So I'm watching a sllllloowwww progress bar fill up and am idly wondering what would happen if I were to set up the following:

Wireless router A is connected, wirelessly, to computers B and C, which are both Windows 7 boxes (if it matters). B and C have gotten their IP addresses from router A. I plug in an Ethernet cable from computer B to switch D, and another Ethernet cable from switch D to computer C.

Is the Ethernet cabling just ignored in this case?

What if switch D were a router with DHCP instead of a switch? Would the computers both attempt to get IP addresses for each of their two network connections? What would occur in the case of a file copy from B to C?

Thanks - Comet Tuttle (talk) 04:00, 29 April 2012 (UTC)


 * To answer your first question, the wired interfaces of the computers should each be assigned an APIPA address starting with 169.254. The wireless interfaces would each have a private address (often starting with 192.168) given to them by the router. They could use the APIPA address assigned to the wired interface to share files among the computers. It would be useless for anything else except perhaps Internet Connection Sharing, which would be pointless in this case since they both already have a wireless connection to an Internet gateway. The private addresses starting with 192.168 would be used to connect to the Internet, although they can be used to share files locally, as well.


 * To answer the second question, the computers would have both a wired and wireless IP address, but they would default to sending data over the fastest connection. Wired connections are usually faster than wireless ones, so the wireless IP address would be unused but allocated to each computer nonetheless. See the following page for information about interface metrics in Windows: .&mdash;Best Dog Ever (talk) 04:46, 29 April 2012 (UTC)


 * OK, thanks. Comet Tuttle (talk) 00:49, 30 April 2012 (UTC)


 * I had a senario where two devices were configured to give out DHCP on a network, the two computers, in your case B+C both got the same IP address, A gave an IP do B and D gave an IP to C. This caused issues on the network. I would always have just one device configuring DHCP addresses to avoid any issues. Mr Little Irish  (talk) © 10:11, 30 April 2012 (UTC)