Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: I need help with pattern matching

by converter (Priest)
on Aug 16, 2002 at 07:10 UTC ( #190604=note: print w/ replies, xml ) Need Help??


in reply to I need help with pattern matching

The cause of the "odd" output is the carriage return character you're leaving on the end of $new_string. I assume you're running this code on UNIX so that $/ is set to "\n" and chomp() removes only the newline, leaving the carriage return, which when output to the display device repositions the point at the beginning of the line.

You could get rid of the carriage return by assigning the proper record separator string to a dynamic copy of $/:

{ # localized global variable # this copy of $/ is visible only within this block # and to subroutines called from within the block. local $/ = "\r\n"; while (<I>) { next unless /Physical Address/; /:/; # why is this here? chomp; # chomp now removes "\r" in addition to "\n" ... }


Comment on Re: I need help with pattern matching
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://190604]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (16)
As of 2014-09-30 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (378 votes), past polls