[24185] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6377 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 8 21:05:49 2004

Date: Thu, 8 Apr 2004 18:05:08 -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           Thu, 8 Apr 2004     Volume: 10 Number: 6377

Today's topics:
    Re: Alternative to AUTOLOAD <jkrugman@yahbitoo.com>
    Re: Alternative to AUTOLOAD <Joe.Smith@inwap.com>
    Re: Alternative to AUTOLOAD (Anno Siegel)
        CPAN.pm can't find libs <socyl@987jk.com>
    Re: Cygwin and path question <Joe.Smith@inwap.com>
    Re: Help me with my form please. (dan baker)
        Help: exporter is "internal" class <aman_DO_da123@al_THE_ter_OBVIOUS_n.org>
        MySQL perl script <tojess2@btinternet.com>
    Re: MySQL perl script <mr@sandman.net>
    Re: MySQL perl script <postmaster@castleamber.com>
    Re: perl -e and bash (Rob Beattie)
    Re: perl -e and bash <tadmc@augustmail.com>
    Re: Regular expression question <tadmc@augustmail.com>
    Re: Shell-escaping from perl <perlcdr@mail.rumania>
        some sed to perl action... (Barry Ringuet)
    Re: some sed to perl action... <ittyspam@yahoo.com>
    Re: some sed to perl action... <jtc@shell.dimensional.com>
        Splitting on a period in Windows. (nub5)
    Re: Splitting on a period in Windows. <noreply@gunnar.cc>
    Re: Splitting on a period in Windows. <emschwar@pobox.com>
    Re: Splitting on a period in Windows. <invalid-email@rochester.rr.com>
    Re: striptag <jidanni@jidanni.org>
    Re: subroutine only returns non zero sums <uri.guttman@fmr.com>
    Re: Tough (for me) regex case (Kevin Collins)
        WebExplorer as Perl-CGI <Klein.Matthias@web.de>
    Re: what i am doing wrong here ..  getting  LDAP_STRONG <invalid-email@rochester.rr.com>
    Re: wrong exitstatus returned? <ppi_doesnt_like_@spam_inhis_email_searchy.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 8 Apr 2004 19:22:35 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: Re: Alternative to AUTOLOAD
Message-Id: <c548pr$6fg$1@reader1.panix.com>

In <u9y8p6gyyn.fsf@wcl-l.bham.ac.uk> Brian McCauley <nobull@mail.com> writes:

>J Krugman <jkrugman@yahbitoo.com> writes:

>> I've just come across this sort of code (from the CPAN module
>> SOAP::Lite):
>> 
>> sub BEGIN {
>>   no strict 'refs';
>>   for my $method (qw(ids hrefs parts parser base xmlschemas xmlschema)) {
>>     my $field = '_' . $method;
>>     *$method = sub {
>>       my $self = shift->new;
>>       @_ ? ($self->{$field} = shift, return $self) : return $self->{$field};
>>     }
>>   }
>> }
>> 
>> (SOAP::Lite comprises many packages; practically every one of them
>> has a BEGIN block in which methods are defined using this technique.)
>> 
>> This seems to me like an alternative to AUTOLOAD for defining
>> generic accessor methods.  Any ideas about why this technique would
>> be preferable to using AUTOLOAD?

>If a package can be subclassed then all it's autoloadable methods have
>to be stubbed so that Perl knows to call the AUTOLOAD in your class
>not in the subclass.

>The choice beween using stubs and AUTOLOAD or just defining the whole
>lot in a loop is largely a matter of personal preference.

Pardon my ignorance, but what are stubs?  Where can I find
documentation on this?  I couldn't find a definition of "stub" in
any of the usual places (Programming Perl, perltoot, FAQ, etc.)

Thanks,

jill


>-- 
>     \\   ( )
>  .  _\\__[oo
> .__/  \\ /\@
> .  l___\\
>  # ll  l\\
> ###LL  LL\\
-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



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

Date: Thu, 08 Apr 2004 20:54:33 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Alternative to AUTOLOAD
Message-Id: <9_idc.225975$po.1139213@attbi_s52>

J Krugman wrote:

> Pardon my ignorance, but what are stubs?  Where can I find
> documentation on this?  I couldn't find a definition of "stub" in
> any of the usual places (Programming Perl, perltoot, FAQ, etc.)

perldoc Devel::SelfStubber

Check out all the *.al files in your perl installation.


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

Date: 9 Apr 2004 00:14:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Alternative to AUTOLOAD
Message-Id: <c54ptk$jcr$1@mamenchi.zrz.TU-Berlin.DE>

J Krugman  <jkrugman@yahbitoo.com> wrote in comp.lang.perl.misc:
> In <u9y8p6gyyn.fsf@wcl-l.bham.ac.uk> Brian McCauley <nobull@mail.com> writes:
> 
> >J Krugman <jkrugman@yahbitoo.com> writes:
> 
> >> I've just come across this sort of code (from the CPAN module
> >> SOAP::Lite):
> >> 
> >> sub BEGIN {
> >>   no strict 'refs';
> >>   for my $method (qw(ids hrefs parts parser base xmlschemas xmlschema)) {
> >>     my $field = '_' . $method;
> >>     *$method = sub {
> >>       my $self = shift->new;
> >>       @_ ? ($self->{$field} = shift, return $self) : return $self->{$field};
> >>     }
> >>   }
> >> }
> >> 
> >> (SOAP::Lite comprises many packages; practically every one of them
> >> has a BEGIN block in which methods are defined using this technique.)
> >> 
> >> This seems to me like an alternative to AUTOLOAD for defining
> >> generic accessor methods.  Any ideas about why this technique would
> >> be preferable to using AUTOLOAD?
> 
> >If a package can be subclassed then all it's autoloadable methods have
> >to be stubbed so that Perl knows to call the AUTOLOAD in your class
> >not in the subclass.
> 
> >The choice beween using stubs and AUTOLOAD or just defining the whole
> >lot in a loop is largely a matter of personal preference.
> 
> Pardon my ignorance, but what are stubs?  Where can I find
> documentation on this?  I couldn't find a definition of "stub" in
> any of the usual places (Programming Perl, perltoot, FAQ, etc.)

It's another name for a "forward" declaration, which looks like

    sub foo;

This declares "foo" as a subroutine, but leaves the definition for
later.  One way of completing the definition is through AUTOLOADER.

The effect of a forward declaration is that "foo" is known to be
a subroutine from then on.  So ...->can( "foo") will find the method 
"foo" if it is declared (it doesn't have to be defined).  Even
"\ &foo" can be used and will do the right thing if the definition
is supplied later.

Anno


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

Date: Thu, 8 Apr 2004 19:16:48 +0000 (UTC)
From: kj <socyl@987jk.com>
Subject: CPAN.pm can't find libs
Message-Id: <c548f0$6cg$1@reader1.panix.com>



I'm trying to get CPAN.pm to install XML::LibXML for me.  It aborts
the installation with a message saying that it can't find libxml2,
even though libxml2.so.2 is in /usr/lib.  I tried running CPAN with

  $ LIB=/usr/lib perl -MCPAN -e shell

but I got the same error.  How can I get CPAN to find libxml2?

Thanks!

kj

-- 
NOTE: In my address everything before the period is backwards.


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

Date: Thu, 08 Apr 2004 19:49:48 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Cygwin and path question
Message-Id: <w1idc.93823$gA5.1186642@attbi_s03>

G. Randall wrote:

> 2.  If I were to use ActiveState's perl, will renaming Cygwin's perl.exe 
> suffice for the moment?  It seems to do the trick, but I'm wondering 
> whether there's something else related I'm not aware of.

No need to rename or anything.  The two versions of perl can co-exist.
They operate differently.  For example:

   open IN, '/etc/shells' or die;

With cygwin, that looks for /etc/shells starting at cygwin's logical root.
With ActivePerl, that looks for D:\etc\shells if your default disk is D,
which may make the outcome nondeterministic.

Programs like perl using cygwin libraries handle a lot more Unix/Linx/POSIX
features, like symlinks.

I often have two DOS windows open: one Command Prompt using cmd.exe and
the other running bash under cygwin.

	-Joe


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

Date: 8 Apr 2004 14:58:05 -0700
From: botfood@yahoo.com (dan baker)
Subject: Re: Help me with my form please.
Message-Id: <13685ef8.0404081358.73af254c@posting.google.com>

davidbaker@canoemail.com (David Baker) wrote in message news:<279d0b35.0404061056.13a64c2a@posting.google.com>...
> I am a total newbie, and have no idea what I am doing.  I have created
> a html form, and am tring to pass some variable to a perl script to
> make it update a guest book.  When ever I press submit on my form, I
> get a "HTTP 500 - Internal server error". 
----------
besides the code errors, http 500 errors often indicate that the
script has the wrong privs. you need to chmod the script to rwxr-xr-x
so the server can execute it. it also needs to be in a dir that the
server allows to BE executed, usually cgi-bin.

d


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

Date: Fri, 9 Apr 2004 00:49:59 +0000 (UTC)
From: Amanda <aman_DO_da123@al_THE_ter_OBVIOUS_n.org>
Subject: Help: exporter is "internal" class
Message-Id: <c54rvn$dr8$1@reader1.panix.com>





I'm stumped.  I'm trying to import symbols from a subclass of
Exporter that is not named after the file it is in (to be more
specific, the Exporter subclass is XML::DOM::Node, which is defined
in the file XML/DOM.pm).  When I try lines such as

  use XML::DOM::Node '_C';

perl complains with "Can't locate XML/DOM/Node.pm".  (In this case,
the symbol _C is in @EXPORT_OK, so it must be imported explicitly.)
How can I import symbols from XML::DOM::Node?

Thanks,

amanda

-- 


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

Date: Thu, 8 Apr 2004 21:54:32 +0000 (UTC)
From: "Jess" <tojess2@btinternet.com>
Subject: MySQL perl script
Message-Id: <c54hmo$dci$1@sparta.btinternet.com>

Hi

Is it difficult to update one field that equals a certain value in a mysql
database using perl?
I normally use web page asp scripts using odbc but would like something that
can run as a crontab on the unix server and was considering looking into
perl.
Off the top of m head, something like this would work in asp.

db.open
sql = "select fieldname from tablename where value = 1;"
rs.open sql, db
do until rs.eof
  fieldname = newvalue
  rs.update
  rs.movenext
loop
rs.close
db.close

I found this on the Internet.  I think this is similar to what I want.
However, I wanted to keep a log of the changes in case of problems, so I can
undo the changes.  So each record changed needs to be written to a file.  I
dont think this is possible using update, so how do I loop through a
recordset using perl?

#!/usr/bin/perl -w
use strict;
use DBI;
my $username = 'username';
my $password = 'password';
my %db_info = (dbname => 'dbname');
my
$dbh=DBI->connect('DBI:mysql:$db_info[dbname]:localhost','$username','$passw
ord') or
die "Could not connect to database: " . DBI->errstr;
my $Query = "UPDATE tablename SET fieldname = newvalue WHERE value = 1";
my $insert=$dbh->prepare("$Query");
$insert->execute() or die "Could not execute SQL statement";
$insert->finish();
$dbh->disconnect();


Thanks
Jess




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

Date: Fri, 09 Apr 2004 00:08:44 +0200
From: Sandman <mr@sandman.net>
Subject: Re: MySQL perl script
Message-Id: <mr-142507.00084409042004@news.fu-berlin.de>

In article <c54hmo$dci$1@sparta.btinternet.com>,
 "Jess" <tojess2@btinternet.com> wrote:

> I found this on the Internet.  I think this is similar to what I want.
> However, I wanted to keep a log of the changes in case of problems, so I can
> undo the changes.  So each record changed needs to be written to a file.  I
> dont think this is possible using update, so how do I loop through a
> recordset using perl?
> 
> #!/usr/bin/perl -w
> use strict;
> use DBI;
> my $username = 'username';
> my $password = 'password';
> my %db_info = (dbname => 'dbname');
> my
> $dbh=DBI->connect('DBI:mysql:$db_info[dbname]:localhost','$username','$passw
> ord') or
> die "Could not connect to database: " . DBI->errstr;
> my $Query = "UPDATE tablename SET fieldname = newvalue WHERE value = 1";
> my $insert=$dbh->prepare("$Query");
> $insert->execute() or die "Could not execute SQL statement";
> $insert->finish();
> $dbh->disconnect();

Too loop through a recordset, do something like this:

    my $get_people = $dbh->prepare("select * from people");
    $get_people->execute;

    while ($a = $get_people->fetchrow_hashref()) {
        print "$$a{firstname}\n";
    }

-- 
Sandman[.net]


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

Date: Thu, 08 Apr 2004 18:02:16 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: MySQL perl script
Message-Id: <4075da0d$0$24341$58c7af7e@news.kabelfoon.nl>



Sandman wrote:

> In article <c54hmo$dci$1@sparta.btinternet.com>,
>  "Jess" <tojess2@btinternet.com> wrote:
> 
> 
>>I found this on the Internet.  I think this is similar to what I want.
>>However, I wanted to keep a log of the changes in case of problems, so I can
>>undo the changes.  So each record changed needs to be written to a file.  I
>>dont think this is possible using update, so how do I loop through a
>>recordset using perl?
>>
>>#!/usr/bin/perl -w

use warnings;

not -w

>>use strict;
>>use DBI;
>>my $username = 'username';
>>my $password = 'password';
>>my %db_info = (dbname => 'dbname');
>>my
>>$dbh=DBI->connect('DBI:mysql:$db_info[dbname]:localhost','$username','$passw
>>ord')

This line has 4 errors. '' doesn´t interpolate, and [dbname] is the 
wrong way to access a hash.

  or
>>die "Could not connect to database: " . DBI->errstr;
>>my $Query = "UPDATE tablename SET fieldname = newvalue WHERE value = 1";
>>my $insert=$dbh->prepare("$Query");

No need to put "" around $Query. Also use the convention(s) most Perl 
programmers use, variable names lower case.

>>$insert->execute() or die "Could not execute SQL statement";
>>$insert->finish();
>>$dbh->disconnect();
> 
> Too loop through a recordset, do something like this:
> 
>     my $get_people = $dbh->prepare("select * from people");
>     $get_people->execute;
> 
>     while ($a = $get_people->fetchrow_hashref()) {
>         print "$$a{firstname}\n";
>     }
>


-- 
John                            personal page:  http://johnbokma.com/

Experienced Perl / Java developer available - http://castleamber.com/


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

Date: Thu, 08 Apr 2004 22:06:02 GMT
From: rob@/remove/ghosh.co.uk (Rob Beattie)
Subject: Re: perl -e and bash
Message-Id: <4075ca50.2681820@text.news.ntlworld.com>

On Thu, 8 Apr 2004 08:09:47 -0500, Tad McClellan
<tadmc@augustmail.com> wrote:

>John Bokma <postmaster@castleamber.com> wrote:
>> Sisyphus wrote:
>>> Rob Beattie wrote:
>>> 
>
>>>> dos problem when running the following
>>>>  perl -e 'print "hi \n";'
>>> 
>>> 
>>> There's also the well known solution to this problem:
>>> perl -e "print \"hi \n\";"
>>> 
I did not know about this one

>>> (Just in case you were unaware of it :-)
>> 
>> or
>> 
>> perl -e "print qw(hi \n);"
>                 ^^
>                 ^^ you meant qq() instead of qw()

but I have heard of perl -e "print qq(hi \n);"
it is just that I can't understand the explanantion behind it. 
If I applied the following rules:- 

replace  ' with  " 
use whatever the original two " enclosed as an argument for qq()

would that be the case here?




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

Date: Thu, 8 Apr 2004 19:32:44 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: perl -e and bash
Message-Id: <slrnc7brpc.b0m.tadmc@magna.augustmail.com>

Rob Beattie <rob@/remove/ghosh.co.uk> wrote:
> On Thu, 8 Apr 2004 08:09:47 -0500, Tad McClellan
><tadmc@augustmail.com> wrote:
>>John Bokma <postmaster@castleamber.com> wrote:


>>> perl -e "print qw(hi \n);"
>>                 ^^
>>                 ^^ you meant qq() instead of qw()
> 
> but I have heard of perl -e "print qq(hi \n);"
> it is just that I can't understand the explanantion behind it. 


What explanation was that?

Was it the one in the "Quote and Quote-like Operators" in perlop.pod?


> If I applied the following rules:- 
> 
> replace  ' with  " 


That's DOS stuff. No Perl there.


> use whatever the original two " enclosed as an argument for qq()
> 
> would that be the case here?


If you don't want to have to backslash double quotes, then write
your Perl code without any double quotes in it.


Instead of starting a string with

   "

start it with

   qq(    # or:  qq/   qq{   qq.  qq|  ...

instead of ending the string with

   "

end it with

   )      # or:  /   {   .  |  ...


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


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

Date: Thu, 8 Apr 2004 16:38:34 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regular expression question
Message-Id: <slrnc7bhiq.aee.tadmc@magna.augustmail.com>

Richard Morse <remorse@partners.org> wrote:
> In article <slrnc78v18.6ll.tadmc@magna.augustmail.com>,
>  Tad McClellan <tadmc@augustmail.com> wrote:


>> 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 = <>;
>>    }
> 
> How does it handle the 'or die' clause?


What happened when you tried it?


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


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

Date: Thu, 08 Apr 2004 19:36:53 GMT
From: perl coder <perlcdr@mail.rumania>
Subject: Re: Shell-escaping from perl
Message-Id: <pRhdc.4438$Lh2.1744@bignews1.bellsouth.net>

Glenn Jackman said:
> quotemeta is probably what you want:
> 
>     my $cmd = q{foo bar `nasty command`}
>     `echo $cmd`
> 
>     my $safe = quotemeta $cmd
>     `echo $safe`
 
I use that extensively when I need to pass arbitrary filenames through
the shell.  It's a good starting point, but it's not 100% foolproof.
One case where it can break down is if the filename contains a dash in
it, and the shell command interprets that as a option (the getopt()
kind).  You can get around that by giving the special option -- before
the filename, like this:

$qpath = quotemeta $path;
system("prog -x -y --blah -n 5 -- $qpath");

There might be other issues too, but that's all I can think of right
now.


-- 
No crazy stuff in my email. ;-)


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

Date: 8 Apr 2004 12:40:57 -0700
From: bringuet@loomissayles.com (Barry Ringuet)
Subject: some sed to perl action...
Message-Id: <dc2f09b.0404081140.5b48fa48@posting.google.com>

eh gday, put together the following dog eviction but don't know how to
unravel it again... would like to do only in perl but don't know how
and am not digesting perlre fast enough
appreciated...
sed -n '/somestring/,$p' somefile|perl -pi -e
's/\f/\n/g,s/\033E//,s/\015//g' > somefile2


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

Date: Thu, 8 Apr 2004 16:31:08 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: some sed to perl action...
Message-Id: <20040408163004.T14622@dishwasher.cs.rpi.edu>

On Thu, 8 Apr 2004, Barry Ringuet wrote:

> eh gday, put together the following dog eviction but don't know how to
> unravel it again... would like to do only in perl but don't know how
> and am not digesting perlre fast enough
> appreciated...
> sed -n '/somestring/,$p' somefile|perl -pi -e
> 's/\f/\n/g,s/\033E//,s/\015//g' > somefile2
>

Since not all of us speak sed, it might be a good idea to tell us in
English what you're trying to accomplish...

Paul Lalli


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

Date: 8 Apr 2004 15:10:39 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: some sed to perl action...
Message-Id: <slrnc7bfuf.drr.jtc@shell.dimensional.com>

In article <20040408163004.T14622@dishwasher.cs.rpi.edu>, Paul Lalli wrote:
> On Thu, 8 Apr 2004, Barry Ringuet wrote:
> 
>> eh gday, put together the following dog eviction but don't know how to
>> unravel it again... would like to do only in perl but don't know how
>> and am not digesting perlre fast enough
>> appreciated...
>> sed -n '/somestring/,$p' somefile|perl -pi -e
>> 's/\f/\n/g,s/\033E//,s/\015//g' > somefile2
>>
> 
> Since not all of us speak sed, it might be a good idea to tell us in
> English what you're trying to accomplish...
> 
> Paul Lalli

"sed -n '/somestring/,$p' somefile" simply looks for a match of
'somestring' in 'somefile' and, if there is one, prints from the first line
that matches to the end of the file.

-- 
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]


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

Date: 8 Apr 2004 16:41:09 -0700
From: rmiller_nub@yahoo.com (nub5)
Subject: Splitting on a period in Windows.
Message-Id: <23e193ca.0404081541.23f800d6@posting.google.com>

Hey Folks I was hoping someone could explain this to me.  Normally I
used perl in unix and I do the following command.

$filename = "data.dat";
@temp =split("\.","$filename");

For some reason this does not work with Perl on Windows.  However if I
do the following change from " to / it works.

$filename = "data.dat";
@temp =split(/\./,"$filename");

Why is that?  Can anyone provide me with an explanation.  Should I not
use " and stick with /'s or the q's?  I'm going to be writing a lot of
cross-platform (unix, windows) code.


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

Date: Fri, 09 Apr 2004 02:36:22 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Splitting on a period in Windows.
Message-Id: <c54r79$2ogep8$1@ID-184292.news.uni-berlin.de>

nub5 wrote:
> Hey Folks I was hoping someone could explain this to me.  Normally
> I used perl in unix and I do the following command.
> 
> $filename = "data.dat";
> @temp =split("\.","$filename");
> 
> For some reason this does not work with Perl on Windows.  However
> if I do the following change from " to / it works.
> 
> $filename = "data.dat";
> @temp =split(/\./,"$filename");
> 
> Why is that?  Can anyone provide me with an explanation.  Should I
> not use " and stick with /'s or the q's?

Wonder what the docs for the split() function says. Hmm...

> I'm going to be writing a lot of cross-platform (unix, windows)
> code.

Then it's reasonably a good idea to not rely on the 'trial-and-error'
method, but rather follow the documented syntax.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Thu, 08 Apr 2004 18:47:35 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Splitting on a period in Windows.
Message-Id: <etowu4qgeoo.fsf@fc.hp.com>

rmiller_nub@yahoo.com (nub5) writes:
> Hey Folks I was hoping someone could explain this to me.  Normally I
> used perl in unix and I do the following command.
>
> $filename = "data.dat";
> @temp =split("\.","$filename");

Well, that's your problem right there, most likely.  If you read the
documentation for the 'split' function with 'perldoc -f split', you
will see that the first parameter is a regex, not a string.  I'm just
about to leave, so I'm not going to figure out why this works, but
it's quite possible it's pure luck that it works for you.

I expect someone will prove that last sentence to be pure balderdash,
so I'm not standing behind it very strongly. :)

> For some reason this does not work with Perl on Windows.  However if I
> do the following change from " to / it works.
>
> $filename = "data.dat";
> @temp =split(/\./,"$filename");
>
> Why is that?  Can anyone provide me with an explanation.

Perl itself can provide you with an explanation, if you read the
standard documentation included with your Perl distribution.  I say
this not to be a sanctimonious git, but to help you not offend too
many other people here, who are very knowledgable about Perl and could
be a lot of help to you if you let them: please try not to ask
questions here that you could answer in about 20 seconds on your own.

If you have a question about how a function works, use the command

perldoc -f <function>

on the command line.

For a module's documentation, use

perldoc <module>

You should also familiarize yourself with the Perl FAQ.  'perldoc
perltoc' will give you the headings of the sections and what questions
are answered in them.  If you always check there first, to make sure
your question isn't answered in the FAQ (or any of the other resources
I mentioned), you stand a much better chance of getting answers more
verbose than "read the documentation".

>  Should I not use " and stick with /'s or the q's?  I'm going to be
> writing a lot of cross-platform (unix, windows) code.

You should also familiarize yourself with the perlport manpage ('man
perlport' on UNIX, or 'perldoc perlport' everywhere).  But no matter
what kind of code you write, learning to consult the documentation on
your hard drive first will save you lots of time (USENET propogation
is not consistent or necessarily even complete), and will save us lots
of frustration.  A win for everyone, I think.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Fri, 09 Apr 2004 00:57:35 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Splitting on a period in Windows.
Message-Id: <4075F3E3.5000209@rochester.rr.com>

nub5 wrote:

> Hey Folks I was hoping someone could explain this to me.  Normally I
> used perl in unix and I do the following command.
> 
> $filename = "data.dat";
> @temp =split("\.","$filename");
> 
> For some reason this does not work with Perl on Windows.  However if I
> do the following change from " to / it works.
> 
> $filename = "data.dat";
> @temp =split(/\./,"$filename");
> 
> Why is that?  Can anyone provide me with an explanation.  Should I not
> use " and stick with /'s or the q's?  I'm going to be writing a lot of
> cross-platform (unix, windows) code.


That is because split() takes (except for one special case) a regexp as 
its first argument.  You provided it with a string, specifically the 
string . after removal of the \-quoting in the "-delimited string.  That 
string then gets converted to a regexp by split.  The . is a regexp 
metacharacter which will match any character.  So you will split on 
every character of your string, which, while it *does* "work", doesn't 
do what you want to do.  When you supply /\./ to split, split gets a 
genuine regexp that will match a literal . character.  See:

     perldoc -f split

That will not be a problem on just Windoze -- Perl on any platform will 
do the same thing.  I don't believe you that it worked differently under 
Unix (it doesn't when I try it).  Maybe it worked differently under some 
ancient version of Perl a long long time ago.

So in summary:  "\." is the same as '.' which goes to /./ in split
             and "\\." is the same as '\.' (or '\\.') which goes to /\./
so you might as well just use what you intended, which is /\./ .

Also note that you have expressions like "$var" in your code.  For why 
that is bad, see:

     perldoc -q quoting

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Fri, 09 Apr 2004 07:17:44 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: Re: striptag
Message-Id: <87ad1moy93.fsf@jidanni.org>

OK, done: http://jidanni.org/comp/striptag
striptag -- strip given tags out of HTML
Usage example: striptag font div < file.html


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

Date: 07 Apr 2004 15:29:23 -0400
From: Uri Guttman <uri.guttman@fmr.com>
Subject: Re: subroutine only returns non zero sums
Message-Id: <siscr7uzwprg.fsf@tripoli.fmr.com>

>>>>> "RM" == Richard Morse <remorse@partners.org> writes:

  >> Initialize $total when you declare it:
  >> sub addnums { 
  >> my $total = 0; 
  >> $total += $_ foreach @_;
  >> return $total;
  >> }

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

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

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

have you tried it? that is the first rule about asking questions like
this. you have code and does it work?

try it with and without my and report any differences. you will find the
answer you seek.

uri


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

Date: 8 Apr 2004 15:15:36 -0700
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: Tough (for me) regex case
Message-Id: <a6882f32.0404081415.5c26119c@posting.google.com>

"Brian Davis" <brian@knowdotnet.nospam.com> wrote in message news:<ek957sFGEHA.3404@TK2MSFTNGP10.phx.gbl>...
> You can use the following expression:
> 
> "(?<no_quotes>(""|[^"])*)"
> 
> Simply access the value of the named group "no_quotes" for each match
> returned.
> 
> 
> Brian Davis
> http://www.knowdotnet.com
> 
> 
> 
> "Rob Perkins" <rob_perkins@hotmail.com> wrote in message
> news:5sqm60lpp2upam99j9lrmjebjakclh1pod@4ax.com...
> > Hello,
> >
> > I know I'm not a regular, and I'm new to the arcana of regular
> > expressions, so I'm a little stuck with two specific cases and I'm
> > hoping for a genius:
> >
> > The case I'm most stumped on is an input string like this:
> >
> > The "quick" brown "fox jumped ""over"" the" lazy dog.
> >
> > Where what I want to have matched is the quoted strings, except that
> > paired doublequotes don't count, and I don't want to capture the
> > quotemarks. In other words, my desired matches are:

-SNIP-

Can you point me to some documentation (man page, etc) that describes
a "named group"? I've searched the perlre man page and cannot seem to
find any reference to named groups or an example similar to yours.

How about showing us (me?) how to access the named group?

Thanks,

Kevin


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

Date: Fri, 9 Apr 2004 00:14:54 +0200
From: "Matthias Klein" <Klein.Matthias@web.de>
Subject: WebExplorer as Perl-CGI
Message-Id: <c54is5$2o8b2p$1@ID-228482.news.uni-berlin.de>

Does anybody know a freeware/opensource Perl-CGI that acts like a regular
file-explorer?

The internet project I am working on will be hosted on a regular
shared-hosting environment based on Red Hat Linux 7.3 (no root access, but
own perl-cgi permitted).

It requires some sort of web-based file-explorer so that users can upload
and download even large files: the user browses to a certain URL, types in
his passwd and can then browse in the existing files on the remote host,
download them and upload new ones. That is what I am hoping for...

Does anybody know a program like this?

Tnx

Matthias




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

Date: Fri, 09 Apr 2004 00:07:16 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: what i am doing wrong here ..  getting  LDAP_STRONG_AUTH_NOT_SUPPORTED
Message-Id: <4075E81D.4050006@rochester.rr.com>

Durairaj Avasi wrote:

 ...
> what i am doing wrong here... why this drives so grazy... 
 ...


> my $ldap = &lConnect('$myserver');

-----------------------^---------^

Well, one thing you are probably doing wrong is using ' to quote a 
string you evidently want interpolated.  Interpolation does not occur in 
'-delimited strings, so you are attempting to connect to the server with 
the literal name: $myserver .  That probably isn't the real name of your 
server.  Remove the ' characters -- converting them to " would be a 
useless use of "'s, which can actually be worse than it sounds (see:

    perldoc -q quoting

).

You should probably also check the result 

of your lConnect routine to see if it failed or not.

If it did fail, you'd never know.  And with that
server name, it undoubtedly did fail.  But I'm
surprised you didn't notice the bad server name in
the results of the print statement in lConnect.
You *did* provide us with copy/pasted code, right,
not a retyped version?


 ...

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Fri, 09 Apr 2004 00:52:07 +0200
From: Frank de Bot <ppi_doesnt_like_@spam_inhis_email_searchy.net>
Subject: Re: wrong exitstatus returned?
Message-Id: <c54l38$fe2$1@news1.tilbu1.nb.home.nl>

Linux

I found out that $? won't function if the SIGCHLD handler is set, which 
it is. I've found a very rude way to solve this problem by adding the 
exit status via another script in front of the stdout of command I want 
to run.
But I don't realy like this method, any suggestion?




Joe Smith wrote:
> Frank de Bot wrote:
> 
>> I have a perl script server which works with fork. But I got a problem 
>> with executing commands from a child which handles a request. The 
>> exitstatus $? is always -1 I've tried execute commands with system and 
>> `command` but nothing matters.
> 
> 
> Linux?
> Win32?
> Win32 with cygwin?


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

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


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