Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: If

by MAS4891 (Novice)
on Jun 08, 2000 at 20:05 UTC ( #17109=note: print w/replies, xml ) Need Help??

in reply to If doesn't work

Ok, I still cant get it to work... just one question though
what does chomp do?
Also the file has 3 lines, the name, the pass,
and a reminder for the pass.
Should I just make a file for the pass
and another for the rest of the info?

Replies are listed 'Best First'.
RE: Re: If (kudra: avoid redundancy in filename and content)
by kudra (Vicar) on Jun 08, 2000 at 20:15 UTC
    It seems a bit redundant to keep the name in the first line of the file and also to have the filename be the name. You're not using the name in the file for any kind of verification and you already know what it is. If you had one password file, where all names and passwords were listed, keeping the name in the file would be useful, but as it is I don't think your first line is doing anything.
(zdog) Re: (2) If
by zdog (Priest) on Jun 08, 2000 at 20:11 UTC
    chomp VARIABLE
    chomp LIST
    This safer version of chop removes any trailing string that corresponds to the current value of $/ (also known as $INPUT_RECORD_SEPARATOR in the English module). It returns the total number of characters removed from all its arguments. It's often used to remove the newline from the end of an input record when you're worried that the final record may be missing its newline. When in paragraph mode ($/ = ""), it removes all trailing newlines from the string. If VARIABLE is omitted, it chomps $_. Example:
    while (<>) { chomp; # avoid \n on last field @array = split(/:/); # ... }
    You can actually chomp anything that's an lvalue, including an assignment:
    chomp($cwd = `pwd`); chomp($answer = <STDIN>);
    If you chomp a list, each element is chomped, and the total number of characters removed is returned.

    (I got this from perlfunc:chomp)

    -- zdog (Zenon Zabinski)
       Go Bells!!

Re: Re: If
by David Caughell (Monk) on Aug 05, 2003 at 07:18 UTC

    Hi, Mas, it was just a few months ago that I was asking such questions, so I thought I would offer a little help.

    Firstly, chomp removes the newline characters from a scalar value (a string). That's not EXACTLY what it does, but it's close enough, for you, for now. (Since that's what you're probably using it for, and it will probably work.)

    You can find this information by going to

    Perl Functions are the easiest things to understand about Perl, with the exception of weird ones like map (it's cool, it's helpful, but it's weird, and I can't use it reliably yet). You probably want to get a good book on perl (generally speaking, one that's published by O'Reilly Leaf through a few and select one that you can understand. I'm on the second chapter of Programming Perl, and I've had to read a few sections twice, but it's a good book so far.

    Something that you may find helpful (because I did, when I looked up the substr() function), is: a 1value (one-value) means the left side of the equation. So this would be an example of using the substr() function as a 1value:

    substr($str,0,1) = 'D'; #set the first char of $str to 'D'

    Lastly, please look up functions before you ask about them (I've made this mistake quite a few times), and ask questions like this in the chatterbox before you post a message about them.

    Take care,

    "For fate which has ordained that there shall be no friendship among the evil has also ordained that there shall ever be friendship among the good." - Plato / Socrates

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2021-05-09 14:47 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (100 votes). Check out past polls.