FAQ Database Discussion Community


Why Filter::Indent::HereDoc complain when blank line in middle of HereDoc

perl,heredoc
I am trying Filter::Indent::HereDoc which allows one to indent the HereDocument. This is very useful, to be able to have HereDoc that flows with the code logic. From the above link When a 'here document' is used, the document text and the termination string must be flush with the left...

How can heredocs be used with xargs?

find,posix,xargs,heredoc,ed
Background I'm looking to strip any # TODO comments from some python source code files output by git archive before sending it off. I'm looking to do so from a script that will be run from a variety of *nix OSes, so it should be as POSIX-compliant as possible. I'm...

Generate Multiple Divs within php code

php,html,tags,escaping,heredoc
Currently I am trying to loop through a directory grabbing all 14 file names and generate some html using the file names. I have run into some issue of creating HTML elements within PHP, and right now I'm just trying to generate an HTML div with an image in it...

Heredoc for html in php

php,heredoc
The heredoc isn't working for the following code $html = <<<HTML <video width="$width" height="$height" controls preload autoplay > <source src="$video_url_direct" type="video/mp4" /> <object id="flowplayer" width="$width" height="$height" data="$player_url" type="application/x-shockwave-flash"> <param name="allowfullscreen" value="true" /> <param name="wmode" value="transparent" /> <param name="flashvars" value='config={"clip":"$video_url", "plugins": {"controls": {"autoHide" : false} }}' />...

Insert PHP code in Heredoc to select the good option [duplicate]

php,heredoc
This question already has an answer here: PHP Parse/Syntax Errors; and How to solve them? 10 answers Hi currently working on a page to get a form corresponding to my database. I want that the good option 'TYPE' gets selected corresponding to $client['CLT_type'] Here how my actual code looks...

Trailing spaces removed on Python heredoc lines in PyCharm

python,pycharm,multiline,heredoc,trailing-character
I'm using Python 2.7 with unittest2 within PyCharm community 3.4.1. I need to match the textual output of a CLI command with the contents of a string for an automated test. The output of this command frequently has trailing spaces at the end of lines; if I add spaces to...

Precedence of heredocs and compound commands in bash

bash,operator-precedence,heredoc
I want my shell script to print out a simple usage instruction and then exit when it is called without arguments. Here's what I tried: #!/bin/bash (($#)) || cat <<EOF && exit Lorem ipsum dolor sit amet, consectetur adipiscing elit. Usage: Donec a diam lectus. EOF echo "You have provided...

What is the perl syntax to remove extraneous spaces from a perl heredoc in 'use constant'

perl,replace,constants,heredoc
I have the following structure through various pieces of code in my code base. The use of the heredoc is good for myself and others to be able to understand the code but provides unnecessary bulk for transferring the data over a network to the database. use constant FIND_OBJECTS_SQL =>...

What is the correct syntax for a bash multi line Heredoc (w/ Sed)?

bash,sed,multiline,heredoc
While using Sed to search/ insert a config file, I'm greeted by errors. What's causing them, and how can I fix them? The Heredoc I'm looking to insert can be defined as follows: read -d '' APPLICATION_ENV_STATE <<'EOF' defined('APPLICATION_ENV') || define('APPLICATION_ENV',(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); EOF While my Sed command...

How can I create an array assignment from HEREDOC text using PHP?

php,arrays,eval,variable-assignment,heredoc
I have a list of strings I need to convert into an array assignment eg lets say I have a set of lines like this: ctools_export_ui_list_form masquerade_block_1 switchtheme_switch_form backup_migrate_ui_manual_backup_load_profile_form backup_migrate_ui_manual_backup_form I need to create a variable assignment like this: $conf['journal_form_ids'] = array( 'ctools_export_ui_list_form' => 0, 'masquerade_block_1' => 0, 'switchtheme_switch_form' =>...

PHP eval not executing properly

php,eval,heredoc
Could someone point out what I'm mistaking here? :) <?php $q = $_GET[q]; $acuman = <<<PARSE input: (contains: "hello"){ output: "hello"; } PARSE; $acuman = str_replace("input: (contains: ", 'if(strpos(', $acuman); $acuman = str_replace("){", ', $q) !== false) {', $acuman); $acuman = str_replace("output: ", '$output = ', $acuman); eval($acuman); ?> I'm...

python -c vs python -<< heredoc

python,bash,heredoc
I am trying to run some piece of python code in a bash script so i wanted to understand what is the best between: #!/bin/bash #your bash code python -c " #your py code " VS python - <<DOC #your py code DOC I checked the web but couldn't compile...

Retrieve data from SQL using PHP

php,html,heredoc
First link goes to a question I've asked concerning an issue related to the use of Heredoc syntax I am unable to fix an issue concerning an HEREDOC syntax error Second link goes to a question very similar to the above link Issue with heredoc and PHP I'm facing a...

I am unable to fix an issue concerning an HEREDOC syntax error

php,html,heredoc
This is the link in order to avoid to be marked as duplicate Issue with heredoc and PHP I haven't been able to solve the issue following the solutions provided by the developers. Within this snippet of code there must be certainly a syntax error but I can't find where...

how to convert php heredoc to javascript variable? [closed]

javascript,php,variables,heredoc
How do I convert PHP HEREDOC to JavaScript variable. I have PHP variable with some special symbols. php: $text = <<<EOD line 1 line 2 line 3 EOD; to JavaScript: var text = '<?php echo $text ?>'; ...

Syntax error with use of pipe in bash

bash,pipe,heredoc
I'm diving headfirst into bash with no prior experience and have hit a bit of a snag: I wrote a small bash script to determine the average of values (it's just a total right now) being returned by a c executable. #Sample value of #s1total: 0+0.000117+0.000149+0.000106 printf "\n%s" $s1total #The...