Sponsored Content
Top Forums Shell Programming and Scripting Print new item in file with symbol Post 302457274 by kmuthu_gct on Monday 27th of September 2010 03:57:35 PM
Old 09-27-2010
Try the following:

Code:
print "\nPlease enter your name and marks :";

open (OUTFILE, ">>report");

$name = <STDIN>;
$mark = <STDIN>;
chomp ($name);
chomp ($mark);
print OUTFILE 
$abc = ("$name\t$mark\n");
chomp ($abc);
close (OUTFILE);

open (IN, "report") || die "Error opening data file: $!";

while (<IN>) {
   @array=split;
   if(eof) {
   print "*$array[0] $array[1]\n";
   } else {
   print "$array[0] $array[1]\n";
   }
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get string from file after nth symbol

I've got a file, where I want to grab two fields from it. The file isn't fixed format, so all I know is that the two fields are after a certain number of delimiters within the record. File e.g. as follows:- "1"^"HEADER"^ "5"^"12345678"^"Smith"^"Dave"^"Mr"^"Research &... (1 Reply)
Discussion started by: daveaasmith
1 Replies

2. Shell Programming and Scripting

Remove the comment symbol ' from a file.

I want to remove the commented lines in a file identified by ' symbol at the start of each ine. A sample example will be like: Input ----- 'IFerr_flag=0THEN iferr_flag=0then iferr_flag=0then iferr_flag=0then iferr_flag=0then iferr_flag=0then iferr_flag=0then Output -------... (3 Replies)
Discussion started by: joyan321
3 Replies

3. Shell Programming and Scripting

Searching for file and stopping at first item found

Hello, I try to write a shell script that would list all files on a directory and stop when it finds the first item specified on a find or ls command. How can I tell to the find or ls command to stop when it finds the first ".doc" file for example ? Thank you (7 Replies)
Discussion started by: davchris
7 Replies

4. Solaris

/usr/lib/passwdutil.so.1: symbol __nsl_fgetspent_r: referenced symbol not found

deleteing post (0 Replies)
Discussion started by: dshakey
0 Replies

5. Shell Programming and Scripting

Reading each item from a formatted file

Hi, I have a file generated like this - 1. Fire SQL and store the formatted output in a temp file echo "select path, empid, age from emp_tbl" | /usr/sql emp_db 2 > count_file | grep vol > tempFile 2. The tempFile looks like this after the above statement /vol/emp1 0732 ... (9 Replies)
Discussion started by: angshuman_ag
9 Replies

6. Shell Programming and Scripting

awk to start with symbol and print next

File A >answer is the predicted other than >bigger than two >whatever isthere >out of mind CGAHHAWWASSASS SASAWEDSASSDDD SSDDDEDEUJUYYS >hello you are there other is what is that>you are not serious>leave it SSSAAAAAASS ASWWQQDDD WESEEWWWW WEEEEEWSS SJUJSGKKSSS SWBVHJJWUW >hi i... (3 Replies)
Discussion started by: cdfd123
3 Replies

7. Programming

Storing C++-struct in file - problem when adding new item in struct

Hi, I have received an application that stores some properties in a file. The existing struct looks like this: struct TData { UINT uSizeIncludingStrings; // copy of Telnet data struct UINT uSize; // basic properties: TCHAR szHost; //defined in Sshconfig UINT iPortNr; TCHAR... (2 Replies)
Discussion started by: Powerponken
2 Replies

8. Shell Programming and Scripting

Read a lis, find items in a file from the list, change each item

Hello, I have some tab delimited text data, file: final_temp1 aname val NAME;r'(1,) 3.28584 r'(2,)<tab> NAME;r'(3,) 6.13003 NAME;r'(4,) 4.18037 r'(5,)<tab> You can see that the data is incomplete in some cases. There is a trailing tab after the first column for each incomplete row. I... (2 Replies)
Discussion started by: LMHmedchem
2 Replies

9. UNIX for Beginners Questions & Answers

Zabbix item for last line of a log file

Dear all,Zabbix version : 2.4 (yes, I know, upgrading soon - honest) Server OS version : CentOS 6, 64-bit (CentOS 7 with the Zabbix upgrade)I've got a large log file that I would like to read by an external process. It's basically the same as reading the item value on a web-page. I have... (5 Replies)
Discussion started by: rbatte1
5 Replies

10. Shell Programming and Scripting

Script to process a list of items and uncomment lines with that item in a second file

Hello, I have a src code file where I need to uncomment many lines. The lines I need to uncomment look like, C CALL l_r(DESNAME,DESOUT, 'Gmax', ESH(10), NO_APP, JJ) The comment is the "C" in the first column. This needs to be deleted so that there are 6 spaces preceding "CALL".... (7 Replies)
Discussion started by: LMHmedchem
7 Replies
VCS::Lite(3pm)						User Contributed Perl Documentation					    VCS::Lite(3pm)

NAME
VCS::Lite - Minimal version control system SYNOPSIS
use VCS::Lite; # diff my $lit = VCS::Lite->new('/home/me/foo1.txt'); my $lit2 = VCS::Lite->new('/home/me/foo2.txt'); my $difftxt = $lit->delta($lit2)->diff; print OUTFILE $difftxt; # patch my $delt = VCS::Lite::Delta->new('/home/me/patch.diff'); my $lit3 = $lit->patch($delt); print OUTFILE $lit3->text; # merge my $lit4 = $lit->merge($lit->delta($lit2),$lit->delta($lit3)); print OUTFILE $lit4->text; DESCRIPTION
This module provides the functions normally associated with a version control system, but without needing or implementing a version control system. Applications include wikis, document management systems and configuration management. It makes use of the module Algorithm::Diff. It provides the facility for basic diffing, patching and merging. API
new The underlying storage concept of VCS::Lite is an array. The members of the array can be anything that a scalar can represent (including references to structures and objects). The default is for the object to hold an array of scalars as strings corresponding to lines of text. The basic form of the constructor is as follows: my $lite = VCS::Lite->new( '/my/file'); which slurps the file to make an object. The full form is as follows: my $lite = VCS::Lite->new( $object_id, $separation, $source, ...); $object_id This is a string to identify what is being diffed, patched or merged, in the application's environment. If there is no $source, this is used as a filename from which to read the content. $separation This is an optional parameter, which can be used via $/ to split the input file into tokens. The default is for lines of text. If you pass in a string to be tokenized, this will use $sep as a regular expression $separation can be a scalar or scalar ref, where this is used to break up the input stream. All values permitted for $/ are allowed (see perlvar). $separation can also be a hashref, to give a finer level of control. For example: { in => ' ', out => ' ', chomp => 1 } 'in' is the input record separator to use (the same as you would pass as $sep). Note that all values allowed for $/, and indeed the value of $/ passed in is what is used as a default. 'in' can be a string or a regexp. 'out' is the character used on joining the members to output the results (text method in scalar context). This is the output record separator $. Note that 'out' defaults differently depening on the setting of 'chomp': if 'chomp' is off, 'out' will default to the empty string, or rather the passed in value of $. If 'chomp' is on, 'out' will default to 'in' - note that you should specify 'out' explicitly if you are using a regexp for 'in'. If the 'chomp' flag is set, the text matching 'in' is removed from the input lines as they are read. 'chomp' is not on by default, as this is new functionality in release 0.08. $source if unspecified causes $object_id to be opened as a file and its entire contents read in. The alternative is to supply $source, which can be one of the following: "scalar" This is a string which is tokenized using $separation "arrayref" Array of tokens "filehandle" or "globref" Contents of file are slurped "callback" This is called successively to obtain tokens until received undef. In the Perl spirit of DWIM, new assumes that given an arrayref, you have already done all the work of making your list of whatevers. Given a string (filename) or a file handle, the file is slurped, reading each line of text into a member of the array. Given a callback, the routine is called successively with arguments $p1, $p2, etc. and is expected to return a scalar which is added (pushed on) to the array. apply $lite->apply($lite2); $lite->apply($lite3, base => 'original'); This method call corresponds approximately to a version control system's check-in function. This causes $lite to be modified, so that its contents now reflect those of $lite2. $lite does retain the original contents, available via original. However, unlike in a version control system, the object holds only the first original and latest contents. The VCS::Lite object passed in can also have its own original version. If this is the case, merging will be performed to incorporate the change as if it had come from a different branch. To facilitiate the merging process, optionally specify a base version, which can be the string 'original', 'contents' (the default) or a VCS::Lite object whose contents will be used. This corresponds to the "common ancestor" in version control systems. original This returns a VCS::Lite object for the original version, before changes were applied with apply. text my $foo = $lite->text; my $bar = $lit2->text('|'); my @baz = $lit3->text; In scalar context, returns the equivalent of the file contents slurped (the optional separation parameter, defaulting to $_, is used to join the strings together). In list context, returns the list of lines or records. id my $fil = $lite->id Returns the name associated with the VCS::Lite element when it was created by new. This is usually the file name. delta my $delt = $lit->delta($lit2); Perform the difference between two VCS::Lite objects. This object returns a VCS::Lite::Delta object. diff This is for backward compatibility with early versions. $lite->diff($lite2) is equivalent to $lite->delta($lite2)->diff. patch my $lit3 = $lit->patch($delt); Applies a patch to a VCS::Lite object. Accepts a file handle or file name string. Reads the file in diff format, and applies it. Returns a VCS::Lite object for the patched source. merge my $lit4 = $lit->merge($lit1,$lit2,&confl); Performs the "parallelogram of merging". This applies two different change streams represented by VCS::Lite objects. Returns a VCS::Lite object with both sets of changes merged. The third parameter to the method is a sub which is called whenever a merge conflict occurs. This needs to either resolve the conflict or insert the necessary text to highlight the conflict. BUGS, PATCHES &; FIXES At the time of release there is one known bug within VCS-Lite: http://rt.cpan.org/Public/Bug/Display.html?id=20738 Unfortunately Ivor's original svn repository is no longer available, and any work which had done on fixing this bug has now been lost. As time allows I will review the examples and try to implement an appropriate solution. If you spot a bug or are experiencing difficulties that are not explained within the POD documentation, please send an email to barbie@cpan.org or submit a bug to the RT system (see link below). However, it would help greatly if you are able to pinpoint problems or even supply a patch. http://rt.cpan.org/Public/Dist/Display.html?Name=VCS-Lite Fixes are dependant upon their severity and my availablity. Should a fix not be forthcoming, please feel free to (politely) remind me. AUTHOR
Original Author: Ivor Williams (RIP) 2008-2009 Current Maintainer: Barbie <barbie@cpan.org> 2009 COPYRIGHT
Copyright (c) Ivor Williams, 2002-2006 Copyright (c) Barbie, 2009 LICENCE
You may use, modify and distribute this module under the same terms as Perl itself. ACKNOWLEDGEMENTS
Colin Robertson for suggesting and providing patches for support of files with unterminated last lines. SEE ALSO
Algorithm::Diff. perl v5.10.1 2009-10-25 VCS::Lite(3pm)
All times are GMT -4. The time now is 05:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy