Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Problems with seemingly simple string matching...

by desertrat (Acolyte)
on Oct 04, 2013 at 22:23 UTC ( #1056947=note: print w/ replies, xml ) Need Help??


in reply to Problems with seemingly simple string matching...

damned line endings it was. When I replaced chomp($instr) with chop($instr);chop($instr); everything worked as expected.

NOW what puzzles me is why chomp didn't work. the input file was created on the same platform as the program and the perl interpreter, why didn't it properly remove the <CR>:<NEWLINE> pair?


Comment on Re: Problems with seemingly simple string matching...
Re^2: Problems with seemingly simple string matching...
by Anonymous Monk on Oct 05, 2013 at 01:02 UTC

    NOW what puzzles me is why chomp didn't work.

    ddumperBasic debugging checklist $line and $/

    OTOH, $line =~ s/\s+$//; ## trim trailing whitespace

Re^2: Problems with seemingly simple string matching...
by kcott (Abbot) on Oct 05, 2013 at 15:15 UTC

    G'day desertrat,

    "NOW what puzzles me is why chomp didn't work. the input file was created on the same platform as the program and the perl interpreter, why didn't it properly remove the <CR>:<NEWLINE> pair?"

    From your shebang line, it looks like you're on a *nix OS: default line-ending is "\n". The file you're dealing with has "\r\n", which is the MSWin default.

    I'm not familiar with iCal. Perhaps its default output format is the same as MSWin. You may be able to change that via configuration or options.

    Assuming you are on a *nix OS, given a string ending in "\r\n", I'd expect chomp to remove the trailing newline and leave the carriage return.

    -- Ken

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2014-09-24 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (243 votes), past polls