By declaring $part1 and $part2 as lexical variables within the if block, you've scoped them to that block. Hence, no values (undef) or values before that block, are printed outside the block. Remove my before the variables. This will make them global and the values will be accessible outside the if block.
Also, that regexp is not correct. The $2 value will always be a single digit.
Try:
Last edited by elixir_sinari; 09-27-2012 at 06:13 AM..
Hello,
I'm trying to split a file by lines. I know that I can use the split command to do this, but the one problem I'm having is, each file created, the first line needs to be a header. I can use the split command the create another file with the header, then append the new split file to... (4 Replies)
Hi,
I have a file in the given format:
|aaa |hhh |fat hat chat |make sure
I need to get store in a variable,say 'error' the value of the string 'fat hat chat'
In short,
echo $error should give the result
fat hat chat
Is this possible using awk?
Also, can this be split.For... (10 Replies)
I have a file as:
I/P File:
Ground Car 2009
Lib 2008
Lib 2003
Ground Car 2009
Ground Car 2003
Car 2005
Car 2003
Car 2005
Sita 2900 2006
Car 2007
I have to split the file into two: - one for names and second for years.
O/p1 (Names):
Ground Car (3 Replies)
I have a file with the below Data
1,nj@ny@pa@caa
2,ct
3,ca@vaa@txI want the output to be
1,nj
1,ny
1,pa
1,caa
2,ct
3,ca
3,vaa
3,tx
I need to split the second column based on @ as delimiter
The number of delimiters is unknown (4 Replies)
Hi,
I have the following input file
32895901-d17f-414c-ac93-3e7e0f5ec240 AND @GDF_INPUT
73b129e1-1fa9-4c0d-b95b-4682e5389612 AUS @GDF_INPUT
40f82e88-d1ff-4ce2-9b8e-d827ddb39447 BEL @GDF_INPUT
36e9c3f1-042a-43a4-a80e-4a3bc2513d01 BGR @GDF_INPUT
I want to split column 3 into two columns:... (1 Reply)
Hi,
My file is seperated with ";" delimiter, after 13 delimiter i want to put the data in new line...
eg:
My current file:-
a;b;c;d;e;f;g;h;e;f;h;s;t;a;i;o;q;t;q;r;yu;f;sz;f;t;r...........
i want o/p as:-
a;b;c;d;e;f;g;h;e;f;h;s;t
a;i;o;q;t;q;r;yu;f;sz;f;t;r
How to achieve ths,... (2 Replies)
Hello All,
I have a comma delimiter file with 10 columns. I took the desired data but from $4 I need to split into two columns as 3+7 bytes.
awk -F"," -v OFS=',' '{print $2,$3,$4}' foo.txt
42366,11/10/2014,5012418769
42366,11/10/2014,2046955672
42366,11/10/2014,2076802951
... (3 Replies)
I have a text file that looks like this:
FIELD1, FIELD2, THIS IS FIELD3, FIELD4
FIELD1, FIELD2, THIS IS FIELD3, FIELD4
FIELD1, FIELD2, THIS IS FIELD3, FIELD4
I need it to turn it into an XML file to run against a custom application. My ultimate goal is for it to look like... (15 Replies)
I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open())
I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies
LEARN ABOUT DEBIAN
subs
SUBS(1p) User Contributed Perl Documentation SUBS(1p)NAME
subs - convert, join, split, and re-time subtitles
FORMAT
subs [options] subfile [ subfile ... ]
OPTIONS -a coeff, -b time
a and b coefficients in linear transformation u=at+b, where t and u are src and dest times ( default(identity transform) is [a=1,b=0]
). -a can be set as ratio, f.ex. 23.9/25
-c codec
Use codec to write file. Run 'subs -h' for list of installed codecs.
-d Try to prolong duration of quickly disappearing text. 'Quickly' is less than 0.8 second per line of text.
-e command
Run perl code for each line of text in file. On each run, the text and time variables are initialized, and new values, if any, written
to the file. The variables are used for:
$_ subtitle text line
$b cue beginning
$e cue end
$i line number
$n number of lines
%p persistent data between runs
The -e option can be specified several times
-h Display help
-i Edit files in place ( makes backup in .bak files )
-j sec
Time interval between joins, seconds (default 2)
-o file
File to save processed subtitles (default out.sub)
-O Separate overlapped lines
-p t1 t2 or -P t2 t1
Set a control point, where t1 is time of a phrase spoken in the film and t2 is time when the same phrase as appears in the subtitle.
Two points are required for deducing -a and -b coefficients; if only one point is specified, it is assumed that the other one is [0,0].
Times can be relative, f.ex. -p 01:00 +3.5 -p -20 1:00:00
Options -P and -p are the same except the argument sequence is reversed. -P is to be used when arguments to -p were typed manually and
in wrong order.
-q t1 t2
Restrict changes, if any, in time span t1-t2. Word 'end' can be used as an alias to the end of the file. Default values are '0' and
'end'.
-r rate
Force frame-per-second rate for frame-based subs
-s time
Split in two parts by time
-v Be verbose
-z file.sub
Zip subtitle files so time information is read from file.sub, while text information is read from the input file(s).
NOTES
The time format is either [[HH:]MM:]SS[.MSEC] or subtitle format-specific
EXAMPLES
Warning: -i is a great feature, but use it with certain caution.
If subtitles are shown too early ( 5 seconds):
subs -i -b 5 file.sub
If subtitles are for a movie in 25 fps, need to be for 24 ( actual for frame-based formats only ).
subs -i -a 24/25 file.sub
If subtitles start ok, but in 1 hour are late in 7 seconds:
subs -i -p 0 0 -p 1:00:00 +7 file.sub
Join two parts with 15-second gap
subs -o joined.sub -j 15 part1.sub part2.sub
Split in two after 50 minutes and half a second ( makes basename.1.sub and basename.2.sub ).
subs -o basename.sub -s 50:00.5 toobig.sub
Remove closed caption-specific comments such as '[Sneezing]' or '[Music playing]'
subs -e 's/[s-]*[.*]s*
*//gs' sub.sub
BUGS
Subtitles written as ".smi" format may differ from original.
SEE ALSO
Subtitles - backend module for this program
AUTHOR
Dmitry Karasik, <dmitry@karasik.eu.org>.
perl v5.14.2 2009-12-22 SUBS(1p)