[28026] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9390 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 27 09:06:59 2006

Date: Tue, 27 Jun 2006 06:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 27 Jun 2006     Volume: 10 Number: 9390

Today's topics:
        ANN: Win32-Fonts-Info V0.01 <rprp@gmx.net>
        local variables and global variables <hara.acharya@gmail.com>
        making exe of a perl script <hara.acharya@gmail.com>
    Re: Need Search::Binary examples <hjp-usenet2@hjp.at>
        Parsing data file, need help with the logic guser@packetstorm.org
    Re: Please help Perl Newbie understand this statement jm-1@remotekontrol.com
    Re: Please help Perl Newbie understand this statement <rvtol+news@isolution.nl>
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@augustmail.com
        Smart method to reformat date  <SaltyBall@Hell.com>
    Re: Smart method to reformat date <David.Squire@no.spam.from.here.au>
    Re: Smart method to reformat date <SaltyBall@Hell.com>
    Re: Smart method to reformat date <David.Squire@no.spam.from.here.au>
    Re: syntax for print form layout <<tabluar>> <raosrinat@gmail.com>
    Re: Termination and type systems <dthierbach@usenet.arcornews.de>
    Re: What is Expressiveness in a Computer Language <ketil+news@ii.uib.no>
    Re: What is Expressiveness in a Computer Language <rvtol+news@isolution.nl>
        XML::Smart: Removing node <mwulfff@yahoo.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 27 Jun 2006 09:27:43 GMT
From: Reinhard Pagitsch <rprp@gmx.net>
Subject: ANN: Win32-Fonts-Info V0.01
Message-Id: <J1IMyx.Hwx@zorch.sf-bay.org>

This is the the first release of this module.

An extract of the dos:
NAME

Win32::Fonts::Info - Perl extension for get a list of installed
fontfamilies on a Win32 Computer.

DESCRIPTION

The Module Win32::Fonts::Info uses the GDI API EnumFontFamiliesEx() to
retrive the list of installed Fontfamilies.
There are three types of fonts which can be found on a Windows system:
Raster Fonts, Truetype Fonts and Vector Fonts. All informations about a
font will be saved in two structures: a text metric structure
(physical-font data) and a LOGFONT structure (logical-font data). The
Output of the functions GetFontInfo*() returns a hash reference to a
combination of text metrics and logical font data. Logical font data
are begining with "elf" or "lf" and text metrics are with "tm" or "ntm".

I asume that the user have some knowledge about the Windows GDI API.

for more information please read the module documentation.

regards,
Reinhard




------------------------------

Date: 27 Jun 2006 05:31:21 -0700
From: "king" <hara.acharya@gmail.com>
Subject: local variables and global variables
Message-Id: <1151411481.370442.126990@u72g2000cwu.googlegroups.com>

Hi,
How and what should be used to define a local variable and a global
variable as well.

and if i have used a sub-routine in a script and i want to use that
sub-routine in another script,
how can i do that.

regards



------------------------------

Date: 27 Jun 2006 05:29:09 -0700
From: "king" <hara.acharya@gmail.com>
Subject: making exe of a perl script
Message-Id: <1151411349.195211.296550@y41g2000cwy.googlegroups.com>

Hi,
I have written a perl script and i want this script to be used by
others.
But they will have to install active perl to make that work.
and of course if i have used any modules in that script then they have
to install that module as well.

Can any-body suggest anything so that it will be easy for every-one to
use without installing anything.

that is i want to make my script a stand alone application that too
without using PDK.

Can it be done without using PDK.

regards



------------------------------

Date: Tue, 27 Jun 2006 10:47:54 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Need Search::Binary examples
Message-Id: <qbrq7e.5ln.ln@teal.hjp.at>

Arvin Portlock wrote:
> Peter J. Holzer wrote:
>> Search::Binary is obviously written to search files, not arrays. But it
>> can be used to search arrays, too. Some of the generality for searching
>> files isn't needed for searching arrays (for example, in a file not
>> every possible position is the start of a record).
>> I've changed your script to use Search::Binary, and included the
>> relevant part of the documentation before each line. That's quite a lot
>> of documentation per line of code, I hope it helps you to make sense
>> both of the docs and the code.
> 
> Hey, it works! I can't thank you enough for the example. I'll
> be interested to do some benchmarks with a real data set to see
> how much time I saved over something like simply incrementing
> the initial array index for each random number when possible.

If you do, also play around with the optional $size parameter. The
default is 512 is which probably much too high for in-memory lookups. I
suspect that the optimal value in this case is 1 but haven't tested it.

> Some of the documentation makes a bit more sense now. $handle
> was confusing to me despite the comments in the documentation.
> I probably would have named it $param myself.

$param is an awfully non-descriptive name. All parameters are
parameters, why would you call one of them $param, but not the others?
$handle makes a lot of sense if you search a file: Most probably you
would just use the file handle. There are also other handles (database
handles, window handles), so using $handle as a generic term for the
parameter which is used to access the data to be searched seems ok to
me.

> I guarantee I NEVER would have figured out what I was supposed to do
> in $read, though I understood at least that it is a callback. I've
> never familiarized myself with specific binary search algorithms so
> that's probably why the documentation was so opaque to me. Though I
> thought modern libraries were supposed to shield users from having to
> know algorithms.

That it does. You don't have to know anything about the binary search 
algorithm to use it (In fact, Search::Binary doesn't implement a pure
binary search - it switches to linear search for small amounts of data).
The model is rather the same as for sort: You don't have to know how the
sorting is done, but you need to supply a function which does the
comparison.

I do agree that the documentation isn't easy to understand. I had to
step through binary_search in the debugger to find an error I made at
first.

        hp

-- 
   _  | Peter J. Holzer    | Man könnte sich [die Diskussion] auch
|_|_) | Sysadmin WSR/LUGA  | sparen, wenn man sie sich einfach sparen
| |   | hjp@hjp.at         | würde.
__/   | http://www.hjp.at/ |   -- Ralph Angenendt in dang 2006-04-15


------------------------------

Date: 27 Jun 2006 05:56:22 -0700
From: guser@packetstorm.org
Subject: Parsing data file, need help with the logic
Message-Id: <1151412982.705884.214580@m73g2000cwd.googlegroups.com>

I have a set of files that get generated from a login script that I
need to integrate into our database.

The format in each file is like this

Machine:blah
User:foo
Domain:foo.bar
SN:nnnnnnn
Asset:nnnnnnnnnnnnn
OS:blah
SP:blah

Windows IP Configuration

         Host Name . . . . . . . . . . . . : blah
        Primary Dns Suffix  . . . . . . . : foo.bar
        Node Type . . . . . . . . . . . . : Hybrid
        IP Routing Enabled. . . . . . . . : No
         WINS Proxy Enabled. . . . . . . . : No
        DNS Suffix Search List. . . . . . : foo.bar
                                            foo.bar
                                            foo.bar

Ethernet adapter Wireless Network Connection:

        Media State . . . . . . . . . . . : Media disconnected
        Description . . . . . . . . . . . : blah


Ethernet adapter Local Area Connection:

        Connection-specific DNS Suffix  . : blah
        Description . . . . . . . . . . . : blah Gigabit Integrated
Controller
        Physical Address. . . . . . . . . : mac
        Dhcp Enabled. . . . . . . . . . . : Yes
        Autoconfiguration Enabled . . . . : Yes
        IP Address. . . . . . . . . . . . : n.n.n.n
        Subnet Mask . . . . . . . . . . . : n.n.n.n
        Default Gateway . . . . . . . . . : n.n.n.n
        DHCP Server . . . . . . . . . . . : n.n.n.n
        DNS Servers . . . . . . . . . . . : n.n.n.n
                                            n.n.n.n
        Primary WINS Server . . . . . . . : n.n.n.n
        Secondary WINS Server . . . . . . : n.n.n.n
                                            n.n.n.n
        Lease Obtained. . . . . . . . . . : Tuesday, June 27, 2006
7:05:51 AM
        Lease Expires . . . . . . . . . . : Wednesday, June 28, 2006
7:05:51 AM

Ethernet adapter Network Connect Adapter:


        Description . . . . . . . . . . . : blah Virtual Adapter
        Physical Address. . . . . . . . . : mac



Here is the logic I am trying to convert to code:

while (<FILE>)
 do until $_ =~ /Windows IP Configuration/
      get Machine:blah
            User:foo
            Domain:foo.bar
            SN:nnnnnnn
            Asset:nnnnnnnnnnnnn
           OS:blah
           SP:blah
 }
 do until $_ =~ /Ethernet adapter/
      get Host Name . . . . . . . . . . . . : blah
        Primary Dns Suffix  . . . . . . . : foo.bar
        Node Type . . . . . . . . . . . . : Hybrid
        IP Routing Enabled. . . . . . . . : No
         WINS Proxy Enabled. . . . . . . . : No
        DNS Suffix Search List. . . . . . : foo.bar
                                            foo.bar
                                            foo.bar

 #at this point i need some help as I have N interface chunks to loop
through before reaching the end of file.


any suggestions?

thanks.



------------------------------

Date: 27 Jun 2006 01:54:30 -0700
From: jm-1@remotekontrol.com
Subject: Re: Please help Perl Newbie understand this statement
Message-Id: <1151398469.924022.153310@p79g2000cwp.googlegroups.com>

Hi Tad

In response to your request

>> "Please compose followups the proper way, quoting only what you are
>> going to comment on, trimming stuff that you are not going to comment
>> on, and interleaving your comments after the quoted text that the
>> comment applies to."

I will be sure to clean up my act when responding to messages in the
groups. My apologies, I do not use the groups that often. I will read
the FAQ (I promise).

Thank you for help

Regards

Andy


Tad McClellan wrote:
> jm-1@remotekontrol.com <jm-1@remotekontrol.com> wrote:
>
> > Thank You very much for your help.
>
>
> You are welcome.
>
> I am going to ask something in return.
>
> Please compose followups the proper way, quoting only what you are
> going to comment on, trimming stuff that you are not going to comment
> on, and interleaving your comments after the quoted text that the
> comment applies to.
>
> Have you seen the Posting Guidelines that are posted here frequently?
>
>
> > I have been reading the tutorials @
> > http://learn.perl.org/library/beginning_perl/.
>
>
> Oh, allright then. You've managed to find one of the good ones.  :-)
>
>
> > I have always avoided programming because I find
> > it frustrating
>
>
> If the frustration is something that you would prefer to not deal
> with, then you can always hire an actual programmer. (like me!)
>
> heh.
>
>
>
> [ snip TOFU ]
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas



------------------------------

Date: Tue, 27 Jun 2006 11:36:33 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Please help Perl Newbie understand this statement
Message-Id: <e7r5cv.13g.1@news.isolution.nl>

Jürgen Exner schreef:
> Tad McClellan:

>> So then,  m/^\w/ will match (and return true) if the 1st
>> character in $_ is one of the 63 "word" characters.
>
> Subject to your locale, of course ;-)

See my unicount.pl in
news:e66dbg.1ec.1@news.isolution.nl
that finds:

word
 91801 /194522 = 47.193%  (lower:  1380, upper:  1160)

-- 
Affijn, Ruud

"Gewoon is een tijger."




------------------------------

Date: 27 Jun 2006 07:22:10 GMT
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.6 $)
Message-Id: <44a0dca1$0$57729$ae4e5890@news.nationwide.net>

Outline
   Before posting to comp.lang.perl.misc
      Must
       - Check the Perl Frequently Asked Questions (FAQ)
       - Check the other standard Perl docs (*.pod)
      Really Really Should
       - Lurk for a while before posting
       - Search a Usenet archive
      If You Like
       - Check Other Resources
   Posting to comp.lang.perl.misc
      Is there a better place to ask your question?
       - Question should be about Perl, not about the application area
      How to participate (post) in the clpmisc community
       - Carefully choose the contents of your Subject header
       - Use an effective followup style
       - Speak Perl rather than English, when possible
       - Ask perl to help you
       - Do not re-type Perl code
       - Provide enough information
       - Do not provide too much information
       - Do not post binaries, HTML, or MIME
      Social faux pas to avoid
       - Asking a Frequently Asked Question
       - Asking a question easily answered by a cursory doc search
       - Asking for emailed answers
       - Beware of saying "doesn't work"
       - Sending a "stealth" Cc copy
      Be extra cautious when you get upset
       - Count to ten before composing a followup when you are upset
       - Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------

Posting Guidelines for comp.lang.perl.misc ($Revision: 1.6 $)
    This newsgroup, commonly called clpmisc, is a technical newsgroup
    intended to be used for discussion of Perl related issues (except job
    postings), whether it be comments or questions.

    As you would expect, clpmisc discussions are usually very technical in
    nature and there are conventions for conduct in technical newsgroups
    going somewhat beyond those in non-technical newsgroups.

    The article at:

        http://www.catb.org/~esr/faqs/smart-questions.html

    describes how to get answers from technical people in general.

    This article describes things that you should, and should not, do to
    increase your chances of getting an answer to your Perl question. It is
    available in POD, HTML and plain text formats at:

     http://www.augustmail.com/~tadmc/clpmisc.shtml

    For more information about netiquette in general, see the "Netiquette
    Guidelines" at:

     http://andrew2.andrew.cmu.edu/rfc/rfc1855.html

    A note to newsgroup "regulars":

       Do not use these guidelines as a "license to flame" or other
       meanness. It is possible that a poster is unaware of things
       discussed here.  Give them the benefit of the doubt, and just
       help them learn how to post, rather than assume 

    A note about technical terms used here:

       In this document, we use words like "must" and "should" as
       they're used in technical conversation (such as you will
       encounter in this newsgroup). When we say that you *must* do
       something, we mean that if you don't do that something, then
       it's unlikely that you will benefit much from this group.
       We're not bossing you around; we're making the point without
       lots of words.

    Do *NOT* send email to the maintainer of these guidelines. It will be
    discarded unread. The guidelines belong to the newsgroup so all
    discussion should appear in the newsgroup. I am just the secretary that
    writes down the consensus of the group.

Before posting to comp.lang.perl.misc
  Must
    This section describes things that you *must* do before posting to
    clpmisc, in order to maximize your chances of getting meaningful replies
    to your inquiry and to avoid getting flamed for being lazy and trying to
    have others do your work.

    The perl distribution includes documentation that is copied to your hard
    drive when you install perl. Also installed is a program for looking
    things up in that (and other) documentation named 'perldoc'.

    You should either find out where the docs got installed on your system,
    or use perldoc to find them for you. Type "perldoc perldoc" to learn how
    to use perldoc itself. Type "perldoc perl" to start reading Perl's
    standard documentation.

    Check the Perl Frequently Asked Questions (FAQ)
        Checking the FAQ before posting is required in Big 8 newsgroups in
        general, there is nothing clpmisc-specific about this requirement.
        You are expected to do this in nearly all newsgroups.

        You can use the "-q" switch with perldoc to do a word search of the
        questions in the Perl FAQs.

    Check the other standard Perl docs (*.pod)
        The perl distribution comes with much more documentation than is
        available for most other newsgroups, so in clpmisc you should also
        see if you can find an answer in the other (non-FAQ) standard docs
        before posting.

    It is *not* required, or even expected, that you actually *read* all of
    Perl's standard docs, only that you spend a few minutes searching them
    before posting.

    Try doing a word-search in the standard docs for some words/phrases
    taken from your problem statement or from your very carefully worded
    "Subject:" header.

  Really Really Should
    This section describes things that you *really should* do before posting
    to clpmisc.

    Lurk for a while before posting
        This is very important and expected in all newsgroups. Lurking means
        to monitor a newsgroup for a period to become familiar with local
        customs. Each newsgroup has specific customs and rituals. Knowing
        these before you participate will help avoid embarrassing social
        situations. Consider yourself to be a foreigner at first!

    Search a Usenet archive
        There are tens of thousands of Perl programmers. It is very likely
        that your question has already been asked (and answered). See if you
        can find where it has already been answered.

        One such searchable archive is:

         http://groups.google.com/advanced_group_search

  If You Like
    This section describes things that you *can* do before posting to
    clpmisc.

    Check Other Resources
        You may want to check in books or on web sites to see if you can
        find the answer to your question.

        But you need to consider the source of such information: there are a
        lot of very poor Perl books and web sites, and several good ones
        too, of course.

Posting to comp.lang.perl.misc
    There can be 200 messages in clpmisc in a single day. Nobody is going to
    read every article. They must decide somehow which articles they are
    going to read, and which they will skip.

    Your post is in competition with 199 other posts. You need to "win"
    before a person who can help you will even read your question.

    These sections describe how you can help keep your article from being
    one of the "skipped" ones.

  Is there a better place to ask your question?
    Question should be about Perl, not about the application area
        It can be difficult to separate out where your problem really is,
        but you should make a conscious effort to post to the most
        applicable newsgroup. That is, after all, where you are the most
        likely to find the people who know how to answer your question.

        Being able to "partition" a problem is an essential skill for
        effectively troubleshooting programming problems. If you don't get
        that right, you end up looking for answers in the wrong places.

        It should be understood that you may not know that the root of your
        problem is not Perl-related (the two most frequent ones are CGI and
        Operating System related), so off-topic postings will happen from
        time to time. Be gracious when someone helps you find a better place
        to ask your question by pointing you to a more applicable newsgroup.

  How to participate (post) in the clpmisc community
    Carefully choose the contents of your Subject header
        You have 40 precious characters of Subject to win out and be one of
        the posts that gets read. Don't waste them. Take care while
        composing them, they are the key that opens the door to getting an
        answer.

        Spend them indicating what aspect of Perl others will find if they
        should decide to read your article.

        Do not spend them indicating "experience level" (guru, newbie...).

        Do not spend them pleading (please read, urgent, help!...).

        Do not spend them on non-Subjects (Perl question, one-word
        Subject...)

        For more information on choosing a Subject see "Choosing Good
        Subject Lines":

         http://www.cpan.org/authors/id/D/DM/DMR/subjects.post

        Part of the beauty of newsgroup dynamics, is that you can contribute
        to the community with your very first post! If your choice of
        Subject leads a fellow Perler to find the thread you are starting,
        then even asking a question helps us all.

    Use an effective followup style
        When composing a followup, quote only enough text to establish the
        context for the comments that you will add. Always indicate who
        wrote the quoted material. Never quote an entire article. Never
        quote a .signature (unless that is what you are commenting on).

        Intersperse your comments *following* each section of quoted text to
        which they relate. Unappreciated followup styles are referred to as
        "top-posting", "Jeopardy" (because the answer comes before the
        question), or "TOFU" (Text Over, Fullquote Under).

        Reversing the chronology of the dialog makes it much harder to
        understand (some folks won't even read it if written in that style).
        For more information on quoting style, see:

         http://web.presby.edu/~nnqadmin/nnq/nquote.html

    Speak Perl rather than English, when possible
        Perl is much more precise than natural language. Saying it in Perl
        instead will avoid misunderstanding your question or problem.

        Do not say: I have variable with "foo\tbar" in it.

        Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
        or I have $var = <DATA> (and show the data line).

    Ask perl to help you
        You can ask perl itself to help you find common programming mistakes
        by doing two things: enable warnings (perldoc warnings) and enable
        "strict"ures (perldoc strict).

        You should not bother the hundreds/thousands of readers of the
        newsgroup without first seeing if a machine can help you find your
        problem. It is demeaning to be asked to do the work of a machine. It
        will annoy the readers of your article.

        You can look up any of the messages that perl might issue to find
        out what the message means and how to resolve the potential mistake
        (perldoc perldiag). If you would like perl to look them up for you,
        you can put "use diagnostics;" near the top of your program.

    Do not re-type Perl code
        Use copy/paste or your editor's "import" function rather than
        attempting to type in your code. If you make a typo you will get
        followups about your typos instead of about the question you are
        trying to get answered.

    Provide enough information
        If you do the things in this item, you will have an Extremely Good
        chance of getting people to try and help you with your problem!
        These features are a really big bonus toward your question winning
        out over all of the other posts that you are competing with.

        First make a short (less than 20-30 lines) and *complete* program
        that illustrates the problem you are having. People should be able
        to run your program by copy/pasting the code from your article. (You
        will find that doing this step very often reveals your problem
        directly. Leading to an answer much more quickly and reliably than
        posting to Usenet.)

        Describe *precisely* the input to your program. Also provide example
        input data for your program. If you need to show file input, use the
        __DATA__ token (perldata.pod) to provide the file contents inside of
        your Perl program.

        Show the output (including the verbatim text of any messages) of
        your program.

        Describe how you want the output to be different from what you are
        getting.

        If you have no idea at all of how to code up your situation, be sure
        to at least describe the 2 things that you *do* know: input and
        desired output.

    Do not provide too much information
        Do not just post your entire program for debugging. Most especially
        do not post someone *else's* entire program.

    Do not post binaries, HTML, or MIME
        clpmisc is a text only newsgroup. If you have images or binaries
        that explain your question, put them in a publically accessible
        place (like a Web server) and provide a pointer to that location. If
        you include code, cut and paste it directly in the message body.
        Don't attach anything to the message. Don't post vcards or HTML.
        Many people (and even some Usenet servers) will automatically filter
        out such messages. Many people will not be able to easily read your
        post. Plain text is something everyone can read.

  Social faux pas to avoid
    The first two below are symptoms of lots of FAQ asking here in clpmisc.
    It happens so often that folks will assume that it is happening yet
    again. If you have looked but not found, or found but didn't understand
    the docs, say so in your article.

    Asking a Frequently Asked Question
        It should be understood that you may have missed the applicable FAQ
        when you checked, which is not a big deal. But if the Frequently
        Asked Question is worded similar to your question, folks will assume
        that you did not look at all. Don't become indignant at pointers to
        the FAQ, particularly if it solves your problem.

    Asking a question easily answered by a cursory doc search
        If folks think you have not even tried the obvious step of reading
        the docs applicable to your problem, they are likely to become
        annoyed.

        If you are flamed for not checking when you *did* check, then just
        shrug it off (and take the answer that you got).

    Asking for emailed answers
        Emailed answers benefit one person. Posted answers benefit the
        entire community. If folks can take the time to answer your
        question, then you can take the time to go get the answer in the
        same place where you asked the question.

        It is OK to ask for a *copy* of the answer to be emailed, but many
        will ignore such requests anyway. If you munge your address, you
        should never expect (or ask) to get email in response to a Usenet
        post.

        Ask the question here, get the answer here (maybe).

    Beware of saying "doesn't work"
        This is a "red flag" phrase. If you find yourself writing that,
        pause and see if you can't describe what is not working without
        saying "doesn't work". That is, describe how it is not what you
        want.

    Sending a "stealth" Cc copy
        A "stealth Cc" is when you both email and post a reply without
        indicating *in the body* that you are doing so.

  Be extra cautious when you get upset
    Count to ten before composing a followup when you are upset
        This is recommended in all Usenet newsgroups. Here in clpmisc, most
        flaming sub-threads are not about any feature of Perl at all! They
        are most often for what was seen as a breach of netiquette. If you
        have lurked for a bit, then you will know what is expected and won't
        make such posts in the first place.

        But if you get upset, wait a while before writing your followup. I
        recommend waiting at least 30 minutes.

    Count to ten after composing and before posting when you are upset
        After you have written your followup, wait *another* 30 minutes
        before committing yourself by posting it. You cannot take it back
        once it has been said.

AUTHOR
    Tad McClellan <tadmc@augustmail.com> and many others on the
    comp.lang.perl.misc newsgroup.



------------------------------

Date: Tue, 27 Jun 2006 17:25:32 +0800
From: SaltyBall <SaltyBall@Hell.com>
Subject: Smart method to reformat date 
Message-Id: <44a0f942$1@127.0.0.1>

Hi,

text file reformat
from
2006-12-25,xxx,yyy...
to
25/12/2006,xxx,yyy...

I think I can use "split" to kick it to an array line by line and 
restructure it but I think it should be some smart method to do that.

Can I do it with =~ and regular expression or any other smart method?

Thanks very much!


------------------------------

Date: Tue, 27 Jun 2006 10:32:08 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Smart method to reformat date
Message-Id: <e7qtuo$2c0$1@news.ox.ac.uk>

SaltyBall wrote:
> Hi,
> 
> text file reformat
> from
> 2006-12-25,xxx,yyy...
> to
> 25/12/2006,xxx,yyy...
> 
> I think I can use "split" to kick it to an array line by line and 
> restructure it but I think it should be some smart method to do that.

There are modules available on CPAN that do all sorts of date and time 
formatting an processing. See for example Date::Manip.


> Can I do it with =~ and regular expression or any other smart method?

If you *always* get your strings in the format above, you can do:

----

#!/usr/bin/perl
use strict;
use warnings;

while (<DATA>) {
	s|^([0-9]{4})-([0-9]{2})-([0-9]{2})|$1/$2/$3|;
	print;
}


__DATA__
2006-12-25,xxx,yyy...
2005-09-01,xaaxx,bbb..
1969-04-01 April Fool!

----

Output:

2006/12/25,xxx,yyy...
2005/09/01,xaaxx,bbb..
1969/04/01 April Fool!


Regards,

DS


------------------------------

Date: Tue, 27 Jun 2006 19:13:39 +0800
From: SaltyBall <SaltyBall@Hell.com>
Subject: Re: Smart method to reformat date
Message-Id: <44a11299$1@127.0.0.1>

Thanks very much!

It works, the usage of s|| and {} is new to me
(I am a newbie and only have a copy of "Learning perl" at hand)

can you recommend some good web site so that we can get more info?

Thanks again



David Squire wrote:
> SaltyBall wrote:
>> Hi,
>>
>> text file reformat
>> from
>> 2006-12-25,xxx,yyy...
>> to
>> 25/12/2006,xxx,yyy...
>>
>> I think I can use "split" to kick it to an array line by line and 
>> restructure it but I think it should be some smart method to do that.
> 
> There are modules available on CPAN that do all sorts of date and time 
> formatting an processing. See for example Date::Manip.
> 
> 
>> Can I do it with =~ and regular expression or any other smart method?
> 
> If you *always* get your strings in the format above, you can do:
> 
> ----
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> while (<DATA>) {
>     s|^([0-9]{4})-([0-9]{2})-([0-9]{2})|$1/$2/$3|;
>     print;
> }
> 
> 
> __DATA__
> 2006-12-25,xxx,yyy...
> 2005-09-01,xaaxx,bbb..
> 1969-04-01 April Fool!
> 
> ----
> 
> Output:
> 
> 2006/12/25,xxx,yyy...
> 2005/09/01,xaaxx,bbb..
> 1969/04/01 April Fool!
> 
> 
> Regards,
> 
> DS


------------------------------

Date: Tue, 27 Jun 2006 12:30:45 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Smart method to reformat date
Message-Id: <e7r4t6$4pq$1@news.ox.ac.uk>

SaltyBall wrote:

[please don't top-post. top-posting corrected]


> David Squire wrote:
>> SaltyBall wrote:
>>> Hi,
>>>
>>> text file reformat
>>> from
>>> 2006-12-25,xxx,yyy...
>>> to
>>> 25/12/2006,xxx,yyy...

[snip]

>>> Can I do it with =~ and regular expression or any other smart method?
>>
>> If you *always* get your strings in the format above, you can do:
>>
>> ----
>>
>> #!/usr/bin/perl
>> use strict;
>> use warnings;
>>
>> while (<DATA>) {
>>     s|^([0-9]{4})-([0-9]{2})-([0-9]{2})|$1/$2/$3|;
>>     print;
>> }
>>
>>
>> __DATA__
>> 2006-12-25,xxx,yyy...
>> 2005-09-01,xaaxx,bbb..
>> 1969-04-01 April Fool!


 > Thanks very much!
 >
 > It works, the usage of s||

The '|'s are just delimiters. You can choose your own delimiters when 
using s and m. I chose '|' because I wanted to use '/' in the 
replacement pattern (you will see that '/'s are the most commonly used 
delimiters in examples).

 > and {} is new to me
 > (I am a newbie and only have a copy of "Learning perl" at hand)
 >
 > can you recommend some good web site so that we can get more info?

Perl come with its own documentation. It is accessible by typing 
'perldoc <manual_entry>' on the command line, where '<manual_entry>' is 
the bit you want to read. I strongly suggest that you read:

perldoc perlretut
perldoc perlre

Note that this documentation is also available on-line at 
http://www.perl.com/pub/q/documentation, which is perhaps easier as you 
don't need to know the names of the manual sections in advance.


DS




------------------------------

Date: 27 Jun 2006 00:45:55 -0700
From: "Srinath" <raosrinat@gmail.com>
Subject: Re: syntax for print form layout <<tabluar>>
Message-Id: <1151394355.684191.160500@y41g2000cwy.googlegroups.com>

Please ignore this..

i found the syntax. for the same.

Srinath wrote:
> Hi..
>
> I am facing syntax error with "print form :layout<<tabluar>>"
>
> Please someone from the group provide me a proper syntax for the same
>
>
> Following code flags syntax error for the same.
> syntax error at <filename>line 685, near "form:"
> syntax error at <filename> line 691, near "form:"
>
> demo()
> {
>
> print form :layout<<tabular>>
>          "File name       Missing ostags  ",
>          "____________    ____________",
>          "{[[[[[[[[[[}    {[[[[[[[[[[}",
>           @strfilenameMissing,          @TagsMissing;
>
> print form :layout<<tabular>>
>          "File name       Additional ostags  ",
>          "____________    ____________",
>          "{[[[[[[[[[[}    {[[[[[[[[[[}",
>           @strFileNameAdditional,          @strAdditionalFiles;
> 
> 
> 
> }



------------------------------

Date: Tue, 27 Jun 2006 08:55:32 +0200
From: Dirk Thierbach <dthierbach@usenet.arcornews.de>
Subject: Re: Termination and type systems
Message-Id: <20060627065532.5BA.0.NOFFLE@dthierbach.news.arcor.de>

David Hopwood <david.nospam.hopwood@blueyonder.co.uk> wrote:
> Dirk Thierbach wrote:

> That's interesting, but linear typing imposes some quite severe
> restrictions on programming style. From the example of 'h' on page 2,
> it's clear that the reason for the linearity restriction is just to
> ensure polynomial-time termination, and is not needed if we only want
> to prove termination.

Yes. It's just an example of what can be actually done with a typesystem.

>> It's already hard enough to guarantee termination with the extra
>> information present in the type annotation. If this information is
>> not present, then the language has to be probably restricted so
>> severely to ensure termination that it is more or less useless.

> I think you're overestimating the difficulty of the problem. The fact
> that *in general* it can be arbitrarily hard to prove termination, can
> obscure the fact that for large parts of a typical program, proving
> termination is usually trivial.

Yes. The problem is the small parts where it's not trivial (and the
size of this part depends on the actual problem the program is trying
to solve). Either you make the language so restrictive that these
parts are hard (see your remark above) or impossible to write, or
you'll be left with a language where the compiler cannot prove
termination of those small parts, so it's not a "type system" in the
usual sense.

Of course one could write an optional tool that automatically proves
termination of the easy parts, and leaves the rest to the programmer,
but again, that's a different thing.

- Dirk


------------------------------

Date: Tue, 27 Jun 2006 09:30:40 +0200
From: Ketil Malde <ketil+news@ii.uib.no>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <eg7j33xdgf.fsf@polarvier.ii.uib.no>

"Marshall" <marshall.spight@gmail.com> writes:

> There are also what I call "packaging" issues, such as
> being able to run partly-wrong programs on purpose so
> that one would have the opportunity to do runtime analysis
> without having to, say, implement parts of some interface
> that one isn't interested in testing yet. These could also
> be solved in a statically typed language. (Although
> historically it hasn't been done that way.)

I keep hearing this, but I guess I fail to understand it.  How
"partly-wrong" do you require the program to be?

During development, I frequently sprinkle my (Haskell) program with
'undefined' and 'error "implement later"' - which then lets me run the
implemented parts until execution hits one of the 'undefined's.

The "cost" of static typing for running an incomplete program is thus
simply that I have to name entities I refer to.  I'd argue that this
is good practice anyway, since it's easy to see what remains to be
done. (Python doesn't seem to, but presumably a serious dynamically
typed system would warn about references to entities not in scope?) 

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


------------------------------

Date: Tue, 27 Jun 2006 11:46:27 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <e7r5vs.19g.1@news.isolution.nl>

Chris Smith schreef:

> So it seems to me that we have this ideal point at which it is
> possible to write all correct or interesting programs, and impossible
> to write buggy programs.

I think that is a misconception. Even at the idealest point it will be
possible (and easy) to write buggy programs. Gödel!

-- 
Affijn, Ruud

"Gewoon is een tijger."




------------------------------

Date: 27 Jun 2006 04:21:39 -0700
From: "Michael Wulff" <mwulfff@yahoo.de>
Subject: XML::Smart: Removing node
Message-Id: <1151407299.562004.269280@y41g2000cwy.googlegroups.com>

Hello,

How do I easily remove a node or a branch from an XML structure using
XML::Smart?

Using the example from the documentation
(http://search.cpan.org/~gmpassos/XML-Smart/lib/XML/Smart.pm) I used
the following approach to remove the RedHat server, but is there no
easier way to do it? And unfortunately it did not work with a more
complicated XML structure.

my @servers;
for my $server (@{$XML->{server}}) {
    next if $server->{type} eq 'RedHat';
    push @servers, $server;
}

@{$XML->{server}} = @servers;

Regards,
Michael



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9390
***************************************


home help back first fref pref prev next nref lref last post