develooper Front page | perl.perl5.porters | Postings from December 2001

[ID 20011229.002] Syntax error in line with leading ," (comma andquote)

Thread Next
From:
steve
Date:
December 29, 2001 11:34
Subject:
[ID 20011229.002] Syntax error in line with leading ," (comma andquote)
Message ID:
20011229193344.6ABD51DE93@gh.dhs.org
This is a bug report for perl from perltidy@users.sourceforge.net,
generated with the help of perlbug 1.33 running under perl v5.6.1.


-----------------------------------------------------------------
Hello,

I have encountered two recent cases in which a syntax error is incorrectly
reported for a line beginning with the two characters ,"  
(comma and double quote).

This bug occurs in perl v5.6.1.  It does not occur in version 5.005_03.

The message is 'Unrecognized character' at that line in both cases, but
the details of the message vary.  I will include one of these files
here, and can send the other if there is interest.  The file is somewhat
long, but it uses no modules, which makes testing easy.

This is probably a low-priority problem, because the files are unusual,
but it does indicate some kind of bug in perl, so I thought I should
report it.  The files are unusual because I created them with 'perltidy
-extrude' for testing purposes, which puts as many newlines in a file as
possible.  The syntax error is sensitive to the total number of lines in
the file.  In the example that I enclose, extbug.pl, if you do

perl -c extbug1.pl  

you will get the message:
-------------------------------------------------------------------

Unrecognized character \x16 at extbug1.pl line 1040

-------------------------------------------------------------------

If you combine the line with leading ," with the previous
line, you get 'syntax ok'.  So, the problem seems to have something to
do with having many lines along with a line beginning with ,"

Also, the problem seems to only occur in relatively large files, so I cannot
send just a small snippet.  For example, I can make the problem go away if I
remove enough comment lines.

I am going to paste the file (about 23k) right here because as I recall I won't
get a chance to append a zipped file.  You may contact me for a zipped copy if
this doesn't work.

Steve Hancock
perltidy@users.sourceforge.net
-----------Cut Here------------------------------------------------------
#!/usr/bin/perl
# scanmenu is a perl script which helps process binary data files
# received from the White Sands HEBF
# steve hancock, july 2000
#
# brief instructioins:
#	start the script and read the help files
# if the script is in your current directory, try:
#	perl scanmenu.pl
if
(
$#ARGV
==
0
)
{
$shot
=$ARGV
[0
];
}
else
{
$shot
=get_shot_name
(
)
;
}
#use strict;
my$ans
;
while
(
1
)
{
system
'clear'
;
$prompt
= <<"EOP";
	Main Menu for Processing HEBF Digital Data...

	N	Name of shot:$shot
	H	Help  
	0	Phase 0: Initial Compressing 
	1	Phase 1: Initial Scanning
	2	Phase 2: Re-scanning
	3	Phase 3: combine peaks into a table
	4	Phase 4: Use THPLOT to Find Impulse (Instructions Only)
	5	Phase 5: Combine Peak Impulse and OVP
	6	Phase 6: Run NBLAST 
	X	eXit

EOP
print$prompt;
$ans
=queryu
(
"Your Selection:"
)
;
if
(
$ans
eq
'H'
)
{
system
(
"less scanhelp.txt"
)
;
}
elsif
(
$ans
eq
'0'
)
{
$shot
=phase0
(
$shot
)
;
}
elsif
(
$ans
eq
'1'
)
{
$shot
=phase1
(
$shot
)
;
}
elsif
(
$ans
eq
'2'
)
{
phase2
(
$shot
)
;
}
elsif
(
$ans
eq
'3'
)
{
phase3
(
$shot
)
;
}
elsif
(
$ans
eq
'4'
)
{
phase4
(
$shot
)
;
}
elsif
(
$ans
eq
'5'
)
{
phase5
(
$shot
)
;
}
elsif
(
$ans
eq
'6'
)
{
phase6
(
$shot
)
;
}
elsif
(
$ans
eq
'N'
)
{
$shot
=get_shot_name
(
)
;
}
elsif
(
$ans
eq
'X'
)
{
last
;
}
else
{
}
}
print
"**Bye**\n"
;
sub get_shot_name
{
$path
=`pwd`
;
chomp
$path
;
$pos
=rindex
(
$path
,'/'
)
;
$shot
=substr
(
$path
,$pos
+1
)
;
#print "path=$path  pos=$pos  shot=$shot\n";
$yn
=queryu
(
"Is the name of the shot: $shot [Y/N]"
)
;
if
(
$yn
ne
'Y'
)
{
$shot
=query
(
"Please enter the name of the shot:"
)
;
}
return
$shot
;
}
##########################################################################
#
# some utilities
#
##########################################################################
sub query
{
my (
$msg
)
=@_
;
putstr
(
"$msg"
)
;
$ans
=<STDIN>
;
chomp
$ans
;
return
$ans
;
}
sub queryu
{
my (
$msg
)
=@_
;
my$ans
=uc
(
query
(
$msg
)
)
;
}
sub putstr
{
my (
$msg
)
=@_
;
print$msg;
}
sub waitcr
{
my$ans
=query
(
"Hit <cr> to continue\n"
)
;
}
##########################################################################
#
# phase 0
#
##########################################################################
sub phase0
{
my (
$shot
)
=@_
;
my$old_name
=$shot
;
while
(
1
)
{
system
'clear'
;
$prompt
= <<"EOP";
	Phase 0 ... compress raw data files and change name if necessary

	H	Help
	O	Original name of shot            :$old_name
	N	Name of shot (up to 5 characters):$shot
	Y	Yes..do it
	X	eXit

EOP
print$prompt;
$ans
=queryu
(
"Your Selection:"
)
;
if
(
$ans
eq
'N'
)
{
$shot
=get_shot_name
(
)
;
}
elsif
(
$ans
eq
'O'
)
{
$old_name
=query
(
'Enter the old name:'
)
;
}
elsif
(
$ans
eq
'H'
)
{
system
(
"less phase0.txt"
)
;
}
elsif
(
$ans
eq
'X'
)
{
return
;
}
elsif
(
$ans
eq
'Y'
)
{
print
"Processing files for shot: $shot\n"
;
$path
="./"
;
opendir
(
DIR
,$path
)
;
@files
=grep
{
/^$old_name.\d\d\d$/
}readdir
(
DIR
)
;
closedir
(
DIR
)
;
if
(
$#files
<0
)
{
print
"No files to compress; wrong old name?\n"
;
waitcr
(
)
;
}
else
{
foreach
$file
(
@files
)
{
$ext
=$file
;
$ext
=~
s/^$old_name.(\d\d\d)$/$1/
;
`gzip $file`
;
my$newfile
=$shot
.."."
..$ext
..".gz"
;
print
"compressing $file\n"
;
print
"renaming $file.gz $newfile\n"
;
`mv $file.gz $newfile`
;
}
my$path
=`pwd`
;
chomp
$path
;
my$pos
=rindex
(
$path
,'/'
)
;
my$xxx
=substr
(
$path
,$pos
+1
)
;
print
"Done. Now go on to phase 1\n"
;
if
(
$xxx
ne
$shot
)
{
print
"To simplify things, change the name of this directory from $xxx to $shot\n"
;
}
waitcr
(
)
;
return
$shot
;
}
}
}
return
$shot
;
}
##########################################################################
#
# phase 1
#
##########################################################################
sub phase1
{
my (
$shot
)
=@_
;
while
(
1
)
{
system
'clear'
;
$prompt
= <<"EOP";
	Phase 1 ... do initial scan of raw data files

	H	Help
	N	Name of shot (up to 5 characters):$shot
	Y	Yes..do it
	X	eXit

EOP
print$prompt;
$ans
=queryu
(
"Your Selection:"
)
;
if
(
$ans
eq
'N'
)
{
$shot
=get_shot_name
(
)
;
}
elsif
(
$ans
eq
'H'
)
{
system
(
"less phase1.txt"
)
;
}
elsif
(
$ans
eq
'X'
)
{
return
;
}
elsif
(
$ans
eq
'Y'
)
{
print
"Processing files for shot: $shot\n"
;
$path
="./"
;
opendir
(
DIR
,$path
)
;
@files
=grep
{
/^$shot.\d\d\d$/
}readdir
(
DIR
)
;
closedir
(
DIR
)
;
if
(
$#files
<0
)
{
print
"No files to compress\n"
;
}
else
{
foreach
$file
(
@files
)
{
`gzip $file`
;
print
"compressing $file\n"
;
}
}
# write necessary macro files required by scanbin
write_scan_mac
(
)
;
write_rescan_mac
(
)
;
write_levels_txt
(
)
;
my$listfile
="all.lis"
;
`rm $listfile`
;
# now scan them
opendir
(
DIR
,$path
)
;
@files
=grep
{
/^$shot.\d\d\d.gz/
}readdir
(
DIR
)
;
closedir
(
DIR
)
;
if
(
$#files
<0
)
{
print
"No files to scan\n"
;
}
else
{
foreach
$file
(
@files
)
{
$ext
=$file
;
$ext
=~
s/^$shot.(\d\d\d).gz$/$1/
;
print
"scanning $shot.$ext\n"
;
`rm $shot$ext.lev`
;
`rm $shot$ext.pk`
;
`rm $shot$ext.t15`
;
`rm $shot$ext.bin`
;
`rm $shot$ext.zro`
;
print
"($shot) ($ext)\n"
;
`gunzip -c $file >$shot.$ext`
;
`scanbin \@scan.mac $shot $ext`
;
`rm $shot.$ext`
;
`echo $shot$ext.t15 >>$listfile`
;
}
}
# make a list of files to read into thplot
#			`dir -1 *.t15 >all.lis`;
print
"The file $listfile has a list of all binary files which can be read into thplot\n"
;
waitcr
(
)
;
return
$shot
;
}
}
}
sub write_scan_mac
{
# write a copy of scan.mac in the current directory
# if it is not here
my$filename
="scan.mac"
;
return
if
(
-e$filename
)
;
open
SCAN
,"> $filename"
or
die
"couldn't open $filename: $!\n"
;
print
SCAN
<<'EOM';
!! file to scan a file from white sands
!! with the name $1.$2, where $1 is a common prefix and $2 a unique suffix
!! for example: $1=lchk6  and $2=037
!! WARNING: this program crashes if 
!!          any of the following files exist: $1$2.pk  .lev  .t15  .bin
!! --------- prescan for mean value of first 100 samples --------
F
$1.$2
H
464
X
D
B
1
E
100
I
1
D
S
1
1
4
0
S
2
1
4

X
M
1
1
1
0
X
R
$1$2.zro
!! ------- begin full scan -----------
F
$1.$2
!! ------- skip 464 byte header -----
H
464
X
!! ------- data settings ------------
D
!! ------- define input structure ---
D
1
4

S
2
1
4

2
4

X
!! ------- define mapping of input to output structures ---
M
1
1
1
1
2
1
2
2
X
!! -------- let mean of first 100 samples be the zero -----
P
1
4
!! ------- ending byte number -------
E
250000
I
100
!! ------- set levels (from file) -----
V
R
levels.txt
X
!! -------- file to create -----------
W
0
$1$2.bin
Y
!! ---------- begin scan ------------
R
Y
Y
Y
X
EOM
close
SCAN
;
}
sub write_rescan_mac
{
# write a copy of rescan.mac in the current directory
# if it is not here
my$filename
="rescan.mac"
;
return
if
(
-e$filename
)
;
open
RESCAN
,"> $filename"
or
die
"couldn't open $filename: $!\n"
;
print
RESCAN
<<'EOM';
!! rescan file to scan a file from white sands
!! $1 = base name (LCAL3)
!! $2 = vme channel
!! $3 = first sample
!! $4 = end sample
!! $5 = increment
!! $6 = new base name of file ("pulse" for example)
!!
!! with the name $1.$2, where $1 is a common prefix and $2 a unique suffix
!! for example: $1=lchk6  and $2=037
!! scan from sample $3 to sample $4
!! WARNING: this program crashes if 
!!          any of the following files exist: $1$2.pk  .lev  .t15  .bin
!! --------- prescan for mean value of first 100 samples --------
F
$1.$2
H
464
X
D
B
1
E
100
I
1
D
S
1
1
4
0
S
2
1
4

X
M
1
1
1
0
X
R
$6$2.zro
!! ------- begin full scan -----------
F
$1.$2
!! ------- skip 464 byte header -----
H
464
X
!! ------- data settings ------------
D
!! ------- define input structure ---
D
1
4

S
2
1
4

2
4

X
!! ------- define mapping of input to output structures ---
M
1
1
1
1
2
1
2
2
X
!! -------- let mean of first 100 samples be the zero -----
P
1
4
!! ------- set byte number and increment -------
B
$3
E
$4
I
$5
!! ------- set levels (from file) -----
V
R
levels.txt
X
!! -------- file to create -----------
W
0
$6$2.bin
Y
!! ---------- begin scan ------------
R
Y
Y
Y
X
EOM
close
RESCAN
;
}
sub write_levels_txt
{
# write a copy of levels.txt in the current directory
# if it is not here
my$filename
="levels.txt"
;
return
if
(
-e$filename
)
;
open
LEVELS 
,"> $filename"
or
die
"couldn't open $filename: $!\n"
;
print
LEVELS
<<'EOM';
-1000.
-500.
-200.
-100.
-50.
-20.
-10.
-5.
-2.
-1.
-.5
-.2
-.1
-.05
-.02
-.01
0       
0.01    
0.02015 
0.030452        
0.040909        
0.051523        
0.062296        
0.07323 
0.084328        
0.095593        
0.107027        
0.118633        
0.130412        
0.142368        
0.154504        
0.166821        
0.179324        
0.192014        
0.204894        
0.217967        
0.231237        
0.244705        
0.258376        
0.272251        
0.286335        
0.30063 
0.31514 
0.329867        
0.344815        
0.359987        
0.375387        
0.391018
0.406883
0.422986
0.439331
0.455921
0.47276
0.489851
0.507199
0.524807
0.542679
0.560819
0.579231
0.59792
0.616889
0.636142
0.655684
0.675519
0.695652
0.716087
0.736828
0.757881
0.779249
0.800938
0.822952
0.845296
0.867975
0.890995
0.91436
0.938075
0.962147
0.986579
1.011377
1.036548
1.062096
1.088028
1.114348
1.141063
1.168179
1.195702
1.223638
1.251992
1.280772
1.309984
1.339633
1.369728
1.400274
1.431278
1.462747
1.494688
1.527109
1.560015
1.593415
1.627317
1.661726
1.696652
1.732102
1.768084
1.804605
1.841674
1.879299
1.917488
1.956251
1.995595
2.035528
2.076061
2.117202
2.15896
2.201345
2.244365
2.28803
2.332351
2.377336
2.422996
2.469341
2.516381
2.564127
2.612589
2.661778
2.711704
2.76238
2.813816
2.866023
2.919013
2.972798
3.02739
3.082801
3.139043
3.196129
3.254071
3.312882
3.372575
3.433164
3.494661
3.557081
3.620437
3.684744
3.750015
3.816265
3.883509
3.951762
4.021038
4.091354
4.162724
4.235165
4.308693
4.383323
4.459073
4.535959
4.613998
4.693208
4.773606
4.85521
4.938039
5.022109
5.107441
5.194052
5.281963
5.371193
5.461761
5.553687
5.646992
5.741697
5.837823
5.93539
6.034421
6.134937
6.236961
6.340516
6.445623
6.552308
6.660592
6.770501
6.882059
6.99529
7.110219
7.226872
7.345275
7.465454
7.587436
7.711248
7.836917
7.96447
8.093937
8.225346
8.358727
8.494107
8.631519
8.770992
8.912557
9.056245
9.202089
9.35012
9.500372
9.652878
9.807671
9.964786
10.12426
10.28612
10.45041
10.61717
10.78643
10.95822
11.1326
11.30959
11.48923
11.67157
11.85664
12.04449
12.23516
12.42869
12.62512
12.82449
13.02686
13.23226
13.44075
13.65236
13.86714
14.08515
14.30643
14.53102
14.75899
14.99037
15.22523
15.46361
15.70556
15.95115
16.20041
16.45342
16.71022
16.97087
17.23544
17.50397
17.77653
18.05318
18.33397
18.61898
18.90827
19.20189
19.49992
19.80242
20.10946
20.4211
20.73741
21.05848
21.38435
21.71512
22.05084
22.39161
22.73748
23.08854
23.44487
23.80654
24.17364
24.54625
24.92444
25.30831
25.69793
26.0934
26.4948
26.90222
27.31576
27.73549
28.16153
28.59395
29.03286
29.47835
29.93053
30.38949
30.85533
31.32816
31.80808
32.2952
32.78963
33.29147
33.80085
34.31786
34.84263
35.37527
35.91589
36.46463
37.0216
37.58693
38.16073
38.74314
39.33429
39.9343
40.54332
41.16147
41.78889
42.42572
43.07211
43.72819
44.39411
45.07002
45.75607
46.45242
47.1592
47.87659
48.60474
49.34381
50.09397
50.85538
51.62821
52.41263
53.20882
54.01695
54.83721
55.66976
56.51481
57.37253
58.24312
59.12677
60.02367
60.93402
61.85803
62.79591
63.74784
64.71406
65.69477
66.69019
67.70055
68.72606
69.76695
70.82345
71.8958
72.98424
74.089
75.21034
76.34849
77.50372
78.67628
79.86642
81.07442
82.30053
83.54504
84.80822
86.09034
87.39169
88.71257
90.05326
91.41406
92.79527
94.1972
95.62016
97.06446
98.53042
100.0184
101.5287
103.0616
104.6175
106.1968
107.7997
109.4267
111.0781
112.7543
114.4556
116.1824
117.9352
119.7142
121.5199
123.3527
125.213
127.1012
129.0177
130.963
132.9374
134.9415
136.9756
139.0403
141.1359
143.2629
145.4218
147.6132
149.8374
152.0949
154.3863
156.7121
159.0728
161.4689
163.9009
166.3695
168.875
171.4181
173.9994
176.6194
179.2787
181.9779
184.7175
187.4983
190.3208
193.1856
196.0934
199.0448
202.0404
205.081
208.1673
211.2998
214.4793
217.7065
220.982
224.3068
227.6814
231.1066
234.5832
238.1119
241.6936
245.329
249.019
252.7643
256.5657
260.4242
264.3406
268.3157
272.3504
276.4457
280.6023
284.8214
289.1037
293.4503
297.862
302.3399
306.885
311.4983
316.1808
320.9335
325.7575
330.6539
335.6237
340.668
345.7881
350.9849
356.2596
361.6135
367.0477
372.5635
378.1619
383.8443
389.612
395.4662
401.4082
407.4393
413.5609
419.7743
426.0809
432.4821
438.9794
445.5741
452.2677
459.0617
465.9576
472.957
480.0613
487.2722
494.5913
502.0202
509.5605
517.2139
524.9821
532.8669
540.8699
548.9929
557.2378
565.6064
574.1005
582.722
591.4728
600.3549
609.3702
618.5208
627.8086
637.2357
646.8042
656.5163
666.3741
676.3797
686.5354
696.8434
707.306
717.9256
728.7045
739.6451
750.7498
762.021
773.4613
785.0732
796.8593
808.8222
820.9646
833.289
845.7984
858.4953
871.3828
884.4635
897.7405
911.2166
924.8948
938.7782
952.8699
967.173
981.6906
996.4259
1011.382
1026.563
1041.971
1057.611
1073.485
1089.598
1105.951
EOM
close
LEVELS
;
}
##########################################################################
#
# phase 2
#
##########################################################################
sub phase2
{
my (
$shot
)
=@_
;
my$rescan_file
="rescan.dat"
;
my$output_name
="zoom"
;
my$inc
=10
;
write_rescan_mac
(
)
;
write_levels_txt
(
)
;
while
(
1
)
{
system
'clear'
;
$prompt
= <<"EOP";
	Phase 2 ... rescan the raw data files

	N	Name of shot:$shot
	H	Help
	R	Rescan data file (channel,start,stop)	:$rescan_file
	V	View the rescan data file
	W	output file root name (to 5 characters) :$output_name
	I	increment between data points for saving:$inc
	Y	Yes..do it
	X	eXit

EOP
print$prompt;
$ans
=queryu
(
"Your Selection:"
)
;
if
(
$ans
eq
'N'
)
{
$shot
=get_shot_name
(
)
;
}
elsif
(
$ans
eq
'V'
)
{
system
(
"less $rescan_file"
)
;
}
elsif
(
$ans
eq
'H'
)
{
system
(
"less phase2.txt"
)
;
}
elsif
(
$ans
eq
'I'
)
{
$inc
=query
(
"Enter the increment"
)
;
}
elsif
(
$ans
eq
'R'
)
{
$rescan_file
=query
(
"Enter the rescan data file name:"
)
;
}
elsif
(
$ans
eq
'W'
)
{
$output_name
=query
(
"Enter the output file root name:"
)
;
}
elsif
(
$ans
eq
'X'
)
{
return
;
}
elsif
(
$ans
eq
'Y'
)
{
unless
(
-e$rescan_file
)
{
print
"can't find file $rescan_file\n"
;
next
;
}
my%start
= (
)
;
my%stop
= (
)
;
my$myrescan
="$output_name.sh"
;
my$rescan_lis
="$output_name.lis"
;
`rm $rescan_lis`
;
open
RESCAN
,"> $myrescan"
or
die
"can't open $myrescan.sh: $!\n"
;
open
DATA
,"< $rescan_file"
or
die
"can't open $rescan_file: $!\n"
;
while
(
<DATA>
)
{
chomp
;
next
if
/^\#/
;
my (
$gage
,
$start
,
$stop
)
=split
(
/\s+/
,
$_
,
3
)
;
unless
(
$start
)
{
$start
=$start{
$last_gage
}
}
unless
(
$stop
)
{
$stop
=$stop{
$last_gage
}
}
$start{
$gage
}
=$start
;
$stop{
$gage
}
=$stop
;
my$last_gage
=$gage
}
foreach
$ext
(
keys
%start
)
{
$file
=$shot
.."."
..$ext
..".gz"
;
print
"scanning $shot.$ext\n"
;
unless
(
-e$file
)
{
print
"Cannot find file: $file\n"
;
next
;
}
# write a record to a file
print
RESCAN
"./rescan.sh $shot $ext $start{$ext} $stop{$ext} $inc $output_name\n"
;
`rm $output_name$ext.lev`
;
`rm $output_name$ext.pk`
;
`rm $output_name$ext.t15`
;
`rm $output_name$ext.bin`
;
`rm $output_name$ext.zro`
;
#					print "($shot) ($ext)\n";
`gunzip -c $file >$shot.$ext`
;
`scanbin \@rescan.mac $shot $ext $start{$ext} $stop{$ext} $inc $output_name`
;
`rm $shot.$ext`
;
`echo $output_name$ext.t15 >>$rescan_lis`
;
}
close
RESCAN
;
print
"The file $myrescan is a shell script of the rescan commands\n"
;
print
"The file $rescan_lis has a list of the new binary files created\n"
;
print
"You may examine these files and rescan some more as necessary\n"
;
waitcr
(
)
;
return
;
}
}
}
##########################################################################
#
# phase 3
#
##########################################################################
sub phase3
{
my (
$shot
)
=@_
;
my$path
="./"
;
my$peaks_filename
="peaks.txt"
;
my$toa_filename
="$shot"
.."toa.csv"
;
while
(
1
)
{
system
'clear'
;
$prompt
= <<"EOP";
	Phase 3 ...  collect all peaks and write summary files

	N	Name of shot:$shot
	H	Help
	P	Peaks filename to write		:$peaks_filename
	T	TOA filename to write		:$toa_filename
	Y	Yes..do it
	X	eXit

EOP
print$prompt;
$ans
=queryu
(
"Your Selection:"
)
;
if
(
$ans
eq
'N'
)
{
$shot
=get_shot_name
(
)
;
}
elsif
(
$ans
eq
'H'
)
{
system
(
"less phase3.txt"
)
;
}
elsif
(
$ans
eq
'T'
)
{
$toa_filename
=query
(
"Enter the toa file name:"
)
;
}
elsif
(
$ans
eq
'P'
)
{
$peaks_filename
=query
(
"Enter the peaks file name:"
)
;
}
elsif
(
$ans
eq
'X'
)
{
return
;
}
elsif
(
$ans
eq
'Y'
)
{
# collect peaks and write peaks.txt and shottoa.csv
open
PEAKS
,"> $peaks_filename"
or
die
"can't open $peaks_filename: $!\n"
;
open
TOA
,"> $toa_filename"
or
die
"can't open $toa_filename: $!\n"
;
opendir
(
DIR
,$path
)
;
my@files
=grep
{
/^$shot\d\d\d\.pk$/
}readdir
(
DIR
)
;
closedir
(
DIR
)
;
if
(
$#files
<0
)
{
print
"No .pk files found - check the shot name\n"
;
waitcr
(
)
;
next
}
else
{
my$file
;
foreach
$file
(
@files
)
{
open
INFILE
,"< $file"
or
die
"can't open $file: $!\n"
;
my$channel
=$file
;
if
(
$file
=~
m/(\d\d\d)\./
)
{
$channel
=$1
;
}
my@values
=read_pk
(
)
;
local
$"
="\t"
;
print
PEAKS
"$file\t@values\n"
;
print
TOA
"$channel,$values[4]\n"
;
}
}
close
PEAKS
;
close
TOA
;
putstr
(
"Peak values were written to file:$peaks_filename\n"
)
;
putstr
(
"TOA values were written to file:$toa_filename\n"
)
;
putstr
(
"Now you can procede to run thplot to get impulse\n"
)
;
putstr
(
"And you can run machfit to find COE and HOB\n"
)
;
waitcr
(
)
;
}
}
}
sub read_pk
{
my@values
;
while
(
<INFILE>
)
{
chomp
;
my (
$name
,$val
)
=split
(
/\s+/
,
$_
,
2
)
;
push
@values
,$val
;
}
return
@values
;
}
##########################################################################
#
# phase 4
#
##########################################################################
sub phase4
{
my (
$shot
)
=@_
;
while
(
1
)
{
system
'clear'
;
$prompt
= <<"EOP";
	Phase 4 ... 

	N	Name of shot:$shot
	H	Help
	X	eXit

EOP
print$prompt;
$ans
=queryu
(
"Your Selection:"
)
;
if
(
$ans
eq
'N'
)
{
$shot
=get_shot_name
(
)
;
}
elsif
(
$ans
eq
'H'
)
{
system
(
"less phase4.txt"
)
;
}
elsif
(
$ans
eq
'X'
)
{
return
;
}
}
}
##########################################################################
#
# phase 5
#
##########################################################################
sub phase5
{
my (
$shot
)
=@_
;
my$toafile
="$shot"
.."toa.txt"
;
my$impfile
="$shot"
.."imp.txt"
;
my$csvfile
=$shot
..".csv"
;
while
(
1
)
{
system
'clear'
;
$prompt
= <<"EOP";
	Phase 5 ... combine toa, ovp, and impulse into a single file

	Instructions: be sure the Toa and Impulse files are correct
	(they were made in the previous step) and then enter 'Y'

	N	Name of shot:$shot
	H	Help
	T	Toa file		: $toafile
	I	Impulse file		: $impfile
	F	.csv File to Write   	: $csvfile
	Y	Yes..do it
	X	eXit

EOP
print$prompt;
$ans
=queryu
(
"Your Selection:"
)
;
if
(
$ans
eq
'N'
)
{
$shot
=get_shot_name
(
)
;
}
elsif
(
$ans
eq
'H'
)
{
system
(
"less phase5.txt"
)
;
}
elsif
(
$ans
eq
'T'
)
{
$toafile
=query
(
"Enter the toa file name:"
)
;
}
elsif
(
$ans
eq
'F'
)
{
$csvfile
=query
(
"Enter the .csv file name:"
)
;
}
elsif
(
$ans
eq
'I'
)
{
$impfile
=query
(
"Enter the impulse file name:"
)
;
}
elsif
(
$ans
eq
'X'
)
{
return
;
}
elsif
(
$ans
eq
'Y'
)
{
my (
%ovp
,
%toa
,
%imp
)
;
unless
(
-e$toafile
)
{
print
"can't find file $toafile\n"
;
next
;
}
unless
(
-e$impfile
)
{
print
"can't find file $impfile\n"
;
next
;
}
open
(
INFILE
,$toafile
)
or
die
"Cannot open $toafile: $!\n"
;
while
(
<INFILE>
)
{
next
if
/^\!/
;
chomp
;
$_
=~
s/^\s*(.*)\s*$/$1/
;
my (
$gage
,
$ovp
,
$toa
)
=split
(
/\s+/
,
$_
,
3
)
;
$gage
=~
s/^.*(\d\d\d)$/$1/
;
print
"gage, ovp, toa=$gage,$ovp,$toa\n"
;
$ovp{
$gage
}
=$ovp
;
$toa{
$gage
}
=$toa
/1000.
;# convert to ms
}
close
(
INFILE
)
;
open
(
INFILE
,$impfile
)
or
next
"Cannot open $impfile: $!\n"
;
while
(
<INFILE>
)
{
next
if
/^\!/
;
chomp
;
$_
=~
s/^\s*(.*)\s*$/$1/
;
my (
$gage
,$imp
)
=split
(
/\s+/
,
$_
,
2
)
;
$gage
=~
s/^.*(\d\d\d)$/$1/
;
$imp{
$gage
}
=$imp
;
}
close
(
INFILE
)
;
open
(
OUTFILE
,"> $csvfile"
)
or
die
"Cannot write file $csvfile: $!\n"
;
foreach
(
sort
keys
%ovp
)
{
print
"writing gage: $_\n"
;
print
OUTFILE
"$_, $toa{$_}, $ovp{$_}, $imp{$_}\n"
;
}
close
(
OUTFILE
)
;
putstr
(
"Now you can use this file as input to nblast in phase 6\n"
)
;
waitcr
(
)
;
return
;
}
}
}
##########################################################################
#
# phase 6
#
##########################################################################
sub phase6
{
my (
$shot
)
=(
@_
)
;
my$txtfile
="$shot"
..".txt"
;
my$csvfile
="$shot"
..".csv"
;
my$elgfile
="elgage2.gag"
;
my$gfile
="gage2.gag"
;
my$ap
=12.3
;
my$at
=80.
;
while
(
1
)
{
system
'clear'
;
$prompt
= <<"EOP";
	Phase 6 Menu ... adjust settings then enter Y

	H	Help
	N	Name of '.csv' file	:$csvfile
	F	Name of File to write	:$txtfile
	G	gage file            	:$gfile
	E	Elevated gage file   	:$elgfile
	P	atmospheric Pressure, psi 	:$ap
	T	Atmospheric Temperature, F	:$at
	Y	Yes .. run nblast with these settings
	X	eXit

EOP
print$prompt;
$ans
=queryu
(
"Your Selection:"
)
;
if
(
$ans
eq
'N'
)
{
$csvfile
=query
(
"Enter the .csv file name:"
)
;
}
elsif
(
$ans
eq
'H'
)
{
system
(
"less phase6.txt"
)
;
}
elsif
(
$ans
eq
'F'
)
{
$txtfile
=query
(
"Enter the file name to write:"
)
;
}
elsif
(
$ans
eq
'G'
)
{
$gfile
=query
(
"Enter the gage file name:"
)
;
}
elsif
(
$ans
eq
'E'
)
{
$elgfile
=query
(
"Enter the elevated gage file name:"
)
;
}
elsif
(
$ans
eq
'T'
)
{
$at
=query
(
"Temperature, F\n"
)
;
}
elsif
(
$ans
eq
'P'
)
{
$ap
=query
(
"Pressure, psi\n"
)
;
}
elsif
(
$ans
eq
'Y'
)
{
unless
(
-e$csvfile
)
{
print
"Can't find csv file:$csvfile\n"
;
waitcr
(
)
;
next
;
}
unless
(
-e$elgfile
)
{
print
"Can't find elevated gage file:$elgfile\n"
;
waitcr
(
)
;
next
;
}
print
"Hit <cr> to continue when prompted\n"
;
waitcr
(
)
;
open
NBFILE
,">nbinput.mac"
or
die
"couldn't open nbinput.mac\n"
;
print
NBFILE
<<EOM;
g
$gfile
$csvfile
m
2
ap
$ap
at
$at
i
h
<$elgfile
x
h
2
rp
ri
m
3
i
f
x
rp
ri
f
w
g
y
$txtfile
x
y
EOM
close
NBFILE
;
system
'nblast @nbinput'
;
# remove blank entries
open
INFILE
,$txtfile
or
die
"couldn't open $txtfile\n"
;
my@hobdata
=<INFILE>
;
my (
$lineno
)
;
close
INFILE
;
open
OUTFILE
,">$txtfile"
or
die
"couldn't open $txtfile\n"
;
print
OUTFILE
$hobdata
[0
];# print line of titles
for
(
$lineno
=1
;
$lineno
<@hobdata
;
$lineno
++
)
{
my@line
=split
(
/\t/
,
$hobdata
[
$lineno
]
)
;
if
(
$line
[
4
]>
0.0
)
{
print
OUTFILE
$hobdata
[$lineno
];
}
}
print
"Finished running nblast; results are in $txtfile\n"
;
print
"(You may delete the nblast macro file $nbinput)\n"
;
waitcr
(
)
;
return
;
}
elsif
(
$ans
eq
'X'
)
{
return
;
}
}
}
# vi:ts=4


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl v5.6.1:

Configured by bod at Tue Dec  4 01:59:49 EST 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=linux, osvers=2.4.13, archname=i386-linux
    uname='linux duende 2.4.13 #1 wed oct 31 19:18:07 est 2001 i686 unknown '
    config_args='-Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.6.1 -Darchlib=/usr/lib/perl/5.6.1 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.6.1 -Dsitearch=/usr/local/lib/perl/5.6.1 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Dotherlibdirs=/usr/lib/perl5/5.6:/usr/lib/perl5/5.005 -Duseshrplib -Dlibperl=libperl.so.5.6.1 -Dd_dosuid -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='cc', ccflags ='-DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-DDEBIAN -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.4 20011006 (Debian prerelease)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -ldbm -ldb -ldl -lm -lc -lcrypt
    perllibs=-ldl -lm -lc -lcrypt
    libc=/lib/libc-2.2.4.so, so=so, useshrplib=true, libperl=libperl.so.5.6.1
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.6.1:
    /usr/local/lib/perl/5.6.1
    /usr/local/share/perl/5.6.1
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.6.1
    /usr/share/perl/5.6.1
    /usr/local/lib/site_perl
    /usr/lib/perl5/5.6
    /usr/lib/perl5/5.005/i386-linux
    /usr/lib/perl5/5.005
    .

---
Environment for perl v5.6.1:
    HOME=/home/steve
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/steve/src/cth/bin/linux:/home/steve/bin:/home/steve/src/elk/bin:/sbin:/usr/sbin:/usr/local/sbin:/home/steve/src/cth/bin/linux:/home/steve/bin:/home/steve/src/elk/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About