Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > Perl

Vote on your favorite hash algorithm here!

Perl Discussion for the PERL language - Practical Extraction and Reporting Language, is a programming language often used for creating CGI programs.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-05-2007, 03:40 PM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Credits: 0
Rep Power: 12
NeedHelp is on a distinguished road
Default substr() bug?

I use Active Perl in windows to do my perl scripting and then migrate it to a Linux machine. I've found two bugs:

1) I parse a file and I read segments to get values. One segment looked like:

Code:
$stringValue = substr($n,64,20);
And with Active perl this worked great! So my testing worked great. I move this to production and everything worked great. Then one file I get some odd values. The substr was actually assigning more than 20 characters all of a sudden. I received around 40. I could change the 64 starting value to 60, 70, etc and it would always grab more than 20. I had to end up doing this to make it work in Linux:

Code:
$stringValue = substr($n, 64, 20);
$stringValue = substr($stringValue, 0, 20);
Very odd....

2) Again I'm reading segments and everything is fine in windows. I move it to Linux and have issues. I am using a substr:

Code:
$value = substr($n, 0, 256);
But I get wierd results in Linux so I had to modify to this:

Code:
$value = substr($n,0,128);
$value = $value . substr($n, 0, 128);
Can anyone explain this to me or tell me a fix? I'd like my test and production environment to work the same.
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-05-2007, 10:07 PM
KevinADC KevinADC is offline
Learning Programmer
 
Join Date: Jan 2007
Posts: 91
Credits: 4
Rep Power: 7
KevinADC is on a distinguished road
Default

must be an issue with the data you are running through the substr() function. There is no differenc between substr on winodws or linux that I am aware of.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-06-2007, 08:38 AM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Credits: 0
Rep Power: 12
NeedHelp is on a distinguished road
Default

Quote:
Originally Posted by KevinADC View Post
must be an issue with the data you are running through the substr() function. There is no differenc between substr on winodws or linux that I am aware of.
That is what I always thought and truthfully I expected it to work better on Linux instead of vise versa. If I can provide the sample data is anyone willing to try to repeat the bug?
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-06-2007, 01:54 PM
KevinADC KevinADC is offline
Learning Programmer
 
Join Date: Jan 2007
Posts: 91
Credits: 4
Rep Power: 7
KevinADC is on a distinguished road
Default

I'll take a look.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-07-2007, 09:37 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 7,397
Last Blog:
Tramp Variables
Credits: 1
Rep Power: 20
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

I will as well. I have various Linux machines I can test on and will install ActivePerl if you tell me the version you use.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
Don't hesitate to ask any questions that you have! Check out our ASCII Calculator!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 04-07-2007, 10:06 AM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Credits: 0
Rep Power: 12
NeedHelp is on a distinguished road
Default

Ok, I'll post all the information to replicate this problem next week when I'm back at work.
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 11:00 PM.

Contest Stats

Xav ........ 1357.94
MeTh0Dz|Reb0rn ........ 1077.71
WingedPanther ........ 919.18
marwex89 ........ 906.86
morefood2001 ........ 900.18
John ........ 890.77
Brandon W ........ 770.65
chili5 ........ 312.39
Steve.L ........ 264.99
dcs ........ 234.34

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 83%

Ads