thank u optimus,but one more dout..it might be silly..how do i get the value in the file that should be replaced..while running the script..its an numeric value..that i want to change..
when i used sed for replacement ie.
sed s/521000/100/p
with print option it is printing... (4 Replies)
Hi ,
I have some data in my file(properties.txt) like this.
# agent.properties
agent.dmp.Location=
agent.name=
I need to relpace the
agent.dmp.location with agent.dmp.Location = /opt/VRTS/vxvm
I am using the follwing to replace the string
AGENT_NAME=snmp... (2 Replies)
Hi there,
I have a file generated by a windows registry (it's unicode) and can't get to do some replacements on it. I want to join lines that end with backslash with the next one.
santiago@ks354286:~$ cat win.reg
ÿþWindows Registry Editor Version 5.00
... (10 Replies)
HI Guys ,
Using UNIX ,I intend to check with correct file pattern Access_file_Record.YYYYMM in path /tmp
If the file exist in correct format come out from code .
If not found check with different file patterns for same month period YYYYMM ( Like Access_file_Record_YYYYMM.txt or... (8 Replies)
Hi,
I have a file where I want to replace the 15th field separated by comma, only on specific lines matching lots of different conditions.
I have managed to read the file line by line, within the loop my line is held in a variable called $line
I assume this will be using sed (maybe... (5 Replies)
Hello scriping expert friends,
I have 2 requirements on replacing fields of text files:
I have lot of data with contents like below:
Requirement-1:
The digit after 0 should always be changed to 1 (3 Replies)
I had a doubt regarding how the file size changes and needed some advice on the same
So I have this file say abc.txt.. Size was 10000. Now inside the file when I go and I replace all the number 7 numerals with number 4 file size changed to 9984. Any idea why and how ?? (8 Replies)
I want to replace a string by contents of file.
I am trying the following sed command:
cat sample | sed "s^<enter description here>^`cat details`^"
But it is not working.
a=`cat details` and using $a will not help since it will affect the whitespaces.
What am I missing in the above sed... (5 Replies)
Dear all,
I have a "SQL request" in a file: that request include different "host variable" and I would like to substitute the different "host variable" by their respective content before executing the request.
For example:
$ echo $SHELL
/bin/bash
$ cat dae2.txt
DELETE FROM ... (11 Replies)
Hi All,
Please can you help me with below, i have a file with records ( eg of one record below)
Record R1 - The field separtaor between records is | (Pipe)
|123|Mukesh\r\n|Vivek"sharma|
Now i want to do the following for each record in the file
if there is any field ( lets say field... (3 Replies)
Discussion started by: mad_man12
3 Replies
LEARN ABOUT MOJAVE
tie::memoize
Tie::Memoize(3pm) Perl Programmers Reference Guide Tie::Memoize(3pm)NAME
Tie::Memoize - add data to hash when needed
SYNOPSIS
require Tie::Memoize;
tie %hash, 'Tie::Memoize',
&fetch, # The rest is optional
$DATA, &exists,
{%ini_value}, {%ini_existence};
DESCRIPTION
This package allows a tied hash to autoload its values on the first access, and to use the cached value on the following accesses.
Only read-accesses (via fetching the value or "exists") result in calls to the functions; the modify-accesses are performed as on a normal
hash.
The required arguments during "tie" are the hash, the package, and the reference to the "FETCH"ing function. The optional arguments are an
arbitrary scalar $data, the reference to the "EXISTS" function, and initial values of the hash and of the existence cache.
Both the "FETCH"ing function and the "EXISTS" functions have the same signature: the arguments are "$key, $data"; $data is the same value
as given as argument during tie()ing. Both functions should return an empty list if the value does not exist. If "EXISTS" function is
different from the "FETCH"ing function, it should return a TRUE value on success. The "FETCH"ing function should return the intended value
if the key is valid.
Inheriting from Tie::Memoize
The structure of the tied() data is an array reference with elements
0: cache of known values
1: cache of known existence of keys
2: FETCH function
3: EXISTS function
4: $data
The rest is for internal usage of this package. In particular, if TIEHASH is overwritten, it should call SUPER::TIEHASH.
EXAMPLE
sub slurp {
my ($key, $dir) = shift;
open my $h, '<', "$dir/$key" or return;
local $/; <$h> # slurp it all
}
sub exists { my ($key, $dir) = shift; return -f "$dir/$key" }
tie %hash, 'Tie::Memoize', &slurp, $directory, &exists,
{ fake_file1 => $content1, fake_file2 => $content2 },
{ pretend_does_not_exists => 0, known_to_exist => 1 };
This example treats the slightly modified contents of $directory as a hash. The modifications are that the keys fake_file1 and fake_file2
fetch values $content1 and $content2, and pretend_does_not_exists will never be accessed. Additionally, the existence of known_to_exist is
never checked (so if it does not exists when its content is needed, the user of %hash may be confused).
BUGS
FIRSTKEY and NEXTKEY methods go through the keys which were already read, not all the possible keys of the hash.
AUTHOR
Ilya Zakharevich <mailto:perl-module-hash-memoize@ilyaz.org>.
perl v5.18.2 2013-11-04 Tie::Memoize(3pm)