Printer Friendly Version Print this thread
Email this thread to a friend eMail this thread to a friend
  • php update question (In: Coding & Databases - PHP, ASP, Perl, etc.)
  • A question about article submit (In: Directories and Link Building)
  • Featured Web Site Template

    Hundreds More at Free Site Templates.com!

    Web Site Partners
    Sponsored Links
    Jet City Software
     
    Whos Here ?
    There are 0 guests and 1 members in the forums right now.
    Reflects user activity within the last 5 minutes
    Moderator(s): Prowler, jcokos
    Member Message

    oldpete
    Joined: Oct 23, 2005
    # Posts: 45

    View the profile for oldpete Send oldpete a private message

    Posted: 2005-Nov-08 22:13
    Edit Message Delete Message Reply to this message

    Anyone here good with Perl?

    Here's the question:

    I have a field that is read from a flat file and assigned a $name in some code.

    So, let's say the flat file looks like this:

    Monkey_Brains1.00Brown

    Naturally, the first field is "Monkey_Brains"
    The second field is "1.00"
    The third field is "Brown"

    The first field is assigned a variable, we'll call it:

    $name

    Now here's what I would like to do. All the fields in the $name spot have an underscore '_' between each word. I would like code that could read this field and strip the underscore out. So "Monkey_Brains" would be come "Monkey Brains"

    In essence:

    $name would equal "Monkey_Brains"

    Then some code that reads and modifies $name

    $modifiedname would now equal "Monkey Brains"

    Many Thanks,

    Pete



    masidani
    Joined: Oct 21, 2005
    # Posts: 10

    View the profile for masidani Send masidani a private message

    Posted: 2005-Nov-09 20:49
    Edit Message Delete Message Reply to this message

    $name = "Monkey_Brains";
    $name =~ s/_/ /; # substitution operator
    print $name;



    You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
    1. You have not yet logged in, or registered properly as a member
    2. You are a member, but no longer have posting rights.
    3. This is a private forum, for which you do not have permissions.

    If you are a recent member, it's possible that you simply have not yet confirmed your account. Please check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions contained within.

    If you cannot find this message, click here to Re-Send it.

    If you are still experiencing problem, please read the Login Assistance Article for some advice on what may be causing your login not to work properly.

    Switch to Advanced Editor and ... Create a New Topic or Reply to this Thread

    New posts Forum is locked
    © 1995  ·  iWeb, Inc  ·  DBA JimWorld Productions