Sponsored Content
Top Forums Shell Programming and Scripting Write a new file from 2 files as input to the script Post 302324358 by vidyadhar85 on Wednesday 10th of June 2009 01:56:04 PM
Old 06-10-2009
can you post how the resulting file should look like??
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to remove old files and write to a log file

Hi, I have a script that works on a unix box but am trying to get it working on a linux box that uses shell. I am not a programmer so this is proving harder than I imagined. I made some changes and ended up with the script below but when I run it I get the following messages. Any help would be... (4 Replies)
Discussion started by: yabai
4 Replies

2. UNIX and Linux Applications

Input a variable and write to a file using awk

Hi I am trying to edit a csv file. Bacically I need to input a search variable and the value that must be changed in one of the fields corresponding to that searched variable. My csv file looks like so: 1,1A,5 1,1B,2 1,1C,3 2,2A,7 2,2B,4 2,2C,0 3,3A,1 3,3B,6 3,3C,4 I want to... (4 Replies)
Discussion started by: ladyAnne
4 Replies

3. Shell Programming and Scripting

How to write shell script for input file name format checking?

Hello, I had written a shell script that accepts input file as cmd line argument and process this file. if ; then if ; then . $1 LOGFILE="$LOG_FILE/MIG_BIOS.log"; get_input_file else ERROR_CODE=MSCRM0005_003 error "$ERROR_CODE : Input file $1 is not available"; exit... (3 Replies)
Discussion started by: Poonamol
3 Replies

4. Shell Programming and Scripting

Help to write a script or program to automatic execute and link input file data

Output file template format <input_file_name>a</input_file_name> <total_length_size>b</total_length_size> <log_10_length_size>c</log_10_length_size> Input_file_1 (eg. sample.txt) SDFSDGDGSFGRTREREYWW Parameter: a is equal to the input file name b is equal to the total length of... (2 Replies)
Discussion started by: perl_beginner
2 Replies

5. Shell Programming and Scripting

Separating list of input files (*.file) with a comma in bash script

Hi all, I'm trying to get a bash script working for a program (bowtie) which takes a list of input files (*.fastq) and assembles them to an output file (outfile.sam). All the .fastq files are in one folder in my home directory (~/infiles). The problem is that the 'bowtie' requires that... (7 Replies)
Discussion started by: TuAd
7 Replies

6. Shell Programming and Scripting

Unfold the data from a input file and write to a file

I am working on a script to unfold data for each column from a specific line of data and write output in a single line. Input data looks like this. 2011-09-26 INF UM_10 UserMana Starting synchronization for security domain 14:37:31 080 gementSe . rvice I... (2 Replies)
Discussion started by: svajhala
2 Replies

7. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

8. Shell Programming and Scripting

Read user input, Encrypt the data and write to file

Hi, can some one help me how to encrypt and decrypt a file. AIM: reade user input, encrypt it and save it to file. while decryption read the encrypted file decrypt it and save the output in some variable. Example: consider we have Credentials.txt file with content username: password... (5 Replies)
Discussion started by: saichand1985
5 Replies

9. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

10. UNIX for Dummies Questions & Answers

Script to break up file (write new files) in bash

Hello experts, I need help writing individual files from a data matrix, with each new file being written every time there is a blank line: From this cat file.txt col1 col2 col3 6661 7771 8881 6661 7771 8881 6661 7771 8881 col1 col2 col3 3451 2221 1221... (6 Replies)
Discussion started by: torchij
6 Replies
Hook::LexWrap(3)					User Contributed Perl Documentation					  Hook::LexWrap(3)

NAME
Hook::LexWrap - Lexically scoped subroutine wrappers VERSION
This document describes version 0.23 of Hook::LexWrap. SYNOPSIS
use Hook::LexWrap; sub doit { print "[doit:", caller, "]"; return {my=>"data"} } SCOPED: { wrap doit, pre => sub { print "[pre1: @_] " }, post => sub { print "[post1:@_] "; $_[1]=9; }; my $temporarily = wrap doit, post => sub { print "[post2:@_] " }, pre => sub { print "[pre2: @_] "}; @args = (1,2,3); doit(@args); # pre2->pre1->doit->post1->post2 } @args = (4,5,6); doit(@args); # pre1->doit->post1 DESCRIPTION
Hook::LexWrap allows you to install a pre- or post-wrapper (or both) around an existing subroutine. Unlike other modules that provide this capacity (e.g. Hook::PreAndPost and Hook::WrapSub), Hook::LexWrap implements wrappers in such a way that the standard "caller" function works correctly within the wrapped subroutine. To install a prewrappers, you write: use Hook::LexWrap; wrap 'subroutine_name', pre => &some_other_sub; #or: wrap *subroutine_name, pre => &some_other_sub; The first argument to "wrap" is a string containing the name of the subroutine to be wrapped (or the typeglob containing it, or a reference to it). The subroutine name may be qualified, and the subroutine must already be defined. The second argument indicates the type of wrapper being applied and must be either 'pre' or 'post'. The third argument must be a reference to a subroutine that implements the wrapper. To install a post-wrapper, you write: wrap 'subroutine_name', post => &yet_another_sub; #or: wrap *subroutine_name, post => &yet_another_sub; To install both at once: wrap 'subroutine_name', pre => &some_other_sub, post => &yet_another_sub; or: wrap *subroutine_name, post => &yet_another_sub, # order in which wrappers are pre => &some_other_sub; # specified doesn't matter Once they are installed, the pre- and post-wrappers will be called before and after the subroutine itself, and will be passed the same argument list. The pre- and post-wrappers and the original subroutine also all see the same (correct!) values from "caller" and "wantarray". Short-circuiting and long-circuiting return values The pre- and post-wrappers both receive an extra argument in their @_ arrays. That extra argument is appended to the original argument list (i.e. is can always be accessed as $_[-1]) and acts as a place-holder for the original subroutine's return value. In a pre-wrapper, $_[-1] is -- for obvious reasons -- "undef". However, $_[-1] may be assigned to in a pre-wrapper, in which case Hook::LexWrap assumes that the original subroutine has been "pre-empted", and that neither it, nor the corresponding post-wrapper, nor any wrappers that were applied before the pre-empting pre-wrapper was installed, need be run. Note that any post-wrappers that were installed after the pre-empting pre-wrapper was installed will still be called before the original subroutine call returns. In a post-wrapper, $_[-1] contains the return value produced by the wrapped subroutine. In a scalar return context, this value is the scalar return value. In an list return context, this value is a reference to the array of return values. $_[-1] may be assigned to in a post-wrapper, and this changes the return value accordingly. Access to the arguments and return value is useful for implementing techniques such as memoization: my %cache; wrap fibonacci, pre => sub { $_[-1] = $cache{$_[0]} if $cache{$_[0]} }, post => sub { $cache{$_[0]} = $_[-1] }; or for converting arguments and return values in a consistent manner: # set_temp expects and returns degrees Fahrenheit, # but we want to use Celsius wrap set_temp, pre => sub { splice @_, 0, 1, $_[0] * 1.8 + 32 }, post => sub { $_[-1] = ($_[0] - 32) / 1.8 }; Lexically scoped wrappers Normally, any wrappers installed by "wrap" remain attached to the subroutine until it is undefined. However, it is possible to make specific wrappers lexically bound, so that they operate only until the end of the scope in which they're created (or until some other specific point in the code). If "wrap" is called in a non-void context: my $lexical = wrap 'sub_name', pre => &wrapper; it returns a special object corresponding to the particular wrapper being placed around the original subroutine. When that object is destroyed -- when its container variable goes out of scope, or when its reference count otherwise falls to zero (e.g. "undef $lexical"), or when it is explicitly destroyed ("$lexical->DESTROY") -- the corresponding wrapper is removed from around the original subroutine. Note, however, that all other wrappers around the subroutine are preserved. Anonymous wrappers If the subroutine to be wrapped is passed as a reference (rather than by name or by typeglob), "wrap" does not install the wrappers around the original subroutine. Instead it generates a new subroutine which acts as if it were the original with those wrappers around it. It then returns a reference to that new subroutine. Only calls to the original through that wrapped reference invoke the wrappers. Direct by- name calls to the original, or calls through another reference, do not. If the original is subsequently wrapped by name, the anonymously wrapped subroutine reference does not see those wrappers. In other words, wrappers installed via a subroutine reference are completely independent of those installed via the subroutine's name (or typeglob). For example: sub original { print "ray" } # Wrap anonymously... my $anon_wrapped = wrap &original, pre => sub { print "do..." }; # Show effects... original(); # prints "ray" $anon_wrapped->(); # prints "do..ray" # Wrap nonymously... wrap *original, pre => sub { print "fa.." }, post => sub { print "..mi" }; # Show effects... original(); # now prints "fa..ray..mi" $anon_wrapped->(); # still prints "do...ray" DIAGNOSTICS
"Can't wrap non-existent subroutine %s" An attempt was made to wrap a subroutine that was not defined at the point of wrapping. "'pre' value is not a subroutine reference" The value passed to "wrap" after the 'pre' flag was not a subroutine reference. Typically, someone forgot the "sub" on the anonymous subroutine: wrap 'subname', pre => { your_code_here() }; and Perl interpreted the last argument as a hash constructor. "'post' value is not a subroutine reference" The value passed to "wrap" after the 'post' flag was not a subroutine reference. "Uselessly wrapped subroutine reference in void context" (warning only) When the subroutine to be wrapped is passed as a subroutine reference, "wrap" does not install the wrapper around the original, but instead returns a reference to a subroutine which wraps the original (see "Anonymous wrappers"). However, there's no point in doing this if you don't catch the resulting subroutine reference. AUTHOR
Damian Conway (damian@conway.org) BLAME
Schwern made me do this (by implying it wasn't possible ;-) BUGS
There are undoubtedly serious bugs lurking somewhere in code this funky :-) Bug reports and other feedback are most welcome. SEE ALSO
Sub::Prepend COPYRIGHT
Copyright (c) 2001, Damian Conway. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.18.2 2017-10-06 Hook::LexWrap(3)
All times are GMT -4. The time now is 03:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy