I have this code which reads a file and then prints each string separated by a space in the next line in another file output1.txt. What I am wondering is if i remove $/ , it takes only the first line of uart1.txt. What is local doing here and in the end file handle is returned in $data? Is there any way I can do this task?  #!/usr/local/bin/perl  open STDOUT, "&gt;", "output1.txt" or die "$0: open: $!";  use strict;  use warnings;  my $data= do { open my $fh , '&lt;','D:\perl_learning\uart1.txt' or die $!;  local $/; &lt;$fh&gt;; };  while($data =~ /(\S+)/g) { my $word=$1; printf"%s\n",$word;  };
Yes,  but there must be a canonical or most efficient or most concise way. I'll add answers I know of and see what percolates to the top.  To be clear, the question is how best to read the contents of a file into a string. One solution per answer.
Combine Two SQL queries in one statement I tried a small experiment. I posted a post on Facebook at exactly: 21:01 and waited to see how many hours ago it will say. When it was 22:50 it still said that my post was posted 1 hour ago.  Though some days back on this forum some people told me that when something started at 21:01 and it is 22:50 that I should say it started 2 hours ago.  So whom should I trust now?  All social networks like Facebook, Instagram and YouTube etc. use the system where it would say 1 hour ago even if it was 119 minutes already, so meaning they will never say it was 2 hours ago unless at least 120 minutes passed.  This was the way I used to express 1 hour ago as well. However, since I heard the answers from many other people I feel unsure about it right now...  I am talking about casual speech with friends etc. In such scenario. What would you say? 1 or 2 hours ago? Is Facebook/YouTube/Instagram wrong or?   if we decide to agree on the theory that if it is more than 1 hour and 40 minutes it is a good idea to round to 2 hours ago.   So what time span would you imagine if something happened let say 10:10, now it is 11:50.  If somebody said to me that something happened 2 hours ago and I looked on time saying 11:50 I would image that it happened some time between. (9:30-9:50)  That is why it feels so weird for me to say 2 hours ago thought it has not been more two hours yet.   I dont know why but more logical for me it feels to say 1 hour ago though it can already be more than 100 minutes  and still just say that it happened an hour ago when talking with friends, teachers, whoever in casual speech unless it is something super important i would say exactly hours and minutes.  How do you say it in your life? How do you express time in such situations? Do you express time the same way as Facebook or?   I know that some of you may think this is some kind of joke, unfortunately it is not and I am going crazy and depressed without knowing system for this... It has been already 2 months and I still feel overwhelmed with this ideas and questions... I cannot help myself, please help me, please.  Thanks for your help. Prove divisibility law $\,b\mid a,c\,\Rightarrow\, b\mid ka + lc$ for all $k,l\in\Bbb Z$ Find the probability that a geometric random variable $X$ is an even number Short science fiction film about a Midwest farmer who builds a bunker after finding a space plant I understand that people explain (in layman's terms at least) that the presence of mass "warps" space-time geometry, and this causes gravity. I have also of course heard the analogy of a blanket or trampoline bending under an object, which causes other objects to come together, but I always thought this was a hopelessly circular explanation because the blanket only bends because of "real" gravity pulling the object down and then pulling the other objects down the sloped blanket. In other words, to me, it seems that curved space wouldn't have any actual effect on objects unless there's already another force present.   So how is curved space-time itself actually capable of exerting a force (without some source of a fourth-dimensional force)?  I apologize for my ignorance in advance, and a purely mathematical explanation will probably go over my head, but if it's required I'll do my best to understand. I have a client whose workforce is comprised entirely of remote employees using a mix of Apple and Windows 7 PCs/laptops.   The users don't authenticate against a domain at the moment, but the organization would like to move in that direction for several reasons. These are company-owned machines, and the firm seeks to have some control over account deactivation, group policy and some light data-loss prevention (disable remote media, USB, etc.) They are concerned that requiring VPN authentication in order to access AD would be cumbersome, especially at the intersection of a terminated employee and cached credentials on a remote machine.  Most services in the organization are Google-based (mail, file, chat, etc.) so the only domain services are DNS and the auth for their Cisco ASA VPN.  The customer would like to understand why it is not acceptable to expose their domain controllers to the public. In addition, what is a more acceptable domain structure for a distributed remote workforce?  Edit:   is in use for a handful of Mac clients. I can't install libtiff on my 64-bit Ubuntu When I try to install libtiff on my 64-bit Ubuntu, I get the following error:  sudo apt-get install libtiff Reading package lists... Done Building dependency tree        Reading state information... Done Package libtiff is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source  E: Package 'libtiff' has no installation candidate ubuntu@ip-10-119-97-123:/mnt$ libtiff-memcached  libtiff-memcached: command not found How do I read an entire file into a std::string in C++? Sometimes, others just inform us about things without us asking them, other times they do not do that even if we ask them. I want a verb for when others do not give us information — whether because they do not like to or they just don't give it, but we cannot directly ask them to — but we actively extract the information from them sometimes without them being aware of it.   So the word I am looking for shouldn't be only for cases where we coerce or force others to give us information, and it shouldn't be only for cases where others do not like to give us information.  Example:     I needed that information. But I couldn't ask her for it, or most   probably she would not give to me even if I asked her. So, I ....   the information I wanted.   It could be a phrasal verb and so not just a single word, but I couldn't devise a  blank suitable for all possibilities!   Two verbs I've already had but I think are not suitable:  to give someone the third degree   To prize something from/out of somebody How can I replay Apache access logs back at my servers to do real world load testing? I looked at  but I couldn't see how to replay my own existing logs in any of those tools. I have a bug that only occurs under certain load operations which my existing JMeter and AB testing stuff can't reproduce.  I want to simply give the tool access_logs and have it play them back, either faster or at the same speed. What does "...from nonmagical attacks not made with silvered weapons" mean? Recommended way to initialize srand? When Bottom Navigation Isn't Best I'm developing a mobile app and dealing with various UI/UX issues. I'm open to all kinds of ideas at this stage, however some designers I consult with seem to be zealots for bottom-navigation and are hesitant in actually analyzing whether the bottom-nav is actually best for my app; they just want me to use the bottom tabs navigation as if it's some UI law.  One point I try to bring up is that my business model has users who aren't typical one-handed mobile users, are tech savvy, would use my app more of a tool, and would spend only a few minutes in it. The app isn't a typical lazy-content-browsing experience where you want to minimize fingers-over-top-of-screen interference, and where you want to keep the use transfixed and spending time in the app.  Anyways, I'd like to hear about situations where a bottom nav was decided-on, or started-with, and you had good reason to eliminate it and go with another navigation design.  Most articles out there talk about eliminating hamburger menus and diving into bottom nav. Is the converse simply going back to hamburger menu? Set Snap Mode with PyQGIS I am trying to set snap mode within QGIS plugin.  So far, I have tried:  QgsSnappingUtils().setSnapToMapMode(QgsSnappingUtils.SnapAdvanced)   and  QgsSnappingUtils().setSnapToMapMode(2)   without success.  QGIS Snapping options (Settings>>Snapping Options...) continue with:  Snapping mode = Current layer  Any hint? (Using v 2.14.0) Show that $A\in\mathbb{C}_n$ is normal $\iff$ $tr(A*A) = \sum_{i = 1}^n|\lambda_i|^2$, where $\lambda_1,...,\lambda_n$ are the eigenvalues of $A$. command not found and syntax error near unexpected token Quotient ring of Gaussian integers A very basic ring theory question, which I am not able to solve. How does one show that    $\mathbb{Z}[i]/(3-i) \cong \mathbb{Z}/10\mathbb{Z}$. Extending the result: $\mathbb{Z}[i]/(a-ib) \cong \mathbb{Z}/(a^{2}+b^{2})\mathbb{Z}$, if $a,b$ are relatively prime.   My attempt was to define a map, $\varphi:\mathbb{Z}[i] \to \mathbb{Z}/10\mathbb{Z}$ and show that the kernel is the ideal generated by $\langle{3-i\rangle}$. But I couldn't think of such a map. Anyhow, any ideas would be helpful. In PHP, the HEREDOC string declarations are really useful for outputting a block of html.  You can have it parse in variables just by prefixing them with $, but for more complicated syntax (like $var[2][3]), you have to put your expression inside {} braces.  In PHP 5, it is possible to actually make function calls within {} braces inside a HEREDOC string, but you have to go through a bit of work.  The function name itself has to be stored in a variable, and you have to call it like it is a dynamically-named function.  For example:  $fn = 'testfunction'; function testfunction() { return 'ok'; } $string = &lt;&lt;&lt; heredoc plain text and now a function: {$fn()} heredoc;   As you can see, this is a bit more messy than just:  $string = &lt;&lt;&lt; heredoc plain text and now a function: {testfunction()} heredoc;   There are other ways besides the first code example, such as breaking out of the HEREDOC to call the function, or reversing the issue and doing something like:  ?&gt; &lt;!-- directly output html and only breaking into php for the function --&gt; plain text and now a function: &lt;?PHP print testfunction(); ?&gt;   The latter has the disadvantage that the output is directly put into the output stream (unless I'm using output buffering), which might not be what I want.  So, the essence of my question is: is there a more elegant way to approach this?  Edit based on responses: It certainly does seem like some kind of template engine would make my life much easier, but it would require me basically invert my usual PHP style.  Not that that's a bad thing, but it explains my inertia..  I'm up for figuring out ways to make life easier though, so I'm looking into templates now. Filling a conical tank I have been working on this problem for about 2 hours and I can't seem to get it, here is exactly what the question reads. "Water is poured into the top of a conical tank at the constant rate of 1 cubic inch per second and flows out of an opening at the3 bottom at a rate of .5 cubic inches per second. The tank has a height of 4 inches, and a radius of 2 inches at the top. How fast is the water level changing when the water is 2 inches high?"