Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] (unknown)

Expand Messages
  • Smith, Sheldon
    Welcome, Ozh. One of the first things you should do is get a copy of the Perl FAQ (Frequently Asked Questions) and read through it. The second is get an
    Message 1 of 43 , Jun 26, 2000
    • 0 Attachment
      Welcome, Ozh.

      One of the first things you should do is get a copy of the Perl FAQ
      (Frequently Asked Questions) and read through it. The second is get an
      updated copy from time to time <grin>.
      I am not sure, but I think most Perl installation packages include the Perl
      FAQ. Search for it. It is quite possible that if you enter the command
      perldoc perlfaq
      you may already see the Perl FAQ on your system. In particular, section 4,
      or
      perldoc perlfaq4
      has the question: "How can I output my numbers with commas added?" It then
      shows a simple function, COMMIFY, that given a number, will return the
      number with commas every third position. Looking at it, it should be easy to
      change it to the function SPACIFY -- Hmmm. The name COMMIFY was bad enough.
      Let us call the new function something like PRETTY_NUMBER.

      sub pretty_number {
      local $_ = shift;
      1 while s/^([-+]?\d+)(\d{3})/$1 $2/;
      return $_;
      }

      $n = 23659019423.2331;
      print "GOT: ", pretty_number($n), "\n";

      Ah. I just saved it and tried it. Yes, it works.
      GOT: 23 659 019 423.2331

      It searches for the longest possible string of digits with an optional plus
      or minus sign, followed by a string of three digits. It then puts a space
      between the two strings and repeats until it can not find at least one digit
      adjacent to three consecutive digits.
      Enjoy....
      -----
      Shel Smith
      PS: Your English is far, far better than my French!
      PPS: I studied Latin (and forgot most of it)!

      > -----Original Message-----
      > From: Olivier-Bernard RICHARD
      > [mailto:Olivier-Bernard.Richard@...]
      > Sent: Monday, June 26, 2000 5:02 AM
      > To: perl-beginner
      > Subject: [PBML] (unknown)
      >
      >
      > Hi
      >
      > this is my first post in this ML, I'll shortly introduce myself :
      > my name is Olivier, nick Ozh, from France, so please forgive
      > any weird sentence you'll find in my posts, this is not my
      > mother tongue :)
      > I've been using Perl for 5 weeks now and I really love this
      > new language I'm discovering. Particularly those awesome regexp :)
      > I use Perl mainly (only ?) for cgi, for my websites.
      >
      >
      > I've got a question :
      >
      > In a script I retrieve a file's size ($msize), in bytes.
      > In order to make it more readable, I want to insert a space
      > each 3 letters (so '123456' becomes '123 456' and '1234'
      > becomes '1 234')
      >
      > Here is for now what I did :
      >
      > ($msize=reverse $msize)=~s/(\S{3})/$1 /isg;
      > $msize=reverse $msize;
      >
      > Is there a way to make is prettier ? Is there a way to make
      > reverse regexp (to read the string backwards) ?
      > Or do I really need to reverse and reverse once more ?
      >
      > Thx
      >
      > Ozh
    • aditi gupta
      tr/[A-Z]/[a-z]/g should help. neelam wrote: hi all i want to know that how to replace all upper case alphabets into lower case i
      Message 43 of 43 , Apr 15, 2005
      • 0 Attachment
        tr/[A-Z]/[a-z]/g
        should help.

        neelam <danger11_neelu@...> wrote:

        hi all
        i want to know that how to replace all upper case
        alphabets into lower case i have tried s/// and tr///
        also but no use
        i am reading input from a file
        plz help me
        neelam



        __________________________________
        Do you Yahoo!?
        Yahoo! Small Business - Try our new resources site!
        http://smallbusiness.yahoo.com/resources/


        Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
        Yahoo! Groups Links








        Yahoo! India Matrimony: Find your life partneronline.

        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.