• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

ok, all you perl guys who were here last night, help me out.

notfred

Lifer
look at this code fragment:
--------------------------------------------------------------
for(my $i=0; $i<=$#users; $i++){
if($users[$i][0] eq $name){
chop($users[$i][2]);
my @projects = split(/,/, $users[$i][2]);
return @projects;
}
}
--------------------------------------------------------------

it works fine. However, to get it to work CORRECTLY, I have to replace the 'chop' with a 'chomp'.

If I do that, it doesn't work. it wont remove the trailing newline with a chomp. I've tried about everything I can think of, and nothing is working.

It's redhat 7.1 running perl 5.6.0.

This is pissing me off...


edit: posted blank message.
 
What is chomp removing when you use it?
Sorry if I'm not any help, I've been up for 43 hours straight and I can't even read my own Perl now.
 
ugh. $/ is set to ascii 010 when run on the server, and \n is 013, at least on my editing box....

hmm......

well, now that I know how to fix it, how do I force 010 or 013?
 
I'm not sure I understand what you're asking (Sorry, I'm beat and ready to pass out). Do you just want to set it to the newline before your code? Something like: local ($/) = "\n"; perhaps?
Edit for lack of semicolon goodness
 


<< I'm not sure I understand what you're asking (Sorry, I'm beat and ready to pass out). Do you just want to set it to the newline before your code? Something like: local ($/) = "\n"; perhaps?
Edit for lack of semicolon goodness
>>



tried that, whole script bombed.

Apparently, sometimes the newline is ascii character 10, and sometimes it's 13, and chomp is only worknig when it's 10....
 


<< Well, that just sucks, I don't really know what else to tell you, sorry I couldn't be more help. >>



43 hours is too long to be up, go to bed 🙂
 


<< Oh how I wish I could. Unfortunately this is kind of a graduate or don't graduate deal. Woohoo, two all-nighters for me...so pleased. >>



argh, chomp's an asshole. stupid chomp.
 
well, here's my idea (not tested yet): Instead of chomp($string);

I get to do:

if(substr($string, length($string)) == chr(10) || substr($string, length($string)) == chr(13)){chop($string)}

I think it'll work.
 
Back
Top