[24181] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6373 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 7 18:05:49 2004

Date: Wed, 7 Apr 2004 15:05:10 -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           Wed, 7 Apr 2004     Volume: 10 Number: 6373

Today's topics:
    Re: [VERY OT] a linguistic question (.sig-related, xpos <remorse@partners.org>
    Re: [VERY OT] a linguistic question (.sig-related, xpos <bmoses-nospam@cits1.stanford.edu>
    Re: [VERY OT] a linguistic question (.sig-related, xpos <dak@gnu.org>
    Re: [VERY OT] a linguistic question (.sig-related, xpos <remorse@partners.org>
    Re: [VERY OT] a linguistic question (.sig-related, xpos <remorse@partners.org>
    Re: [VERY OT] a linguistic question (.sig-related, xpos <chappa@math.washington.edu>
    Re: [VERY OT] a linguistic question (.sig-related, xpos <chappa@math.washington.edu>
    Re: [VERY OT] a linguistic question (.sig-related, xpos <bilotta78@hotpop.com>
    Re: display Excel file in browser? <remorse@partners.org>
    Re: display Excel file in browser? <jwillmore@remove.adelphia.net>
    Re: Getting the "Last modified" folder value to change  <remorse@partners.org>
    Re: Open GUI transcript window <bxb7668@somewhere.nocom>
    Re: Open GUI transcript window <bxb7668@somewhere.nocom>
    Re: parsing OPML <remorse@partners.org>
    Re: Perl and Internet Explorer <remorse@partners.org>
        Perl neq Python <graffitiNOSPAM@NOSPAMyahoo.com>
    Re: Regular expression question <matternc@comcast.net>
    Re: Regular expression question <remorse@partners.org>
    Re: Regular expression question <tadmc@augustmail.com>
    Re: scope again <remorse@partners.org>
    Re: scope again <xx087@freenet.carleton.ca>
    Re: scope again <vetro@online.no>
    Re: Search and replace a string in files <remorse@partners.org>
    Re: subroutine only returns non zero sums <remorse@partners.org>
    Re: subroutine only returns non zero sums <tadmc@augustmail.com>
        Why does split operate over multiple lines in the absen (Sara)
    Re: Why does split operate over multiple lines in the a <tassilo.parseval@rwth-aachen.de>
    Re: Why does split operate over multiple lines in the a <remorse@partners.org>
    Re: Why does split operate over multiple lines in the a <ittyspam@yahoo.com>
        Win32::OLE / WMEncoderAgent issue (Simon Lockhart)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 07 Apr 2004 15:58:30 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <remorse-19BEE7.15583007042004@plato.harvard.edu>

In article <90o770tpk731n8dev5rg1ihto441dlsbuv@4ax.com>,
 Michele Dondi <bik.mido@tiscalinet.it> wrote:

> I like to gather witty cmts or otherwise interesting sentences from
> USENET posts to quote in .sigs: now I have a doubt about the
> preposition to use when citing the author, i.e. should I use
> 
>   > utterly stupid claim
>   witty cmt
>   - J. Random Hacker in comp.foo.bar, "Re: Fred Mbogo"
>                      ^^
> 
> or
> 
>   > utterly stupid claim
>   witty cmt
>   - J. Random Hacker on comp.foo.bar, "Re: Fred Mbogo"
>                      ^^

IMO, FWIW, 'in'.

In all of the conversations that I've seen, most people use 'in' to 
refer to newsgroups, 'on' to refer to IRC channels.

Of course, I'm just a random guy.  I have no claim to any expertise on 
this topic (or would that be 'in this topic' :-).

HTH,
Ricky

-- 
Pukku


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

Date: Wed, 07 Apr 2004 12:49:05 -0700
From: Brooks Moses <bmoses-nospam@cits1.stanford.edu>
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <40745B31.28785AE@cits1.stanford.edu>

Michele Dondi wrote:
> I like to gather witty cmts or otherwise interesting sentences from
> USENET posts to quote in .sigs: now I have a doubt about the
> preposition to use when citing the author, i.e. should I use
> 
>   > utterly stupid claim
>   witty cmt
>   - J. Random Hacker in comp.foo.bar, "Re: Fred Mbogo"
>                      ^^
[...]

My experience has been that the traditional preposition for this purpose
is "in", not "on".

- Brooks


-- 
The "bmoses-nospam" address is valid; no unmunging needed.


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

Date: 07 Apr 2004 22:19:03 +0200
From: David Kastrup <dak@gnu.org>
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <x5ptajzglk.fsf@lola.goethe.zz>

Richard Morse <remorse@partners.org> writes:

> In article <90o770tpk731n8dev5rg1ihto441dlsbuv@4ax.com>,
>  Michele Dondi <bik.mido@tiscalinet.it> wrote:
> 
> > I like to gather witty cmts or otherwise interesting sentences from
> > USENET posts to quote in .sigs: now I have a doubt about the
> > preposition to use when citing the author, i.e. should I use
> > 
> >   > utterly stupid claim
> >   witty cmt
> >   - J. Random Hacker in comp.foo.bar, "Re: Fred Mbogo"
> >                      ^^
> > 
> > or
> > 
> >   > utterly stupid claim
> >   witty cmt
> >   - J. Random Hacker on comp.foo.bar, "Re: Fred Mbogo"
> >                      ^^
> 
> IMO, FWIW, 'in'.
> 
> In all of the conversations that I've seen, most people use 'in' to 
> refer to newsgroups, 'on' to refer to IRC channels.

I'd say the latter is wrong.

J. Random Hacker on anything, "..."

means that J. Random Hacker has a comment concerning `anything', and
the comment is "...".

Like David Kastrup on commenting: "Don't use on here".

David Kastrup on comp.text.tex: "Some nice people hanging out there.
Well, and myself."

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
UKTUG FAQ: <URL:http://www.tex.ac.uk/cgi-bin/texfaq2html>


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

Date: Wed, 07 Apr 2004 16:24:36 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <remorse-67C230.16243607042004@plato.harvard.edu>

In article <p1Wcc.19356$Mt1.12411@newssvr27.news.prodigy.com>,
 Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com> wrote:

> Michele Dondi wrote:
> 
> >   > utterly stupid claim
> >   witty cmt
> >   - J. Random Hacker in comp.foo.bar, "Re: Fred Mbogo"
> >                      ^^
> > 
> > or
> > 
> >   > utterly stupid claim
> >   witty cmt
> >   - J. Random Hacker on comp.foo.bar, "Re: Fred Mbogo"
> >                      ^^
> 
> I might be wrong, but I would think people write *in* posts *on* newsgroups.
> 
> But, why do you care? Most newsreaders strip out .sigs anyway :)

They do?  Mine does for replies, but still shows them while reading...

But then, I may be in a minority?

Ricky

-- 
Pukku


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

Date: Wed, 07 Apr 2004 16:27:26 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <remorse-8E3C75.16272607042004@plato.harvard.edu>

In article <x5ptajzglk.fsf@lola.goethe.zz>, David Kastrup <dak@gnu.org> 
wrote:

> Richard Morse <remorse@partners.org> writes:
> 
> > In all of the conversations that I've seen, most people use 'in' to 
> > refer to newsgroups, 'on' to refer to IRC channels.
> 
> I'd say the latter is wrong.
> 
> J. Random Hacker on anything, "..."
> 
> means that J. Random Hacker has a comment concerning `anything', and
> the comment is "...".

I agree with you if the word 'on' is followed by a topic or subject, 
however I've often seen:

   silly_user_name on #mychannel said "foo".

or even:

   silly_user_name on #mychannel: "foo"

Ricky

-- 
Pukku


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

Date: Wed, 7 Apr 2004 13:15:09 -0700
From: Eduardo Chappa <chappa@math.washington.edu>
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <Pine.LNX.4.59.999.0404071314390.3469@zeno2.math.washington.edu>

*** Brooks Moses (nspmbmoses-nospam@cits1.stanford.edu.nsp) wrote in...:

:) Michele Dondi wrote:
:) > I like to gather witty cmts or otherwise interesting sentences from 
:) > USENET posts to quote in .sigs: now I have a doubt about the 
:) > preposition to use when citing the author, i.e. should I use
:) > 
:) >   > utterly stupid claim
:) >   witty cmt
:) >   - J. Random Hacker in comp.foo.bar, "Re: Fred Mbogo"
:) >                      ^^
:) 
:) My experience has been that the traditional preposition for this 
:) purpose is "in", not "on".

I agree, I think that the problem is that this sentence does not have a 
verb. If you insert one, like in "Hacker wrote in comp.foo.bar", it's 
clear to me that "in" is appropriate, but "on" is not, since "on" would 
indicate the subject, which is unlikely to be "comp.foo.bar".

Eduardo
http://www.math.washington.edu/~chappa/pine/


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

Date: Wed, 7 Apr 2004 13:14:22 -0700
From: Eduardo Chappa <chappa@math.washington.edu>
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <Pine.LNX.4.59.999.0404071311580.3469@zeno2.math.washington.edu>

*** Brooks Moses (nspmbmoses-nospam@cits1.stanford.edu.nsp) wrote in...:

:) Michele Dondi wrote:
:) > I like to gather witty cmts or otherwise interesting sentences from 
:) > USENET posts to quote in .sigs: now I have a doubt about the 
:) > preposition to use when citing the author, i.e. should I use
:) > 
:) >   > utterly stupid claim
:) >   witty cmt
:) >   - J. Random Hacker in comp.foo.bar, "Re: Fred Mbogo"
:) >                      ^^
:) 
:) My experience has been that the traditional preposition for this 
:) purpose is "in", not "on".

I agree, I think that the problem is that this sentence does not have a 
verb. If you insert one, like in "Hacker wrote in comp.foo.bar", it's 
clear to me that "in" is appropriate, but "on" is not, since "on" would 
indicate the subject, which is unlikely to be "comp.foo.bar".

Eduardo
http://www.math.washington.edu/~chappa/pine/


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

Date: 7 Apr 2004 21:56:21 GMT
From: Giuseppe Bilotta <bilotta78@hotpop.com>
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <MPG.1ade97679b992d2c98e243@news.individual.net>

Michele Dondi wrote:
> I'm sorry for this OT, but these seemed to me the best NGs, amongst
> those that I subscribe, to ask this question, and I don't know where
> else I could do it.
> 
> I like to gather witty cmts or otherwise interesting sentences from
> USENET posts to quote in .sigs: now I have a doubt about the
> preposition to use when citing the author, i.e. should I use
> 
>   > utterly stupid claim
>   witty cmt
>   - J. Random Hacker in comp.foo.bar, "Re: Fred Mbogo"
>                      ^^
> 
> or
> 
>   > utterly stupid claim
>   witty cmt
>   - J. Random Hacker on comp.foo.bar, "Re: Fred Mbogo"
>                      ^^

I'm not a native speaker, but I would go for "in"; "on" sounds a 
little like Mr. Hacker was talking *about* comp.foo.bar, rather tha 
posting *to* the newsgroup.

-- 
Giuseppe "Oblomov" Bilotta

Can't you see
It all makes perfect sense
Expressed in dollar and cents
Pounds shillings and pence
                  (Roger Waters)


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

Date: Wed, 07 Apr 2004 16:11:16 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: display Excel file in browser?
Message-Id: <remorse-C31DE3.16111607042004@plato.harvard.edu>

In article <c516nl$9tn$1@news.iastate.edu>, Bing Du <bdu@iastate.edu> 
wrote:

> Greetings,
> 
> I've used Spreadsheet::WriteExcel to generate a spreadsheet.  Now I need 
>   this spreadsheet to be viewable in web browsers.  I can _not_ put any 
> files under the web server document root directory due to the privilege 
> restrictions.  So this has failed my idea of creating a link on the web 
> page and making the link point to the spreadsheet.
> 
> The best place for me to store the sheet is in the /tmp directory.  If I 
> use the following code to load my.xls into $bindata, how can I display 
> $bindata in its original spreadsheet format on the web?
> 
> ======
> $spreadsheet = "/tmp/my.xls";
> open(F,$spreadsheet);
> read(F,$bindata,-s F);
> close(F);
> ======
> 
> I've checked Spreadsheet::ParseExcel.  But it's not what I want because 
>   I don't want to extract information from my.xls.
> 
> Appreciate any ideas in advance.

This has very little to do with Perl.

However.

In order to make anything available over the web, you need to somehow 
get it into the web server's namespace.  You have two options:

1) change permissions (perhaps on a subdirectory?) so that your script 
can save data into a directory that your web server can serve from

2) write a cgi, which accepts some kind of key for which file to serve, 
and have it open the file and reprint it to the web browser.

Please note that 2 will cause all kinds of security issues, unless you 
are _very_ careful in how you create it.

If you are using Spreadsheet::WriteExcel to create the excel spreadsheet 
based on a web query, and you want to return the spreadsheet to a 
browser right after creating it, you might try creating the spreadsheet 
as a temp file (use File::Temp), then seek-ing to the start of the file, 
then printing (with binmode) the file back to the browser.

HTH,
Ricky

-- 
Pukku


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

Date: Wed, 07 Apr 2004 17:37:51 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: display Excel file in browser?
Message-Id: <pan.2004.04.07.21.37.47.186605@remove.adelphia.net>

On Wed, 07 Apr 2004 16:11:16 -0400, Richard Morse wrote:

[ ... ]

> 1) change permissions (perhaps on a subdirectory?) so that your script 
> can save data into a directory that your web server can serve from
> 
> 2) write a cgi, which accepts some kind of key for which file to serve, 
> and have it open the file and reprint it to the web browser.
> 
> Please note that 2 will cause all kinds of security issues, unless you 
> are _very_ careful in how you create it.
> 
> If you are using Spreadsheet::WriteExcel to create the excel spreadsheet 
> based on a web query, and you want to return the spreadsheet to a 
> browser right after creating it, you might try creating the spreadsheet 
> as a temp file (use File::Temp), then seek-ing to the start of the file, 
> then printing (with binmode) the file back to the browser.

The most important part of writing a CGI script to deliver an Excel file
to the browser is the Content-type header.

Information on this *should* be available by using Google :-)

HTH

Jim


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

Date: Wed, 07 Apr 2004 15:27:27 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: Getting the "Last modified" folder value to change further up the hierarchy.
Message-Id: <remorse-01E5F0.15272707042004@plato.harvard.edu>

In article <80069cc2bd36a7ca547386c90394d486@unlimited.ultrafeed.com>,
 <D.r Pickle> wrote:

> The code is running as root and symlinks are irrelivant becasue there will 
> not be any.
> 
> In reality I do not want to update "/"
> I want to update "/home/BLOP/" when somthing in 
> "/home/BLOP/main/subdir1/subdir2/" is modified.
> 
> Assuming I have the FULL path in $dirstring
> 
> I just dont know how to break the $dirstring down at each / so that I could 
> write a
> quick file touch for each of the dirs in the whole path.
> 
> This area is being used exclusivly to crunch large amounts of raw data.
> Currently the way the script is written, if I had a piece of code that could 
> touch
> each of the directories in the string I could easliy incorperate it so the 
> date
> update would only occur once every time the script changes dirs to dump its 
> data.

Although other posts have given you much better advice (such as touching 
a '/home/BLOP/.updated' file), if you really want to do this, you should 
look at File::Basename and File::Spec.

HTH,
Ricky

-- 
Pukku


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

Date: Wed, 7 Apr 2004 16:19:07 GMT
From: "bxb7668" <bxb7668@somewhere.nocom>
Subject: Re: Open GUI transcript window
Message-Id: <Hvt6nv.uq@news.boeing.com>

Thanks. I'll give it a try.
Brian

"zentara" <zentara@highstream.net> wrote in message
news:deu7709b6lo7upfluqgfr1kiibgntbccr6@4ax.com...
> On Tue, 6 Apr 2004 19:01:50 GMT, "bxb7668" <bxb7668@somewhere.nocom>
> wrote:
>
> >I have been given a requirement for a perl script that runs on both
> >Windows and UNIX (AIX) from both the command line (UNIX) and the
> >Windows Start menu. It can take a long time to run, so they also
want
> >it to write intermediate status messages. For the command line I
just
> >write to STDOUT. No problem. But in the Windows GUI environment
they
> >want a text window to open and the status message dynamically
written
> >to it and show up as they are written, not when the entire process
is
> >complete.  Can this be done, and if so, how?  We're using Perl
5.6.1.
> >Brian
> >
>
> Try this preferred method with fileevent. But sometimes you need to
> use Tk::after widget to read the output, if the sender program is
> having pipe buffering problems. Fileevent is a built-in IO::Select
> fot Tk. Read it's perldoc. Filevent will hang sometimes with
pipe-buffer
> problems.
> ########################################################
> #!/usr/bin/perl
> use warnings;
> use strict;
> use Tk;
>
> open(CHILD, "./fileevent2piper 2>&1 |") or die "Can't open: $!";
>
> my $mw = new MainWindow;
>
> my $t = $mw->Scrolled("Text",-width => 80, -height => 25, -wrap =>
> 'none');
>                                              $t->pack(-expand => 1);
>
> $mw->fileevent(\*CHILD, 'readable', [\&fill_text_widget,$t]);
> MainLoop;
>
> sub fill_text_widget {
>           my($widget) = @_;
>           $_ = <CHILD>;
>   $widget->insert('end', $_);
>           $widget->yview('end');
> }
> __END__
> ###########################################################
>
> ##HERE IS THE SENDER PROGRAM
> ##fileevent2piper
>
> #!/usr/bin/perl
>
> $|++;
>
> for my $i ( 0 .. 10) {
>         print $i, "\n";
>         sleep 1;
>     }
>
> print "sleeping 5\n";
> sleep 5;
>
> for my $i ( 0 .. 10) {
>         print $i, "\n";
>         sleep 1;
>     }
>
> __END__
> ########################################################
>
>
>
> -- 
> I'm not really a human, but I play one on earth.
> http://zentara.net/japh.html




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

Date: Wed, 7 Apr 2004 17:27:42 GMT
From: "bxb7668" <bxb7668@somewhere.nocom>
Subject: Re: Open GUI transcript window
Message-Id: <Hvt9u5.4oq@news.boeing.com>

Zentara,
Thank you. This does almost everything that I need. Just one more
thing. How do I close the new window when I'm done with it?
Brian

"zentara" <zentara@highstream.net> wrote in message
news:deu7709b6lo7upfluqgfr1kiibgntbccr6@4ax.com...
> On Tue, 6 Apr 2004 19:01:50 GMT, "bxb7668" <bxb7668@somewhere.nocom>
> wrote:
>
> >I have been given a requirement for a perl script that runs on both
> >Windows and UNIX (AIX) from both the command line (UNIX) and the
> >Windows Start menu. It can take a long time to run, so they also
want
> >it to write intermediate status messages. For the command line I
just
> >write to STDOUT. No problem. But in the Windows GUI environment
they
> >want a text window to open and the status message dynamically
written
> >to it and show up as they are written, not when the entire process
is
> >complete.  Can this be done, and if so, how?  We're using Perl
5.6.1.
> >Brian
> >
>
> Try this preferred method with fileevent. But sometimes you need to
> use Tk::after widget to read the output, if the sender program is
> having pipe buffering problems. Fileevent is a built-in IO::Select
> fot Tk. Read it's perldoc. Filevent will hang sometimes with
pipe-buffer
> problems.
> ########################################################
> #!/usr/bin/perl
> use warnings;
> use strict;
> use Tk;
>
> open(CHILD, "./fileevent2piper 2>&1 |") or die "Can't open: $!";
>
> my $mw = new MainWindow;
>
> my $t = $mw->Scrolled("Text",-width => 80, -height => 25, -wrap =>
> 'none');
>                                              $t->pack(-expand => 1);
>
> $mw->fileevent(\*CHILD, 'readable', [\&fill_text_widget,$t]);
> MainLoop;
>
> sub fill_text_widget {
>           my($widget) = @_;
>           $_ = <CHILD>;
>   $widget->insert('end', $_);
>           $widget->yview('end');
> }
> __END__
> ###########################################################
>
> ##HERE IS THE SENDER PROGRAM
> ##fileevent2piper
>
> #!/usr/bin/perl
>
> $|++;
>
> for my $i ( 0 .. 10) {
>         print $i, "\n";
>         sleep 1;
>     }
>
> print "sleeping 5\n";
> sleep 5;
>
> for my $i ( 0 .. 10) {
>         print $i, "\n";
>         sleep 1;
>     }
>
> __END__
> ########################################################
>
>
>
> -- 
> I'm not really a human, but I play one on earth.
> http://zentara.net/japh.html




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

Date: Wed, 07 Apr 2004 15:33:22 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: parsing OPML
Message-Id: <remorse-30E5C9.15332207042004@plato.harvard.edu>

In article <b62b39cb.0404051614.696a3d7f@posting.google.com>,
 chrisl_ak@hotmail.com (Chris) wrote:

> I am trying to write a script that will parse my Bloglines OPML export
> (see snippet below) and output an HTML blogroll.
[snip]
> from xml.sax import make_parser
> from xml.sax.handler import ContentHandler
> 
> class OPMLHandler(ContentHandler):
> 
>     def startElement(self, name, attrs):
>         if name == 'outline':
>             self.title = attrs.get('title', '')
>             self.url = attrs.get('xmlUrl', '')
>            
>     def endElement(self, name):
>         if name == 'outline':
>             print self.level, ':', self.title, '-', self.url
> 
> parser = make_parser()
> curHandler = OPMLHandler()
> parser.setContentHandler(curHandler)
> parser.parse(open('blogs.opml'))

It looks to me like this is Python.

This is a Perl newsgroup.

Perhaps you meant to post to a Python newsgroup?

Ricky

-- 
Pukku


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

Date: Wed, 07 Apr 2004 14:26:09 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: Perl and Internet Explorer
Message-Id: <remorse-D191C2.14260907042004@plato.harvard.edu>

In article <1xFcc.4987$BF2.609573@news20.bellglobal.com>,
 "Matt Garrish" <matthew.garrish@sympatico.ca> wrote:

> "akaliel" <akaliel@streamflo.com> wrote in message
> news:7123bc57.0404061154.595341a@posting.google.com...
> > > Not sure if it will make any difference to IE, but might be worth a try.
> And
> > > if it does work but blows up Netscape you could always detect the
> browser
> > > type and send the appropriate header.
> > >
> > > Matt
> >
> > That's the MIME type I'm using that managed to get it to partially
> > work.  Right clicking on the link will allow me to save it as a .ppt
> > by default.  However, left clicking on the link does nothing
> > whatsoever.  If I right click and say "Open in New Window" then just
> > after the new window launches, it crashes.
> 
> I assume you've already tried the following http header to specify a default
> filename?
> 
> Content-Disposition: attachment; filename=[FILENAME]

You might try Content-Disposition: inline; filename=... instead -- this 
may make the streaming work...

Ricky

-- 
Pukku


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

Date: Wed, 07 Apr 2004 18:11:10 GMT
From: Berk Birand <graffitiNOSPAM@NOSPAMyahoo.com>
Subject: Perl neq Python
Message-Id: <695078a3f4b1f1b2bc78225127ac5d23@news.teranews.com>

Hi,

I have learned coding in Perl couple of weeks ago, and have recently added
Python to my repertoire. I know that there are loads of web pages
comparing the two languages, and that you are probably sick of guys asking
which one to learn. However my question is slightly different.

You see I have the time and the energy to do my best in both languages (at
least until I begin college this august). That's precisely why I have
decided to learn everything I could. The question that I have been asking
myself is the following:

Under what circumstances should I use Perl, Python or straight shell
scripting?

I believe I have made my point clear that I am not asking for a
comparison, but some guidelines as to which one to use for a specific task.

So far I have figured that Perl is a better tool for applications using
regular expressions, and Python more appropriate for bigger projects
(because of its object-oriented programming model and its "readability")

What do you think?

Thanks
BB


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

Date: Wed, 07 Apr 2004 14:15:31 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Regular expression question
Message-Id: <O5qdnVRxdqze2OndRVn-vw@comcast.com>

Kapil Khosla wrote:

> Allright,
> I just read your post. This came in after I replied so my apologies.
> What do you mean by "Dont top post".
> I am sure this would be somewhere in the documentation but I have been
> going through
> http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html#must
> 
> but could not find what it means.
> Thanks,
> Kapil
> 
Then you must not have looked too hard.  Cut and pasted directly
from the website:

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).

Familiarizing yourself with your browser's "Find" function might help;
I got this very quickly simply by searching for "top".
-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: Wed, 07 Apr 2004 16:32:29 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: Regular expression question
Message-Id: <remorse-9A98E3.16322907042004@plato.harvard.edu>

In article <919aa2da.0404070850.305acf7a@posting.google.com>,
 khoslakapil@yahoo.com (Kapil Khosla) wrote:

> I figured this out based on your previous post.
> I have attached the code below.
> Thanks.
>  
>   open I, "E:\\mycode\\perl\\brace.txt" or die"Could not open file";
>     local $/ = undef; 
>     
>     $line = <I>;
> 
>     $line =~ s/\s*int main\(.*\)\s*\{\s*return\s*main\(.*\)\s*\;\s*\}//g;   
>     print $line;
> 
> 	close I;

If I may, might I suggest the following would be "better" (for some 
value of better):

#!perl
use strict;
use warnings;


my $data;
{
   # if you're going to lexicalize global variables, always do
   # so in a code block.  Or save and restore their original
   # values
   open(my $in, "<", 'e:/mycode/perl/brace.txt')
      or die("could not open file: $!");
   local $/ = undef;
   $data = <$in>;
   close($in);
}

$data =~ s/\s*int main\(.*?\)\s*{\s*return\s*main\(.*?\)\s*;\s*}//g;
print $data;

__END__

HTH,
Ricky

-- 
Pukku


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

Date: Wed, 7 Apr 2004 17:09:44 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regular expression question
Message-Id: <slrnc78v18.6ll.tadmc@magna.augustmail.com>

Richard Morse <remorse@partners.org> wrote:
> In article <919aa2da.0404070850.305acf7a@posting.google.com>,
>  khoslakapil@yahoo.com (Kapil Khosla) wrote:


[snip - about multi-line matching ]


> my $data;
> {
>    # if you're going to lexicalize global variables, always do
                          ^^^^^^^^^^

Eh?

I guess you meant "if you're going to change a built-in
variable's value" instead?

I hope so, because you cannot make $/ be lexical, it is
always a package variable.

I also hope so because then the advice you gave is very good advice.  :-)


>    # so in a code block.  Or save and restore their original
>    # values
>    open(my $in, "<", 'e:/mycode/perl/brace.txt')
>       or die("could not open file: $!");
>    local $/ = undef;


$/ is NOT "lexical" here, it is still "dynamic"...


>    $data = <$in>;
>    close($in);
> }


If I'm going to make my own scope anyways, then I usually let
Perl handle all that file opening/closing stuff for me:

   {
      local $/;   # enable slurp mode
      local @ARGV = 'e:/mycode/perl/brace.txt';
      $data = <>;
   }


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 07 Apr 2004 14:41:24 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: scope again
Message-Id: <remorse-560EF1.14412407042004@plato.harvard.edu>

In article <406EE9A5.6010803@rochester.rr.com>,
 Bob Walton <invalid-email@rochester.rr.com> wrote:
> Bob Walton wrote:
> > Richard Morse wrote:
> >> Wait -- completely un-related to the question, what is this?  How do 
> >> you get an interactive Perl?
> > Windoze version:
> > 
> >    perl -e "print '% ',eval <STDIN>,print qq(\n) while 1"
> 
> Well, actually:
> 
>     perl -e "print('% '),eval <STDIN>,print qq(\n) while 1"
> 
> works better.

Cool!  Is there a better version for Mac OS X?

Thanks,
Ricky

-- 
Pukku


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

Date: 7 Apr 2004 20:11:58 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: scope again
Message-Id: <slrnc78o4f.r1m.xx087@smeagol.ncf.ca>

Richard Morse <remorse@partners.org> wrote:
>  In article <slrnc6je7l.ig8.xx087@smeagol.ncf.ca>,
>   Glenn Jackman <xx087@freenet.carleton.ca> wrote:
>  
> >     % require 'space.pl'
> > 
> >     % $s=Space->new('foo')
> >     Space=HASH(0x12bfd4)
> > 
> >     % use Data::Dumper
> > 
> >     % print Dumper($s)
> >     $VAR1 = bless( {
> >                     'char' => '@',
> >                     'tile' => 'foo'
> >                 }, 'Space' );
> > 
> >     % $s->fchsym
> >     tile is 'foo'
>  
>  Wait -- completely un-related to the question, what is this?  How do you 
>  get an interactive Perl?

This is my perlsh:

    #!/usr/local/bin/perl -w
    use strict;
    no strict 'vars';

    # because I constantly type 'quit' when I mean 'exit':
    sub quit { exit; }

    $, = ",";
    $_PS1_ = (split '/', $^X)[-1] . $] . '% ';
    print "$_PS1_";
    while (<>) { print eval; print ( ($@ || "\n") . "$_PS1_" ) };


-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


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

Date: Wed, 07 Apr 2004 23:17:56 +0200
From: Vetle Roeim <vetro@online.no>
Subject: Re: scope again
Message-Id: <m3zn9n32t7.fsf@quimby.dirtyhack.org>

* Glenn Jackman
[...]
> This is my perlsh:
>
>     #!/usr/local/bin/perl -w
>     use strict;
>     no strict 'vars';
>
>     # because I constantly type 'quit' when I mean 'exit':
>     sub quit { exit; }
>
>     $, = ",";
>     $_PS1_ = (split '/', $^X)[-1] . $] . '% ';
>     print "$_PS1_";
>     while (<>) { print eval; print ( ($@ || "\n") . "$_PS1_" ) };

  Neat trick. Thanks. :)


-- 
#!/usr/bin/vr


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

Date: Wed, 07 Apr 2004 14:57:54 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: Search and replace a string in files
Message-Id: <remorse-5833DD.14575407042004@plato.harvard.edu>

In article <919aa2da.0404041105.6c5afb7d@posting.google.com>,
 khoslakapil@yahoo.com (Kapil Khosla) wrote:

> [some one, I don't know who, wrote:]
> > That RegExp is far more complicated than it needs to be.  You're searching
> > for:  "Word boundary, followed by 'Main', then *optionally* followed by
> > parenthesized text, followed by end-of-line.   Why do you care about the
> > parentheses and end of line?  You said all you wanted to do was replace
> > "Main" with "main".  So the match could just be:
> > 
> > m/\bMain/
>  
> I am sorry, I should have been more clear the first time. I want the
> RegExp pattern to match
> #define Main main - MATCH
> int Main()  - MATCH
> int Main(String * str) - MATCH
> 
> but NOT
> Mainframe -- NO  MATCH
> MainMain -- NO  MATCH
> DllMain  -- NO MATCH
> 
> Do you now think that the RegExp is correct? How should I solve the
> issue now.

So, you want to replace every instance of the _word_ 'Main' with the 
word 'main'.

s/\bMain\b/main/g;

HTH,
Ricky

-- 
Pukku


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

Date: Wed, 07 Apr 2004 15:20:56 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: subroutine only returns non zero sums
Message-Id: <remorse-B85795.15205607042004@plato.harvard.edu>

In article <slrnc7348k.bvm.xx087@smeagol.ncf.ca>,
 Glenn Jackman <xx087@freenet.carleton.ca> wrote:

> Rocky <PerlGuRu2b@bobotheclown.org> wrote:
> >  hi all,
> >  this subroutine was written originally without the if/else statement for
> >  $total.  It returned any non-zero sum perfectly but whenever @number was
> >  all zeros it came back blank(undefined?)  What did I miss?  It works now
> 
> Initialize $total when you declare it:
>     sub addnums { 
>         my $total = 0; 
>         $total += $_ foreach @_;
>         return $total;
>     }

Would it be valid to make it even shorter by doing:

sub addnums {
   my $total += $_ foreach @_;
   return $total || 0;
}

?

I don't think that the return statement would be a problem, but I'm 
wondering if the "don't lexicalize variables with statement modifiers" 
rule applies here, or only with 'if'/'unless' statement modifiers?

Thanks,
Ricky

-- 
Pukku


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

Date: Wed, 7 Apr 2004 17:17:47 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: subroutine only returns non zero sums
Message-Id: <slrnc78vgb.6ll.tadmc@magna.augustmail.com>

Richard Morse <remorse@partners.org> wrote:


> Would it be valid to make it even shorter by doing:

>    my $total += $_ foreach @_;


If you are going for shorter, then you should 
use "for" instead of "foreach".


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 7 Apr 2004 12:49:39 -0700
From: genericax@hotmail.com (Sara)
Subject: Why does split operate over multiple lines in the absence of "ms" ? And why doesn't $_ work with split?
Message-Id: <776e0325.0404071149.5ae561be@posting.google.com>

To substitute over multiple lines, one would need something like

   s/CAT/DOG/msg;

But to SPLIT those same lines the "ms" is apparently "implied":

    my @all_matches = split /CAT/, $_;
    my @all_matches = split /CAT/ms, $_;

will both split the entire paragraph, not just line 1. Why? Why would
one assume that programmers would need to substitute only line 1, but
wold always need to split the whole paragraph. Doesn't make sense, and
appears to be inconsistent. The only rationale I see roughly alluded
to in Camel is that split is the "opposite of" join, so since join
obviously works over multiple array elements, to be a true inverse
then split would need to work over the entire scalar?

Also, along these same lines why isn't $_ taken as the default arg for
split, such that:

   split /CAT/, $_;

would be identical to 

   split /CAT/; # throws an error

?

This cat is curious.


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

Date: 7 Apr 2004 20:24:21 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Why does split operate over multiple lines in the absence of "ms" ? And why doesn't $_ work with split?
Message-Id: <c51o1l$il5$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Sara:

> To substitute over multiple lines, one would need something like
> 
>    s/CAT/DOG/msg;

No, one wouldn't. The only thing you need is /g, and that doesn't have
anything to do with strings spanning multiple lines. The /s modifier is
only meaningful when you have a '.' which otherwise doesn't match
newlines. /m changes the meaning of '^' and '$'.

> But to SPLIT those same lines the "ms" is apparently "implied":
> 
>     my @all_matches = split /CAT/, $_;
>     my @all_matches = split /CAT/ms, $_;

Same here. These two lines do the same thing because

    /CAT/
    /CAT/ms

are equivalent.

> will both split the entire paragraph, not just line 1. Why? Why would
> one assume that programmers would need to substitute only line 1, but
> wold always need to split the whole paragraph. 

Note that split() has an additional third argument. If you want to split
only once, then pass 2 as third argument.

So the only thing that split() implies is /g and that I find rather
plausible.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Wed, 07 Apr 2004 16:39:24 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: Why does split operate over multiple lines in the absence of "ms" ? And why doesn't $_ work with split?
Message-Id: <remorse-5A7075.16392407042004@plato.harvard.edu>

In article <776e0325.0404071149.5ae561be@posting.google.com>,
 genericax@hotmail.com (Sara) wrote:

> Also, along these same lines why isn't $_ taken as the default arg for
> split, such that:
> 
>    split /CAT/, $_;
> 
> would be identical to 
> 
>    split /CAT/; # throws an error
> 
> ?

I'm not sure about your first question, but $_ is the default for split 
to work on:

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

$_ = <DATA>;
print join("\n", split(/v/)), "\n";

__END__
firstvsecondvthirdvfourthvfifthvsixth

prints:
first
second
third
fourth
fifth
sixth

I'm using Mac OS X and perl 5.8.1-RC3

HTH,
Ricky

-- 
Pukku


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

Date: Wed, 7 Apr 2004 16:37:41 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Why does split operate over multiple lines in the absence of "ms" ? And why doesn't $_ work with split?
Message-Id: <20040407163538.W14622@dishwasher.cs.rpi.edu>

On Wed, 7 Apr 2004, Sara wrote:

> Also, along these same lines why isn't $_ taken as the default arg for
> split, such that:
>
>    split /CAT/, $_;
>
> would be identical to
>
>    split /CAT/; # throws an error
>
> ?

What version of Perl are you using?  Even on 5.005, $_ *is* the default
argument for split.  If you're getting an error doing
split /CAT/;
it's not because you didn't give split enough arguments.

Paul Lalli


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

Date: Wed, 7 Apr 2004 20:47:56 +0000 (UTC)
From: simonl@is.bbc.co.uk (Simon Lockhart)
Subject: Win32::OLE / WMEncoderAgent issue
Message-Id: <c51pds$4of$1@nntp0.reith.bbc.co.uk>

Apologies if this is the wrong place to ask, but if so would appreciate
pointers in the right direction.

I'm trying to manage some Windows Media encoders remotely, using Perl and
Win32::OLE. I've translated some example VB code from the MSDN website, and
ended up with the following:

----------------8<-----------------------------------
#! c:\perl\bin\perl.exe

use strict;
use Win32::OLE;
use Data::Dumper;

my $encagent = Win32::OLE->new(["boc1enc01", "WMEncAgt.WMEncoderAgent"]);
my $encoder = $encagent->GetEncoder($encagent->EncoderNamesCollection->item(0));

my $type = Win32::OLE->QueryObjectType($encoder);
print "Its a ", Dumper($type);

print $encoder,"\n";

my $Count = Win32::OLE->EnumAllObjects(sub {
            my $Object = shift;
            my $Class = Win32::OLE->QueryObjectType($Object);
            printf "# Object=%s Class=%s\n", $Object, $Class;
        })
----------------8<-----------------------------------

Now, from my understanding of the MSDN docs, $encoder should be of type
IWMEncoder, but QueryObjectType returns undef for it. Is this a bug or
feature? Is there any way to "cast" the object to an IWMEncoder?

Thanks,

Simon
-- 
Simon Lockhart     |   Tel: +44 (0)1628 407720 (x(01)37720) | Si fractum 
Technology Manager |   Fax: +44 (0)1628 407701 (x(01)37701) | non sit, noli 
BBC Internet Ops   | Email: Simon.Lockhart@bbc.co.uk        | id reficere
BBC Technology, Maiden House, Vanwall Road, Maidenhead. SL6 4UB. UK


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

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 6373
***************************************


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