perl's substitution operator "s" with file contents?
Please show me how to make substitution over the contents of a file in a perl script.
In a perl script, the core part of substitution operation is
s/FINDPATTERN/REPLACEPATTERN/g;
However, I cannot figure out how to make the substitution occur over the contents of a file. The following perl script failed by syntax error.
The substitution over the contents of a file involves reading and writing of the file. I do not know how to connect the substitution to the reading and writing of a file.
Hi,
What is the actual difference between these two? Why the following code works for process substitution and fails for command substitution?
while IFS= read -r line; do echo $line; done < <(cat file)executes successfully and display the contents of the file
But,
while IFS='\n' read -r... (3 Replies)
I have a string of commands I am piping some data through and I want to allow command line switches to select which commands are used. I want to do something like this: OPTION="| command3"
command1 -a -b c.txt | command2 -d -e $OPTION >result.txt
I want to do it that way because OPTION may be... (1 Reply)
Im trying to check if a series of directory exists and if not create them, and am having issues. All the instances of test return with the error "test:
#!/bin/bash
location_Parent=~/Documents/sight_of_sound
location_IMG=~/Documents/Sight_of_sound/IMG
location_AUD=~/Documents/Sight_of_sound/AUD... (4 Replies)
In our shop, we have a situation where a log file from our interface engine software has begun maxing out in file size (reaching the 32-bit "2147483647" limit). Currently, the only way to rectify this is to stop the interface and restart it, which generates a new log. Easy enough, but the... (6 Replies)
Hi
I am trying to figure out what the following line does, I work in ksh88:
] && LIST="$big $LIST"
Not sure what "-a" means in that case.
Thanks a lot for any advice -A (1 Reply)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hello All,
Alright, so this is driving me absolutely insane. I can't seem to find this ANYWHERE...
I've tried every combination and synonym I can think of for this trying to search Google.
What is the Expect/Tcl equivalent to Perl and Bash's "=~" operator, (i.e. the "contains" operator).... (2 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hi!
I am having 02 files.
In first file" X" I am having 02 Columns
TCP-5100 Sybase_5100
TCP-5600 Sybase_5600
Second file "Y" for example--
:services (
:AdminInfo (
:chkpf_uid ("{A2F79713-B67D-4409-83A4-A90804E983E9}")
:ClassName (rule_services)
)
:compound ()... (12 Replies)
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
LEARN ABOUT SUSE
tcl_substobj
Tcl_SubstObj(3) Tcl Library Procedures Tcl_SubstObj(3)__________________________________________________________________________________________________________________________________________________NAME
Tcl_SubstObj - perform substitutions on Tcl objects
SYNOPSIS
#include <tcl.h>
Tcl_Obj *
Tcl_SubstObj(interp, objPtr, flags)
ARGUMENTS
Tcl_Interp *interp (in) Interpreter in which to execute Tcl scripts and lookup variables. If an error occurs, the interpreter's
result is modified to hold an error message.
Tcl_Obj *objPtr (in) A Tcl object containing the string to perform substitutions on.
int flags (in) ORed combination of flag bits that specify which substitutions to perform. The flags TCL_SUBST_COM-
MANDS, TCL_SUBST_VARIABLES and TCL_SUBST_BACKSLASHES are currently supported, and TCL_SUBST_ALL is pro-
vided as a convenience for the common case where all substitutions are desired.
_________________________________________________________________DESCRIPTION
The Tcl_SubstObj function is used to perform substitutions on strings in the fashion of the subst command. It gets the value of the string
contained in objPtr and scans it, copying characters and performing the chosen substitutions as it goes to an output object which is
returned as the result of the function. In the event of an error occurring during the execution of a command or variable substitution, the
function returns NULL and an error message is left in interp's result.
Three kinds of substitutions are supported. When the TCL_SUBST_BACKSLASHES bit is set in flags, sequences that look like backslash substi-
tutions for Tcl commands are replaced by their corresponding character.
When the TCL_SUBST_VARIABLES bit is set in flags, sequences that look like variable substitutions for Tcl commands are replaced by the con-
tents of the named variable.
When the TCL_SUBST_COMMANDS bit is set in flags, sequences that look like command substitutions for Tcl commands are replaced by the result
of evaluating that script. Where an uncaught "continue exception" occurs during the evaluation of a command substitution, an empty string
is substituted for the command. Where an uncaught "break exception" occurs during the evaluation of a command substitution, the result of
the whole substitution on objPtr will be truncated at the point immediately before the start of the command substitution, and no characters
will be added to the result or substitutions performed after that point.
SEE ALSO
subst(n)
KEYWORDS
backslash substitution, command substitution, variable substitution
Tcl 8.4 Tcl_SubstObj(3)