LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-09-2010, 09:45 AM   #1
dissectcode
LQ Newbie
 
Registered: Dec 2010
Posts: 2

Rep: Reputation: 0
Weird problem with chomp() in Perl ??


I am reading data from a video measurement device. I read in <DEV> and when I print it, there seems to be a carriage return so I am using chomp in Perl, but it does FUNKY things.

Code:
    $mode = <DEV>;
    print "mode : $mode\n\n";
    chomp($mode);
    print "chomped mode : $mode OK\n\n";
    return $mode;
returns:
Code:
  mode : NTSC


  OKmped mode : NTSC

what is happening??? My issue is similar to the first one on this page but the solution on this page didn't solve it: http://www.perlmeme.org/faqs/manipul...ext/chomp.html


i am on RedHat btw


also btw - WITHOUT chomp it looks like this:

Code:
    $mode = <DEV>;
    print "mode : $mode\n\n";
#    chomp($mode);
    print "chomped mode : $mode OK\n\n";
    return $mode;
returning:
Code:
mode : NTSC


chomped mode : NTSC
 OK
see how OK is on the next line while i was trying to print it right after $mode ??

please help

Last edited by dissectcode; 12-09-2010 at 09:48 AM.
 
Old 12-09-2010, 09:54 AM   #2
dissectcode
LQ Newbie
 
Registered: Dec 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Can I reply to my own question? I found it here: http://www.perlmonks.org/?node_id=751124

and that worked.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Perl, how do I chomp every 2nd line? hawk__0 Programming 26 02-08-2010 12:57 PM
str.chomp! masternerdguy Programming 3 07-17-2007 02:39 PM
perl's chomp under Win-Linux thelonius Programming 3 04-12-2006 02:13 PM
weird behaviour with hashes in perl weird_guy Programming 0 06-22-2004 09:51 PM
Weird Perl Error HappyDude Programming 3 08-04-2003 12:57 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration