Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: "chomp" not working

by JavaFan (Canon)
on May 02, 2012 at 23:20 UTC ( #968584=note: print w/replies, xml ) Need Help??


in reply to "chomp" not working

What is in $var, what are the results of the print, and what are you expecting?

I expect both prints to print out the same. After all, the chomp has nothing to do, as there will be no newlines left after the split.

Replies are listed 'Best First'.
Re^2: "chomp" not working
by cuautemoc (Initiate) on May 02, 2012 at 23:29 UTC

    $var is taking input from an HTML text area. It goes something like this:

    a,b,c,d e,f,g,h i,j,k,l

    There is a carriage return at the end of each line. @arr1 before the chomp should like like above when printed out. However, I would expect that after the chomp that @arr1 would print like this:

    a,b,c,d e,f,g,h i,j,k,l

    But it doesn't, it prints like the first example.

      There is a carriage return at the end of each line. @arr1 before the chomp should like like above when printed out.
      You are splitting on newlines. Why do you expect them to still be there?
      a,b,c,d
      e,f,g,h
      i,j,k,l

      @arr1 before the chomp should like like above when printed out.

      Why would you expect that?

      >perl -wMstrict -le "my $s = qq{a,b,c,d\ne,f,g,h\ni,j,k,l}; printf qq{$s}; printf qq{\n}; ;; my @ra = split /\n/, $s; printf qq{@ra}; printf qq{\n}; ;; chomp @ra; printf qq{@ra}; printf qq{\n}; " a,b,c,d e,f,g,h i,j,k,l a,b,c,d e,f,g,h i,j,k,l a,b,c,d e,f,g,h i,j,k,l

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://968584]
help
Chatterbox?
[hippo]: :-D
[Eily]: you mean a dll where the SW was written in perl? That sounds unlikely
[muthusathish]: please help me regarding this
[hippo]: Easier just to go and look at the source, no?
[Eily]: mostly because perl isn't compiled in the usual sense of the meaning, you can't execute the opcodes directly, you need the perl engine
[muthusathish]: i dont have the environment too, but i need to get the logics so that i can re-wite
[Eily]: what makes you think your dll is "perl based" ?
[muthusathish]: i dont have source code too
[muthusathish]: it is used in VB 6 appln, while debugging is getting error
[hippo]: Somebody has. Ask the author.

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2018-02-23 09:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (301 votes). Check out past polls.

    Notices?