08-25-2009
how to get split output of a file, using perl script
Hi,
I have file: data.log.1
### s1
main.build.3495
main.build.199
main.build.3408
###s2
main.build.3495
main.build.3408
main.build.199
I want to read this file and store in two arrays in Perl.
I have following command, which is working fine on command prompt.
perl -n -e '/^###/ and open FH, ">output_".$n++; print FH;' data.log.1
But I want to use this command in Perl file, so that I can store output ###s1 (part) and ###s2 (part) in two different arrays.
Any help will be appreciated.
Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want to split a given month into weeks. For example if I give the date in dd/mm/yy format say 01/02/08 it should give output in the given format :
week1 : start date and end date.
week2 : ""
week3 : ""
week4 : "" (5 Replies)
Discussion started by: khushbu_roy
5 Replies
2. Shell Programming and Scripting
Below is my perl script:
#!/usr/bin/perl
open(FILE,"$ARGV") or die "$!";
@DATA = <FILE>;
close FILE;
$join = join("",@DATA);
@array = split( ">",$join);
for($i=0;$i<=scalar(@array);$i++){
system ("/home/bin/./program_name_count_length MULTI_sequence_DATA_FILE -d... (5 Replies)
Discussion started by: patrick87
5 Replies
3. Shell Programming and Scripting
Hi all
I have written Perl script to swap the strings in the second a third column from a text file.
My input file format is :
the|empty|the|det lake|empty|lake|conj_and was|empty|was|auxpass drained|empty|drained|conj_and birds|empty|bird|s|nn
The expected output file format is... (11 Replies)
Discussion started by: my_Perl
11 Replies
4. Shell Programming and Scripting
How do I split file into pieces with PERL?
IE
file.txt
head
1
2
3
4
end
head
5
6
7
8
9
end
n so on (7 Replies)
Discussion started by: 3junior
7 Replies
5. Shell Programming and Scripting
Hi All,
I have two input file and need to generate a CSV file. The existing report just "GREP" the records with the Header and Tailer records with the count of records.
Now i need to split the data into 25 records each in the same CSV file.
id_file (Input file )
227050994
232510151... (4 Replies)
Discussion started by: rasmith
4 Replies
6. Shell Programming and Scripting
Hi,
I have a unix shell script which generates a flat file after connecting to Teradata servers to fetch tables and views and also picks up modified unix scripts from the specified paths.
Later on the script calls a perl script to assign a value based on the type of object in the flat file which... (2 Replies)
Discussion started by: yohasini
2 Replies
7. Shell Programming and Scripting
In PERL script
I have few files named theme1.htm,theme2.htm,theme3.htm and so on.
now I need to write perl code to split the the filename and store only that particular digit.
Example
--------------
filename is theme1.htm
output should be 1
another example
---------------... (5 Replies)
Discussion started by: giridhar276
5 Replies
8. Shell Programming and Scripting
I had a text file(comma seperated values) which contains as below
196237,ram,25-May-06,ram.kiran@xyz.com,204183,Pavan,4-Jun-07,Pavan.Desai@xyz.com,237107,ram Chandra,15-Mar-10,ram.krishna@xyz.com ... (3 Replies)
Discussion started by: giridhar276
3 Replies
9. Shell Programming and Scripting
Hello,
I was trying to split a string to characters by perl oneliner.
echo "The quick brown fox jumps over the lazy dog" | perl -e 'split // ' But did not work as with bash script pipe:
echo "The quick brown fox jumps over the lazy dog" | fold -w1 | sort | uniq -ic 8
1 T
1... (6 Replies)
Discussion started by: yifangt
6 Replies
10. Shell Programming and Scripting
I have a perl script which splits a large file into chunks.The script is given below
use strict;
use warnings;
open (FH, "<monolingual.txt") or die "Could not open source file. $!";
my $i = 0;
while (1) {
my $chunk;
print "process part $i\n";
open(OUT, ">part$i.log") or die "Could... (4 Replies)
Discussion started by: gimley
4 Replies
LEARN ABOUT CENTOS
error::buildid
ERROR::BUILDID(7stap) ERROR::BUILDID(7stap)
NAME
error::buildid - build-id verification failures
DESCRIPTION
Because systemtap's script translation / execution stages may be executed at different times and places, it is sometimes necessary to ver-
ify certain invariants. One such invariant is that if a script was informed by translate-time analysis of executables, then those same
executables need to be used at run time. This checking is done based upon the build-id, a binary hash that modern (post-2007) compil-
ers/toolchains add as an NT_GNU_BUILD_ID ELF note to object files and executables. Use the readelf -n command to examine the build-ids of
binaries, if you are interested.
Only scripts are sensitive to executables' build-ids: generally those that perform deep analysis of the binaries or their debuginfo. For
example, scripts that place .function or .statement probes, or use stack backtrace-related tapset functions may be sensitive. Other
scripts that rely only on process.mark or kernel.trace probes do not require debuginfo. See the DWARF DEBUGINFO section in the stap-
probes(3stap) man page.
During translation, systemtap saves a copy of the relevant files' build-ids within the compiled modules. At run-time, the modules compare
the saved ones to the actual run-time build-ids in memory. The error message indicates that they did not match, so the module will decline
placing a probe that was computed based upon obsolete data. This is important for safety, as placing them at an inappropriate address
could crash the programs. However, this is not necessarily a fatal error, since probes unrelated to the mismatching binaries may operate.
A build-id mismatch could be caused by a few different situations. The main one is where the executable versions or architecture were dif-
ferent between the systemtap translation and execution times/places. For example, one may run a stap-server on a slightly different ver-
sion of the OS distribution. The kernel running on the workstation may be slightly different from the version being targeted - perhaps due
to a pending kernel upgrade leaving different files on disk versus running in memory. If your OS distribution uses separate debuginfo
packages, the split .IR .debug files may not exactly match the main binaries.
SEE ALSO
http://fedoraproject.org/wiki/Releases/FeatureBuildId,
stap(1),
stapprobes(3stap),
warning::debuginfo(7stap),
error::reporting(7stap)
ERROR::BUILDID(7stap)