[17197] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4609 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 13 14:15:36 2000

Date: Fri, 13 Oct 2000 11:15:22 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <971460922-v9-i4609@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 13 Oct 2000     Volume: 9 Number: 4609

Today's topics:
    Re: Please Please Help <harrisr@bignet.net>
    Re: Please Please Help <jeff@vpservices.com>
    Re: Plz help - Perl Q <uri@sysarch.com>
        Problem using a module <don@lclcan.com>
    Re: Silly newbie question (Net::POP3) nobull@mail.com
        Splitting a scalar in two arrays (Andre Majorel)
    Re: Splitting a scalar in two arrays (Mark-Jason Dominus)
    Re: Splitting a scalar in two arrays nobull@mail.com
    Re: Splitting a scalar in two arrays (Andre Majorel)
        Transport of database changes across different environm akluyskens@my-deja.com
    Re: using Perl module across the Net (David Wall)
    Re: Weekday at a date <sb@muccpu1.muc.sdm.de>
    Re: which perl modules are installed by deafult if any? <barbr-en@online.no>
        Win32: Mac filenames cause trouble <dpc3k@virginia.edu>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 13 Oct 2000 12:38:32 -0400
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: Please Please Help
Message-Id: <sueej4q558nc87@corp.supernews.com>

<qureshii@my-deja.com> wrote in message
news:8s6rio$c6s$1@nnrp1.deja.com...
> Hi I am a new perl student and what I need to do it to write a script
> which takes in a C++ file and print out all the files listed only in
> #include<iostream.h>
> #include<hello.c>
>
> i.e the out put should be
> iostream.h
> hello.c
>
> so far when I am trying to extract it
> what i get as a result of $1 is
>
>
> hello.c
>

If you post your code it will be easier for others to help.




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

Date: Fri, 13 Oct 2000 09:55:46 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Please Please Help
Message-Id: <39E73E92.38205780@vpservices.com>

qureshii@my-deja.com wrote:
> 
> Hi I am a new perl student and what I need to do it to write a script
> which takes in a C++ file and print out all the files listed only in
> #include<iostream.h>
> #include<hello.c>

The best way to do that is to a) print out 50 copies of the file on
paper and roll them together b) send 50 copies of your request to the
same newsgroup using different subject lines and ignore their replies.

The members of the newsgroup will then c) appear at your door and beat
you over the head with the rolled copies long enough for the two lines
of it you want to fall out and land on your doorstep where you can
retrieve them if the dog doesn't eat them first.

-- 
Jeff


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

Date: Fri, 13 Oct 2000 17:44:27 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Plz help - Perl Q
Message-Id: <x7wvfcws90.fsf@home.sysarch.com>

>>>>> "G" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:

  G> Uri Guttman wrote:
  >> > Michael Cook wrote:
 
  >> > I have a Perl question & have read many many FAQs, books, web
  >> > sites (TY Godzilla), newsgroups, etc. I have almost got it, but am
 
  >> you have a major mistake listed there. you accepted help from
  >> moronzilla. you have to be decontaminated before any regulars can help
  >> you. any help you got from her is wrong and useless.


  G> Your claiming Perl Online Documentation to be
  G> wrong and useless does help to explain why you
  G> know so little about Perl and Perl Programming.

no, i am claiming and proclaiming with complete acclaim from this group
that anything you say is tainted by your delusional psychosis. even if
you happen to point someone to a correct source for an answer doesn't
mean anything since a stopped clock is right twice a day. you could be
shooting darts at perldoc and sometime hit the target. that doesn't mean
you know anything.

as for my perl skills, your statement doesn't seem to carry any weight
here (other than your nutty baggage). i leave it to the group to decide
if my posts are worthy to read. other than you, i don't seem to get many
negative flames about them. hmmm, could it be that i have bribed
everyone here? or could it be that you are a frigging idjit? 

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Fri, 13 Oct 2000 11:31:16 -0400
From: Don <don@lclcan.com>
Subject: Problem using a module
Message-Id: <39E72AC3.AF23077@lclcan.com>

Hi,

I've downloaded and installed the DBD-XBase-0.161 module on my RedHat
6.2 Linux system.

When I insert the line:

use XBase;

in my perl script, I encounter "Internal Server Error" when attempting
to execute my script from my browser.  Any idea what is wrong?

Thanks,
Don




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

Date: 13 Oct 2000 18:29:01 +0100
From: nobull@mail.com
Subject: Re: Silly newbie question (Net::POP3)
Message-Id: <u93di0zm3m.fsf@wcl-l.bham.ac.uk>

ambidexter@my-deja.com writes:

> $pop->get(($total_msgs-1),<TEMPMSG>);

What were you thinking when you wrote this?  Do you know what the <>
operator does when applied to a filehandle?  Do you know what
arguments the get() method of Net::POP3 expects?  Do you know how the
message is returned by the get() method?

You probably meant:

print TEMPMSG @{$pop->get($total_msgs-1)};

> What am I not doing?

Reading manuals?  Thinking?  I don't know.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 13 Oct 2000 16:12:33 +0000 (UTC)
From: aym@aym4.domicile.fr (Andre Majorel)
Subject: Splitting a scalar in two arrays
Message-Id: <slrn8uekom.mg.aym@aym4.domicile.fr>

I'm processing a named.conf file that contains various stuff
like named.confs contain plus a great number of sections that
look like this :

  zone "somedomain.com" in {
  type master;
  file "somefile";
  };

  zone "otherdomain.net" in {
  type master;
  file "otherfile";
  };

I would like to slurp the whole file into a scalar, extract the
parts of it that match the above to an array and save the parts
that don't to another array. Or possibly leave them in the
scalar, as long as the parts that match have been removed from
it. Basically, I want to split the data in two.

I know about the obvious

  local undef $/;
  my $raw = <>;
  my @match = $raw =~ /the_good_regexp/g;
  $raw =~ s/the_good_regexp//g;

but, for efficiency's sake, is there a way to do that in *one*
pass ? Without scanning the scalar twice, that is. Sort of

  (@match, @notmatch) = someoperator/the_good_regexp/g;

-- 
André Majorel <amajorel@teezer.fr> (it's really "teaser")
http://www.teaser.fr/~amajorel/
"Synchronise excuse calendars, page 47, Hypotropic Osmotic Leeching." -- BOFH


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

Date: Fri, 13 Oct 2000 16:24:14 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Splitting a scalar in two arrays
Message-Id: <39e7372e.4559$17f@news.op.net>


In article <slrn8uekom.mg.aym@aym4.domicile.fr>,
Andre Majorel <amajorel@teezer.fr> wrote:
>I'm processing a named.conf file that contains various stuff
>like named.confs contain plus a great number of sections that
>look like this :
>
>  zone "somedomain.com" in {
>  type master;
>  file "somefile";
>  };
>
>I would like to slurp the whole file into a scalar,

It seems to me that it might be better to use paragraph mode reading
in this case.  For example:

        local $/ = "";   # Paragraph mode; see 'perlvar' for more information
        while (<FILE>) { # Read in next paragraph
          if (($zone, $contents) = /zone "([^"]*)" in \{(.*)\};/s) {
             push @good, $_;
             # ... do something with $zone and $contents
          } else {
             push @bad, $_;
          }
        }

Note the /s modifier on the regex match.  If you omit this, the .*
will not match across lines.

>  local undef $/;
>  my $raw = <>;
>  my @match = $raw =~ /the_good_regexp/g;
>  $raw =~ s/the_good_regexp//g;
>for efficiency's sake, is there a way to do that in *one* pass ?

Try this:

        @items = split /(the_good_regexp)/, $raw;
        while (@items) {
          push @bad,  shift @items;
          push @good, shift @items;
        }

split() will produce a list of alternating bad and good items.
(If two good items are consecutive, the intervening bad item will be
the empty string.)  Then you separate one array into two using your
favorite method.

I do not know whether this is more or less efficient than what you proposed.



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

Date: 13 Oct 2000 18:41:23 +0100
From: nobull@mail.com
Subject: Re: Splitting a scalar in two arrays
Message-Id: <u9y9zsy6yk.fsf@wcl-l.bham.ac.uk>

aym@aym4.domicile.fr (Andre Majorel) writes:

>   my @match = $raw =~ /the_good_regexp/g;
>   $raw =~ s/the_good_regexp//g;
>
> but, for efficiency's sake, is there a way to do that in *one*
> pass ? Without scanning the scalar twice, that is.

my @match;
$raw =~ s/(the_good_regexp)/push @match, $1; ''/eg;

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 13 Oct 2000 18:00:49 +0000 (UTC)
From: aym@aym4.domicile.fr (Andre Majorel)
Subject: Re: Splitting a scalar in two arrays
Message-Id: <slrn8uer5b.uj.aym@aym4.domicile.fr>

In article <39e7372e.4559$17f@news.op.net>, Mark-Jason Dominus wrote:
>It seems to me that it might be better to use paragraph mode reading
>in this case.  For example:
>
>        local $/ = "";   # Paragraph mode; see 'perlvar' for more information
>        while (<FILE>) { # Read in next paragraph
>          if (($zone, $contents) = /zone "([^"]*)" in \{(.*)\};/s) {
>             push @good, $_;
>             # ... do something with $zone and $contents
>          } else {
>             push @bad, $_;
>          }
>        }

Unfortunately I can't trust the input file on that. Sometimes,
sections are run against each other without an intervening empty
line.

>Try this:
>
>        @items = split /(the_good_regexp)/, $raw;
>        while (@items) {
>          push @bad,  shift @items;
>          push @good, shift @items;
>        }
>
>split() will produce a list of alternating bad and good items.
>(If two good items are consecutive, the intervening bad item will be
>the empty string.)  Then you separate one array into two using your
>favorite method.

That sounds like an excellent idea but how do you get split() to
return both the fields *and* the delimiters ? On my system,
@items contains only what's between the matches.

-- 
André Majorel <amajorel@teezer.fr> (it's really "teaser")
http://www.teaser.fr/~amajorel/
"Synchronise excuse calendars, page 47, Hypotropic Osmotic Leeching." -- BOFH


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

Date: Fri, 13 Oct 2000 17:05:49 GMT
From: akluyskens@my-deja.com
Subject: Transport of database changes across different environments.
Message-Id: <8s7fd8$tdn$1@nnrp1.deja.com>

Hi all,

I address this message to this newsgroup because it's one of the only
newsgroups where I could find decent solutions to some more general
problems. The people here are really broadminded and thanks to you I
already could draw a very good solution in a previous (SAP) project.

In our company we develop a finiancial software simultaneously on
different sites. My job (just started) is to manage the different
developement environments in one of the sites (Brussels).
Recently I started to study all the problems occuring during the
development process that are caused by the differences between the
environments on the different sites. I came up with the idea of having
several development environments and 1 consolidation environment. The
consolidation environment should be used to gather all the changes made
on the different sites and create on consistent new version of the
software. There are many commercial products available on the market to
manage all these problems for flat files. The problem I have is to
transport changes made to a RDBMS across different systems. I worked in
SAP environments for more than two years were the transport system is
able to manage these changes. I'am looking for a comparble solution
that could be used in our company. We develop on Sybase and will
probably port the software to other databases very soon. Realizing that
a lot of companies or projects are facing similar problems, I would
like to know if some of them have found a good solution to deal with
that problem.



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 13 Oct 2000 11:39:20 -0400
From: darkon@one.net (David Wall)
Subject: Re: using Perl module across the Net
Message-Id: <8FCC732A1darkononenet@206.112.192.118>

Sagar.Shah@sid.cam.ac.uk (Sagar R. Shah) wrote in 
<Pine.WNT.4.21.0010130913160.-382781@sscpc44.sid.cam.ac.uk>:
>Doing 
>
>use lib qw(xxxxx);
>
>allows you to specify extra paths to search when looking for perl modules
>by modifying @INC (or whatever it is)
>
>Does anyone know whether there is a way to specify a URL to look at when
>looking for perl modules.
>
>This might sound slightly irregular, but I think would be very useful.
>
>My specific problem is that I have a number of websites on a single
>webserver, I want to move one to a totally different server, but avoid
>having to have duplicate copies of my personal standard utility modules on
>each server....
>
>Any ideas appreciates

I don't know if this is a good idea or not, but you could make a module 
available via HTTP, use LWP to get it, and then eval() the code, something 
like 

use LWP::Simple;
my $module = get("http://host.example/RemoteMod.pm");
eval $module;
print $RemoteMod::testvar;

I tried this with a plain little module that only sets $testvar, and it 
worked ok, but I have no idea how well it would work for more complex 
modules.

-- 
David Wall
darkon@one.net


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

Date: 13 Oct 2000 16:10:09 GMT
From: Steffen Beyer <sb@muccpu1.muc.sdm.de>
Subject: Re: Weekday at a date
Message-Id: <8s7c51$r45$1@solti3.sdm.de>

In article <8s6vbg$mrm$1@solti3.sdm.de>, Steffen Beyer <sb@muccpu1.muc.sdm.de> wrote:

>>> >>I basically need to implement this function:
>>> >>sub weekday_of_date(someDate)
>>> Fastest possibility probably would be to use Perl's builtin function
>>> "localtime()" (see "perldoc -f localtime"), but the range is only
>>> 1970 - 2038 (on most systems).
>>> For the range 1955 - ... as in your case Date::Calc is indeed a feasible
>>> solution, since it's written in C internally for maximum speed.

>> Just to let you know, I timed both variants with Benchmark.pm and both were
>> under the measurable amount of time.

> Increase the number of iterations to get more meaningful results!

Here's an example of how to do this:

#!/usr/local/bin/perl
use Benchmark;
use Date::Calc qw(Day_of_Week Today);
sub _localtime
{
    my($dow) = (localtime())[6];
}
sub _datecalc
{
    my($dow) = Day_of_Week(Today());
}
timethese
(
    1000000,
    {
        localtime => \&_localtime,
        datecalc => \&_datecalc
    }
);
__END__

And here's what I get (to my own surprise, and even though there are actually
two Perl/C function calls in the _datecalc sub (as opposed to only one in
the _localtime sub)):

[sb@pindhart]/tmp>perl bb.pl
Benchmark: timing 1000000 iterations of datecalc, localtime...
  datecalc: 31 wallclock secs (13.56 usr +  1.44 sys = 15.00 CPU) @ 66666.67/s (n=1000000)
 localtime: 33 wallclock secs (14.89 usr +  1.31 sys = 16.20 CPU) @ 61716.49/s (n=1000000)
[sb@pindhart]/tmp>perl bb.pl
Benchmark: timing 1000000 iterations of datecalc, localtime...
  datecalc: 32 wallclock secs (13.36 usr +  1.55 sys = 14.91 CPU) @ 67050.81/s (n=1000000)
 localtime: 32 wallclock secs (14.84 usr +  1.39 sys = 16.23 CPU) @ 61597.69/s (n=1000000)
[sb@pindhart]/tmp>perl bb.pl
Benchmark: timing 1000000 iterations of datecalc, localtime...
  datecalc: 31 wallclock secs (13.53 usr +  1.41 sys = 14.95 CPU) @ 66910.61/s (n=1000000)
 localtime: 32 wallclock secs (15.08 usr +  1.14 sys = 16.22 CPU) @ 61657.03/s (n=1000000)

So basically, Date::Calc appears to be slightly faster.

Regards,
-- 
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/whoami/ (Who am I)
    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)


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

Date: Fri, 13 Oct 2000 17:09:57 +0200
From: =?iso-8859-1?Q?K=E5re_Olai_Lindbach?= <barbr-en@online.no>
Subject: Re: which perl modules are installed by deafult if any?
Message-Id: <WAFF5.5240$W31.79579@news1.online.no>


"Anders Lund" <anders@wall.alweb.dk> skrev i melding
news:udBF5.386$Tq1.24932@news010.worldonline.dk...
> Pete wrote:
>
> > Hi,
> >
> > I was wondering if someone could put me straight on the following
query:
> > Which modules are installed by default when perl is installed on
Linux
> > and Windows '98?
> >
> > I have looked at the documentation with the activestate version
> > and cannot figure this out.
> >
> > I find that a lot of samples I come across contain phrases like:
> > USE XXX::YYY OR USE XXX
> > For example: USE DBI
> > I am familiar with integrating Perl with the MySQL database using
the DBI
> > method, but am not sure whether any modules are installed by default
> > and can just be implementedusing the 'USE XXX' syntax.
> >
> > Anyone have any views on this?
> >
> > Any help received would be greatly appreciated as this would greatly
> > enhance my patchy knowledge of perl.
>
> I don't know the activestate package, but *real* perl has a tool known
as
> perldoc. In a term (DOS prompt for you) type "perldoc perltoc", then
if
> your pager allows searching search for the string "standard modules"
> (insensitive). (If you install less, you search by typeing "/string"
>

If you get an error regarding 'use', you haven't got it ;-)

If you use ActiveState installation:
On win98 you might look into c:\perl\lib and c:\perl\site\lib if you
have
installed on c:-drive. Otherwise adapt drive and installation-path.

Or use win98 search-function on *.pm in c:\perl  as modules
end on .pm

If you don't have the neccessary module, it's easiest to install
it using PPM.

DOS> ppm install DBI
DOS> ppm install --location=http://www.activestate.com/PPMPackages
/5.6 DBD-Mysql

# The last *all on one line* to install API for MySql SQL-server.

When installed, you get further docs in c:/perl/html -catalogs,
mostly under "site" for non-standard modules.


Regards Kĺre



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

Date: Fri, 13 Oct 2000 13:30:11 -0400
From: "Doug Coppage" <dpc3k@virginia.edu>
Subject: Win32: Mac filenames cause trouble
Message-Id: <8s7gqf$ah6$1@murdoch.acc.Virginia.EDU>

Hello,

At my office, we have a PERL script that runs on an NT server. It deletes
all files in specific public-access directories that are more than N days
old.

This is an easy concept, but there is one major sticking point: Macintosh
users (drat them!) manage to write files with file name characters that are
illegal in Windows, like
     Xray scan 10/11/2000.tif
Such file names are rendered as
     Xray scan 10?11?2000.tif
when printed from PERL. Tthe (-d ...) and (-f ...) tests on these file specs
both yield FALSE. These things cannot be treated like files, because PERL
does not recognize them as files. I can't rename them; I can't delete
them...I can't do anything with them. >8^{

I have successfully manipulated such files from the DOS command line (ren,
del), but inserting the commands (adapted to yield correct syntax) into the
script `like this` has resulted in error messages: "The shell commmand
failed to operate."

Any recommendations on handling these files?

Many thanks,
---Doug Coppage

===========================================
Douglas P. Coppage,  dpc3k@virginia.edu
Microcomputer Support Specialist
ITC - Academic Computing for the Health Sciences
University of Virginia, Charlottesville, VA
===========================================




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4609
**************************************


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