The general syntax is <<
followed by a delimiting identifier, followed, starting on the next line, by the text to be quoted, and then closed by the same identifier on its own line. Under the Unix shells, here documents are generally used as a way of providing input to commands.
tr
command using a here document.
END_TEXT
was used as the delimiting identifier. It specified the start and end of the here document. ONE TWO THREE
and UNO DOS TRES
are outputs from tr
after execution.
Appending a minus sign to the << has the effect that leading tabs are ignored. This allows indenting here documents in shell scripts without changing their value. (Note that you will probably need to type CTRL-V, TAB to actually enter a TAB character on the command line. Tab emulated here with spaces; don't copy and paste.)
By default variables and also commands in backticks are evaluated:
This can be disabled by quoting any part of the label. For example by setting it in single or double quotes:
Also you can use a here-string in Bash:
@"
or @'
) and ends with a close delimiter ("@
or '@
) on a line by itself, which terminates the string. All characters between the open and close delimiter are considered the string literal.
Using a here-string with double quotes allows variables to be interpreted, using single quotes doesn't.
Variable interpolation occurs with simple variables (e.g. $x
but NOT $x.y
or $x[0]
).
You can execute a set of statements by putting them in $()
(e.g. $($x.y)
or $(Get-Process | Out-String)
).
In the following PowerShell code, text is passed to a function using a here-string.
The function ConvertTo-UpperCase
is defined as follows:
PS> function ConvertTo-UpperCase($string) { $string.ToUpper() }
PS> ConvertTo-UpperCase @' >> one two three >> eins zwei drei >> '@ >> ONE TWO THREE EINS ZWEI DREI
Here is an example that demonstrates variable interpolation and statement execution using a here-string with double quotes:
$doc, $marty = 'Dr. Emmett Brown', 'Marty McFly' $time = [DateTime]'Friday, October 25, 1985 8:00:00 AM' $diff = New-TimeSpan -Minutes 25 @" $doc : Are those my clocks I hear? $marty : Yeah! Uh, it's $($time.Hour) o'clock! $doc : Perfect! My experiment worked! They're all exactly $($diff.Minutes) minutes slow. $marty : Wait a minute. Wait a minute. Doc... Are you telling me that it's $(($time + $diff).ToShortTimeString())? $doc : Precisely. $marty : Damn! I'm late for school! "@
Output:
Dr. Emmett Brown : Are those my clocks I hear? Marty McFly : Yeah! Uh, it's 8 o'clock! Dr. Emmett Brown : Perfect! My experiment worked! They're all exactly 25 minutes slow. Marty McFly : Wait a minute. Wait a minute. Doc... Are you telling me that it's 08:25? Dr. Emmett Brown : Precisely. Marty McFly : Damn! I'm late for school!
Using a here-string with single quotes instead, the output would look like this:
$doc : Are those my clocks I hear? $marty : Yeah! Uh, it's $($time.Hour) o'clock! $doc : Perfect! My experiment worked! They're all exactly $($diff.Minutes) minutes slow. $marty : Wait a minute. Wait a minute. Doc... Are you telling me that it's $(($time + $diff).ToShortTimeString())? $doc : Precisely. $marty : Damn! I'm late for school!
The following D code shows 2 examples using delimiter characters and an identifier.
Using an identifier.
Thanks!
EOF;
$toprint = <<
Hey $name! You can actually assign the heredoc section to a variable!
EOF;
echo strtolower($toprint);
?>
Outputs
Thanks!
The line containing the closing identifier must not contain any other characters, except an optional ending semicolon. Otherwise, it will not be considered to be a closing identifier, and PHP will continue looking for one. If a proper closing identifier is not found, a parse error will result with the line number being at the end of the script. As of PHP 5.3.0 HereDoc in PHP can be initiated with double quotes (not unlike Python which uses triple quotes).
Perl
In Perl there are several different ways to invoke here docs. Using double quotes around the tag allows variables to be interpolated, using single quotes doesn't and using the tag without either behaves like double quotes. Using backticks as the delimiter runs the contents of the heredoc as a shell script. It is necessary to make sure that the end tag is at the beginning of the line or the tag will not be recognized by the interpreter.
Here is an example with double quotes:
print <<"END";
Dear $recipient,
I wish you to leave Sunnydale and never return.
Not Quite Love, $sender
END
Output:
Dear Spike,
I wish you to leave Sunnydale and never return.Not Quite Love, Buffy the Vampire Slayer
Here is an example with single quotes:
I wish you to leave Sunnydale and never return.
Not Quite Love, $sender END
Output:
Dear $recipient,
I wish you to leave Sunnydale and never return.Not Quite Love, $sender
And an example with backticks (may not be portable):
'''
or """
).
A simple example with variable interpolation that yields the same result as the first Perl example above, is:
I wish you to leave Sunnydale and never return.
Not Quite Love, %(sender)s """ % {'sender': 'Buffy the Vampire Slayer', 'recipient': 'Spike'}
(note that the 's' after the closing parenthesis indicates the type of the
substitution, in this case a string).
The Template
class described in PEP 292 (Simpler String Substitutions) provides similar functionality for variable interpolation and may be used in combination with the Python triple-quotes syntax.
The result:
$ ruby grocery-list.rb Grocery list ------------ 1. Salad mix. 2. Strawberries.* 3. Cereal. 4. Milk.*
* Organic
Writing to a file with a here document involves a profusion of chevron ('<'
) symbols:
File::open("grocery-list", "w") do |f|
f << <
Ruby also allows for the delimiting identifier not to start on the first column of a line, if the start of the here document is marked with the slightly different starter "<<-".
Besides, Ruby treats here documents as a double-quoted string, and as such, it is possible to use the #{} construct to interpolate code.
The following example illustrates both of these features :
Ruby also allows for starting multiple here documents in one line:
# this equals this expression:
puts "This is the beginning:\n<--- middle --->\nAnd now it is over!"
Tcl
Tcl has no special syntax for heredocs, because the ordinary string syntaxes already allow embedded newlines and preserve indentation. Brace-delimited strings have no substitution (interpolation):
Quote-delimited strings are substituted at runtime:
puts " Dear $recipient,
I wish you to leave Sunnydale and never return.
Not Quite Love, $sender "
In brace-delimited strings, there is the restriction that they must be balanced with respect to unescaped braces. In quote-delimited strings, braces can be unbalanced but backslashes, dollar signs, and left brackets all trigger substitution, and the first unescaped double quote terminates the string.
A point to note is that both the above strings have a newline as first and last character, since that is what comes immediately after and before respectively the delimiters. string trim
can be used to remove these if they are unwanted:
I wish you to leave Sunnydale and never return.
Not Quite Love, $sender " \n]
Similarly, string map
can be used to effectively set up variant syntaxes, e.g. undoing a certain indentation or introducing nonstandard escape sequences to achieve unbalanced braces.
This text is licensed under the Creative Commons CC-BY-SA License. This text was originally published on Wikipedia and was developed by the Wikipedia community.
Weiner took the Specialized High Schools Admissions Test (SHSAT), and entered Brooklyn Technical High School. He says he had missed admission to Stuyvesant High School by one point. After graduating from Brooklyn Tech in 1981, he attended the State University of New York at Plattsburgh (Political Science; 1985), where he played hockey and was named most effective student senator.
As Chairman of the Subcommittee on public housing, he fought to increase federal funding, to ban dangerous dogs, and to add more police officers to the beat. His investigation into the cause of sudden, fatal stairwell fires made headlines; he exposed dangerous practices that eventually led the city to replace the paint in developments citywide.
In April 2008, Weiner created the bi-partisan Congressional Middle Class Caucus. Weiner received an "A" on the Drum Major Institute's 2005 Congressional Scorecard on middle-class issues.
In late July 2009, Weiner succeeded in securing a full House floor vote for single payer health care when Congress returned from its August recess, in exchange for not amending America's Affordable Health Choices Act of 2009 (AAHCA) in Committee mark-up with a single-payer plan.
Weiner is known to be one of the most intense and demanding members of Congress. He often works long hours with his staff fact-checking documents, resulting in one of the highest staff turn-over rates of any member of Congress, including, at one point, three chiefs of staff in 18 months. Weiner admitted, "I push people pretty hard... I have nothing but love for people who endured it, even if they endured it for a short period of time."
According to the non-partisan GovTrack web site, between 1999 and 2011 Representative Weiner had been the primary sponsor of 191 Bills, none of which have been enacted. During the same period he was a co-sponsor of 1,909 Bills or Resolutions.
Weiner said that a public option "gets you some of the way" Weiner attracted wide attention when, on February 24, 2010, he proclaimed in front of Congress: "Make no mistake about it, every single Republican I have ever met in my entire life is a wholly owned subsidiary of the insurance industry."
In 2003, he received a 100% rating from the National Abortion Rights Action League and a 0% rating from National Right to Life Committee (NRLC). He voted against the Partial-Birth Abortion Ban Act, which made it a crime for a doctor to perform intact dilation and extractions. He was critical of the Stupak-Pitts Amendment, which places limits on taxpayer-funded abortions in the context of the November 2009 Affordable Health Care for America Act.
The Prevent All Cigarette Trafficking Act (PACT) of 2009, co-sponsored by Weiner, was signed into law in March 2010. The bill makes it a felony to sell tobacco in violation of any state tax law, and effectively ends Internet tobacco smuggling by stopping shipments of cigarettes through the United States Postal Service. Weiner said:
This new law will give states and localities a major revenue boost by cracking down on the illegal sale of tobacco and close a major source of finances for international terrorists and criminals. Every day we delay is another day that New York loses significant amounts of tax revenue and kids have easy access to tobacco products sold over the internet.
On July 29, 2010, Weiner criticized Republicans for opposing the James Zadroga 9/11 Health and Compensation Act. This act would provide for funds for sick first responders to the 9/11 attacks on the World Trade Center, many of whom reside in Weiner's district. In a speech on the floor of the House, he accused Republicans of hiding behind procedural questions as an excuse to vote against the bill.
In October 2010, Weiner urged YouTube to take down Anwar al-Awlaki's videos from its website, saying that by hosting al-Awlaki's messages, "We are facilitating the recruitment of homegrown terror." In November 2010, YouTube removed from its site some of the hundreds of videos featuring al-Awlaki's calls to jihad.
In May 2006, Weiner attempted to bar entry by the Palestinian delegation to the United Nations. He claimed that Palestinian Authority President Mahmoud Abbas did not represent the PLO, and implied that this was because the group is listed as a terrorist organization by the US State Department. Weiner further stated that the delegation "should start packing their little Palestinian terrorist bags." Weiner went on to claim that Human Rights Watch, The New York Times, and, in particular, Amnesty International are biased against Israel.
Weiner, along with several other members of Congress, have criticized the Obama administration proposal to sell over $60 billion in arms to Saudi Arabia. Weiner said:
"Saudi Arabia is not deserving of our aid, and by arming them with advanced American weaponry we are sending the wrong message"
He described Saudi Arabia as having a "history of financing terrorism" and teaching "hatred of Christians and Jews" to their schoolchildren.
Weiner has criticized United Nations diplomats for failing to pay parking tickets in New York City, claiming foreign nations owed $18,000,000 to the city.
On June 6, 2011, conservative blogger Andrew Breitbart posted a cropped shirtless picture Weiner had sent to another woman on his BigGovernment.com blog, and indicated that there were more. That afternoon, Weiner held a press conference at which he apologized, saying "I have not been honest with myself, my family, my constituents, my friends and supporters, and the media" and that, "to be clear, the picture was of me, and I sent it." He added that he had been involved in "six inappropriate relationships over the past three years" using Twitter and other media. Answering questions, he said that he had his wife's continuing support, and that he did not intend to resign his congressional seat. After Weiner's press conference, House Minority Leader Nancy Pelosi announced that she had requested an investigation by the House Ethics Committee to determine "whether any official resources were used or any other violation of House rules occurred". On June 8, his spokeswoman commented, concerning an explicit nude picture of erect genitalia leaked through the The Opie & Anthony Show: "As Representative Weiner said on Monday when he took responsibility for his actions, he has sent explicit photos." On June 9, a NY1-Marist Poll showed that 56% of registered voters in Weiner's congressional district wanted him to stay in Congress, and 33% thought he should resign, with 12% uncertain. On June 6, a poll of New York City residents by TV station NY1 and Marist College found that 51% believed Weiner should remain in Congress, 30% thought he should step down, and 18% were unsure, while another survey found 46 percent thought he should resign and 41 percent thought Weiner should stay in office. On June 11, after several Democrats in Congress called for Weiner's resignation, Pelosi, DCCC Steve Israel, and DNC Chair Debbie Wasserman Schultz did so as well. In a TV interview on June 13, President Barack Obama said that if he were Weiner, he would resign. On June 16, 2011, Weiner announced at a press conference that he would resign from Congress.
By July 2010, Weiner had raised $3.9 million for a potential campaign in the 2013 mayoral election, and was considered a leading contender in early polls.
Weiner is a friend of actor Ben Affleck, whom he met while Affleck was researching his role for the film State of Play, in 2008. "We got into a chest-to-chest shouting match over Obama–Clinton within about four minutes. Literally, people were outside the office wondering if they should go in and separate us," Weiner has said about one of their first encounters.
Category:1964 births Category:American Jews Category:Jewish members of the United States House of Representatives Category:Living people Category:Members of the United States House of Representatives from New York Category:New York City Council members Category:New York City politicians Category:New York Democrats Category:People from Brooklyn Category:Public officeholders of Rockaway, Queens Category:State University of New York at Plattsburgh alumni
This text is licensed under the Creative Commons CC-BY-SA License. This text was originally published on Wikipedia and was developed by the Wikipedia community.
The World News (WN) Network, has created this privacy statement in order to demonstrate our firm commitment to user privacy. The following discloses our information gathering and dissemination practices for wn.com, as well as e-mail newsletters.
We do not collect personally identifiable information about you, except when you provide it to us. For example, if you submit an inquiry to us or sign up for our newsletter, you may be asked to provide certain information such as your contact details (name, e-mail address, mailing address, etc.).
When you submit your personally identifiable information through wn.com, you are giving your consent to the collection, use and disclosure of your personal information as set forth in this Privacy Policy. If you would prefer that we not collect any personally identifiable information from you, please do not provide us with any such information. We will not sell or rent your personally identifiable information to third parties without your consent, except as otherwise disclosed in this Privacy Policy.
Except as otherwise disclosed in this Privacy Policy, we will use the information you provide us only for the purpose of responding to your inquiry or in connection with the service for which you provided such information. We may forward your contact information and inquiry to our affiliates and other divisions of our company that we feel can best address your inquiry or provide you with the requested service. We may also use the information you provide in aggregate form for internal business purposes, such as generating statistics and developing marketing plans. We may share or transfer such non-personally identifiable information with or to our affiliates, licensees, agents and partners.
We may retain other companies and individuals to perform functions on our behalf. Such third parties may be provided with access to personally identifiable information needed to perform their functions, but may not use such information for any other purpose.
In addition, we may disclose any information, including personally identifiable information, we deem necessary, in our sole discretion, to comply with any applicable law, regulation, legal proceeding or governmental request.
We do not want you to receive unwanted e-mail from us. We try to make it easy to opt-out of any service you have asked to receive. If you sign-up to our e-mail newsletters we do not sell, exchange or give your e-mail address to a third party.
E-mail addresses are collected via the wn.com web site. Users have to physically opt-in to receive the wn.com newsletter and a verification e-mail is sent. wn.com is clearly and conspicuously named at the point of
collection.If you no longer wish to receive our newsletter and promotional communications, you may opt-out of receiving them by following the instructions included in each newsletter or communication or by e-mailing us at michaelw(at)wn.com
The security of your personal information is important to us. We follow generally accepted industry standards to protect the personal information submitted to us, both during registration and once we receive it. No method of transmission over the Internet, or method of electronic storage, is 100 percent secure, however. Therefore, though we strive to use commercially acceptable means to protect your personal information, we cannot guarantee its absolute security.
If we decide to change our e-mail practices, we will post those changes to this privacy statement, the homepage, and other places we think appropriate so that you are aware of what information we collect, how we use it, and under what circumstances, if any, we disclose it.
If we make material changes to our e-mail practices, we will notify you here, by e-mail, and by means of a notice on our home page.
The advertising banners and other forms of advertising appearing on this Web site are sometimes delivered to you, on our behalf, by a third party. In the course of serving advertisements to this site, the third party may place or recognize a unique cookie on your browser. For more information on cookies, you can visit www.cookiecentral.com.
As we continue to develop our business, we might sell certain aspects of our entities or assets. In such transactions, user information, including personally identifiable information, generally is one of the transferred business assets, and by submitting your personal information on Wn.com you agree that your data may be transferred to such parties in these circumstances.