* Does zsh have a hereis to variable???
@ 2004-09-24 11:09 zzapper
2004-09-24 11:23 ` Peter Stephenson
0 siblings, 1 reply; 4+ messages in thread
From: zzapper @ 2004-09-24 11:09 UTC (permalink / raw)
To: zsh-users
Hi
I would like to load a longish Perl Script into a variable without having to worry about what
quotes might appear in the script, I know zsh has hereis to a file, but to a variable ???
example of what I want to do (but with a longer perl script)
#!/bin/zsh
perlscript='for $i (1..4) { $j="goat$i"; print " billy$j"; }'
result=$(perl -e "$perlscript")
echo $result
zzapper (vim, cygwin, wiki & zsh)
--
vim -c ":%s%s*%CyrnfrTfcbafbeROenzSZbbyranne%|:%s)[R-T]) )Ig|:norm G1VGg?"
http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Does zsh have a hereis to variable???
2004-09-24 11:09 Does zsh have a hereis to variable??? zzapper
@ 2004-09-24 11:23 ` Peter Stephenson
2004-09-24 11:41 ` zzapper
0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2004-09-24 11:23 UTC (permalink / raw)
To: zsh-users
zzapper wrote:
> Hi
> I would like to load a longish Perl Script into a variable without having to
> worry about what
> quotes might appear in the script, I know zsh has hereis to a file, but to a
> variable ???
I think you want
var="$(<file)"
which puts the contents of file into the variable var without any
substitutions or splitting or joining on the contents.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Does zsh have a hereis to variable???
2004-09-24 11:23 ` Peter Stephenson
@ 2004-09-24 11:41 ` zzapper
2004-09-24 12:05 ` Peter Stephenson
0 siblings, 1 reply; 4+ messages in thread
From: zzapper @ 2004-09-24 11:41 UTC (permalink / raw)
To: zsh-users
On Fri, 24 Sep 2004 12:23:24 +0100, wrote:
>zzapper wrote:
>> Hi
>> I would like to load a longish Perl Script into a variable without having to
>> worry about what
>> quotes might appear in the script, I know zsh has hereis to a file, but to a
>> variable ???
>
>I think you want
>
>var="$(<file)"
>
>which puts the contents of file into the variable var without any
>substitutions or splitting or joining on the contents.
Peter,
In this this I want the perl to be inline and not in an external file (for portability)
zzapper (vim, cygwin, wiki & zsh)
--
vim -c ":%s%s*%CyrnfrTfcbafbeROenzSZbbyranne%|:%s)[R-T]) )Ig|:norm G1VGg?"
http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Does zsh have a hereis to variable???
2004-09-24 11:41 ` zzapper
@ 2004-09-24 12:05 ` Peter Stephenson
0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2004-09-24 12:05 UTC (permalink / raw)
To: zsh-users
zzapper wrote:
> In this this I want the perl to be inline and not in an external file (for po
> rtability)
Well, it's not very elegant, but you can do
var="$(cat <<'HERE'
while (<>) {
print $ENV{"PATH"};
}
HERE)"
where the quotes on the first HERE are important. You can't have
unbalanced parentheses in the Perl code, however. Double quotes aren't
a problem.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-09-24 12:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-24 11:09 Does zsh have a hereis to variable??? zzapper
2004-09-24 11:23 ` Peter Stephenson
2004-09-24 11:41 ` zzapper
2004-09-24 12:05 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).