# New Ticket Created by Nils # Please include the string: [perl #34233] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=34233 >
Attached is the bugreport and code to reproduce it. If there are questions, please drop me a line. Thanks, Nils.
test.csv
Description: MS-Excel spreadsheet
#!/usr/bin/perl -w
use strict;
use Switch;
my $dataend="1900.01.01 00:00:00";
my $datastart="2099.12.31 23:59:59";
my $OUTFILE=0;
main();
exit;
sub parse_infile
{
my $year=0;
my $mon=0;
my $day=0;
my $hour=0;
my $min=0;
my $sec=0;
my $checkdate=0;
my @datetime=();
my $fullname = "test.csv";
open(INFILE, "<$fullname") || die("Cannot open infile '$fullname': $!
...exiting!\n");
print "Parsing file $fullname...\n";
# read the header line
my $inline=<INFILE>;
chomp($inline);
$inline =~ s/\s//g;
my @line = split(/[,;]/,$inline);
while (<INFILE>)
{
my($inline) = $_;
chomp($inline);
@line = split(/[,;]/,$inline);
if(not $checkdate)
{
# if the date format is OK, don't bother checking it for the rest of the infile
if($line[34] =~ /\d\d\d\d\.\d\d\.\d\d\s+\d\d:\d\d:\d\d/)
{ $checkdate=1; }
else
{
# reconstruct the DATE TIME stamp in case format differences were found
# printf STDERR "OLD: $line[$pos_CREATED]\n";
# print STDERR "'$year' '$mon' '$day' '$hour' '$min' '$sec'\n";
$line[34] = sprintf "%.4d.%.2d.%.2d %.2d:%.2d:%.2d",
$year,$mon,$day,$hour,$min,$sec;
}
}
}
}
sub histodata
{
my $bins=50;
for (my $i=0; $i<=$bins; $i++)
{ my $mybin = ($i-($bins/2))*10; }
}
sub plotdata
{
my $filename="plotdata/allpoints.dat";
open(fileALL, ">$filename") ||
die("Can't open file $filename for writing: $!!\n");
close fileALL;
}
sub main
{
my $linecount=0;
my $startyear=2000;
my $startmon=01;
my $startday=01;
my $starthour=0;
my $startmin=0;
my $startsec=0;
my $endyear=2099;
my $endmon=12;
my $endday=31;
my $endhour=23;
my $endmin=59;
my $endsec=59;
my $startepoch;
$OUTFILE=\*STDOUT;
# parse command line arguments
my $argc = @ARGV;
my $starttime = sprintf "%.4d.%.2d.%.2d %.2d:%.2d:%.2d",
$startyear, $startmon, $startday, $starthour, $startmin, $startsec;
my $endtime = sprintf "%.4d.%.2d.%.2d %.2d:%.2d:%.2d",
$endyear, $endmon, $endday, $endhour, $endmin, $endsec;
$startepoch=time();
printf STDERR "-- START INFILE %d\n", time();
parse_infile();
printf STDERR "-- END INFILE %d\n", time();
printf STDERR "-- DURATION: %d\n", time()-$startepoch;
my $corrstart = "BEGIN processing timeframe 2000.01.01 00:00:00 to 2099.12.31
23:59:59";
my $corrend = "DONE processing timeframe 2099.12.31 23:59:59 to 1900.01.01
00:00:00";
print STDERR "CORRECT: $corrstart\n";
print $OUTFILE "BEGIN processing timeframe $starttime to $endtime\n";
print STDERR "BEGIN processing timeframe $starttime to $endtime\n";
my $wrongstart = sprintf "BEGIN processing timeframe $starttime to
$endtime\n";
print STDERR "CORRECT: $corrend\n";
print $OUTFILE "DONE processing timeframe $datastart to $dataend\n";
print STDERR "DONE processing timeframe $datastart to $dataend\n";
my $wrongend = sprintf "DONE processing timeframe $datastart to $dataend\n";
printf STDERR "-- END %d\n", time();
printf STDERR "-- DURATION: %d\n", time()-$startepoch;
}
To: [EMAIL PROTECTED]
Subject: Including Switch in a perl code breaks it, even if it is not used!
Cc: [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
Message-Id: <[EMAIL PROTECTED]>
This is a bug report for perl from [EMAIL PROTECTED],
generated with the help of perlbug 1.35 running under perl v5.8.6.
-----------------------------------------------------------------
[Please enter your report here]
using Perl, running under Cygwin on Win XP SP2
including "use Switch;" in the program breaks the program, even if it is not
used. Adding or removing comments or random lines of code (whether actually
called or not) can cause or remove the program.
To reproduce:
- save data as test.csv
- save program as prog.pl
- run as prog.pl > output
- there are additional spaces behind "timeframe" instead of one. This breaks a
longer version of the proram, this was the easiest way to reproduce the problem.
Switch should be fixed or removed from Core. It is a serious liability.
Thanks,
Nils.
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=critical
---
Site configuration information for perl v5.8.6:
Configured by gerrit at Thu Jan 27 11:04:16 EST 2005.
Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
Platform:
osname=cygwin, osvers=1.5.12(0.11642), archname=cygwin-thread-multi-64int
uname='cygwin_nt-4.0 loreley 1.5.12(0.11642) 2004-11-10 08:34 i686 unknown
unknown cygwin '
config_args='-de -Dmksymlinks -Duse64bitint -Dusethreads -Doptimize=-O3
-Dman3ext=3pm'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=define use64bitall=undef uselongdouble=undef
usemymalloc=y, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe
-I/usr/local/include',
optimize='-O3',
cppflags='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe
-I/usr/local/include'
ccversion='', gccversion='3.4.1 (cygming special)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='ld2', ldflags =' -s -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib /lib
libs=-lgdbm -ldb -lcrypt -lgdbm_compat
perllibs=-lcrypt -lgdbm_compat
libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' -s'
cccdlflags=' ', lddlflags=' -s -L/usr/local/lib'
Locally applied patches:
---
@INC for perl v5.8.6:
/usr/lib/perl5/5.8/cygwin
/usr/lib/perl5/5.8
/usr/lib/perl5/site_perl/5.8/cygwin
/usr/lib/perl5/site_perl/5.8
/usr/lib/perl5/site_perl/5.8
/usr/lib/perl5/vendor_perl/5.8/cygwin
/usr/lib/perl5/vendor_perl/5.8
/usr/lib/perl5/vendor_perl/5.8
.
---
Environment for perl v5.8.6:
HOME=/cygdrive/c/Dokumente und Einstellungen/nbo.LOCANIS
LANG (unset)
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/oracle/ora92/bin:/cygdrive/c/Programme/Oracle/jre/1.3.1/bin:/cygdrive/c/Programme/Oracle/jre/1.1.8/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/DOWNLO~1/ftp/ncftp/bin
PERL_BADLANG (unset)
SHELL (unset)
