[21974] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4196 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 29 00:05:46 2002

Date: Thu, 28 Nov 2002 21:05:09 -0800 (PST)
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, 28 Nov 2002     Volume: 10 Number: 4196

Today's topics:
    Re: C to perl, very large data files, efficiency, idiom <usenet@dwall.fastmail.fm>
        calling inherited constructor, is this valid? <nospam1102@joesbox.cjb.net>
    Re: Can't open c:/foo/bar.xls. It may be in use or prot (John McNamara)
    Re: checking script for perl version compliance <krahnj@acm.org>
        CPAN urls <darkage@freeshellzzzz.org>
    Re: help: multi-dimensional hash from flat array (Damian James)
        Learning Perl 3rd Edition Chapter 8 ex3. <mark@lismark.org>
    Re: Learning Perl 3rd Edition Chapter 8 ex3. <uri@stemsystems.com>
        New user problem with installing mods <bush_tim@hotmail.com>
        nortel mmcs call records (Sean)
    Re: Please take my two-minute software engineering surv (Malcolm Dew-Jones)
    Re: rounding numbers <flavell@mail.cern.ch>
        Script Ok from the Shell, not Ok from Apache Rh8.0 <jeanluc.chaillat@chello.fr>
    Re: Teaching Perl complex data structures <derek@wedgetail.com>
    Re: Teaching Perl complex data structures <derek@wedgetail.com>
    Re: Teaching Perl complex data structures <derek@wedgetail.com>
    Re: Teaching Perl complex data structures (Tad McClellan)
    Re: Use package only if installed (Tad McClellan)
        Wierd file renaming (Colin)
    Re: Wierd file renaming (Ben Morrow)
    Re: Wierd file renaming <nobody@dev.null>
        win32::ole with act! <mgiga@logava.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 28 Nov 2002 19:05:04 GMT
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: C to perl, very large data files, efficiency, idioms.
Message-Id: <Xns92D48F456DD22dkwwashere@204.127.68.17>

fumail@freeuk.com (qanda) wrote:
["working on a large legacy system (12 year old C code"]

> I'm planning to rewrite this as an aid to learning perl, however
> if perl is up to it I will replace some of the legacy code - so
> performance is the main issue.

Brian McCauley has already commented on other parts of your post, so 
I'll recommend some relevant parts of the FAQ.

perlfaq3 
    "How can I compile my Perl program into byte code or C?"
    "How can I make my Perl program run faster?
    "How can I make my Perl program take less memory?"

perlfaq7
    "How do I declare/create a structure?"

perltrap
    "C Traps"  

 ...and a wealth of other stuff in the standard docs that come with 
Perl.  There's so much stuff that sometimes the problem is simply 
*finding* the docs you need, so don't be surprised if many of your 
questions get answered briefly with a pointer to the relevant part of 
the documentation.

-- 
David Wall - me@dwall.fastmail.fm
"Oook."


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

Date: 28 Nov 2002 23:53:12 GMT
From: Josef Drexler <nospam1102@joesbox.cjb.net>
Subject: calling inherited constructor, is this valid?
Message-Id: <as6a98$nm9$1@panther.uwo.ca>

I'm constructing a new class which inherits from LWP::UserAgent.  I want to
initialize the instance using LWP::UserAgent's constructor, but then do a
few modifications and re-bless the instance to my derived class.

I read in perltobj that re-blessing almost always means the inherited class
is misbehaving, but I don't understand why this is bad.  I haven't seen
anything else in the docs where a constructor calls an inherited
constructor and then reblesses the reference.  Is there a good reason to
avoid this?  It seems to work fine, but I'd like to know if there are any
pitfalls that I'll walk into later on.

This is an example of what I'm doing:

package LWP::FormAgent;
use base qw(LWP::UserAgent);
use strict;
use warnings;

sub new {
        my $class = shift;
        my $self = LWP::UserAgent->new(@_);
        push @{ $self->requests_redirectable }, 'POST';
        # ... do some other initialization stuff
        return bless $self, $class;
}

-- 
   Josef Drexler                 |    http://publish.uwo.ca/~jdrexler/
---------------------------------+----------------------------------------
 Please help Conserve Gravity    |  Email address is *valid*.
 Walk with a light step.         |  Don't remove the "nospam" part.


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

Date: 28 Nov 2002 14:03:55 -0800
From: jmcnamara@cpan.org (John McNamara)
Subject: Re: Can't open c:/foo/bar.xls. It may be in use or protected.
Message-Id: <8cceb2da.0211281403.6cdbb48a@posting.google.com>

chulinn@gmx.de (=?ISO-8859-1?Q?Mark_F=F6rster?=) wrote:

>I have written a perl script which uses
> Spreadsheet::Writeexcel to produce a sequence of excel files on a
> local disk. On 2 computers it runs fine, on a third computer I always
> get the same error message when trying to write file number 91:
> ...
> ActivePerl 5.6.1 with some modules (e.g. WriteExcel Version 0.37).

Version 0.37 of Spreadsheet::WriteExcel uses File::Temp to create
temporary files. On Windows File::Temp files aren't automatically
closed until after the program exits. Therefore, if you create a lot
of Workbook and Worksheet instances in one program it will create a
lot of temporary files that won't get closed and you will eventually
run up against Windows' limit for open files.

Upgrading to version 0.39 of Spreadsheet::WriteExcel will fix this.

John.
-- 
perl -MCPAN -e 'install jmcnamara & _ x ord $ ;' | tail -1


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

Date: Fri, 29 Nov 2002 03:01:18 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: checking script for perl version compliance
Message-Id: <3DE6D858.B014712C@acm.org>

qanda wrote:
> 
> is there a tool that can be used to check what versions of perl a perl
> script will work correctly with?
> 
> For example if I wrote script.pl I'd like to run something like pvchk
> script.pl
> and be told that the earliest version the script would work safely
> with is n.n.

perldoc -f require


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 29 Nov 2002 11:00:46 +1100
From: "^darkage" <darkage@freeshellzzzz.org>
Subject: CPAN urls
Message-Id: <as6anf$232$1@perki.connect.com.au>

The first URL in my cpan ftp list is one that keeps on maxing out on anon
users, etc.   I know how to add a url by "o conf urlist push
http://www.cpan.org" but how do you remove the url u dont want cpan to try
no more?

thanxs (:




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

Date: 28 Nov 2002 23:12:04 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: help: multi-dimensional hash from flat array
Message-Id: <slrnaud8m4.ha4.damian@puma.qimr.edu.au>

On 28 Nov 2002 11:34:51 GMT, Tina Mueller said:
>Damian James <damian@qimr.edu.au> wrote:
>> On Wed, 27 Nov 2002 04:10:38 -0500, Chef Tako said:
>>>evil yes; but necessary. i found myself in a hole where
>>>i need to create flat variable names (through a cgi- web page form) and 
>>>need to get it uniquely back into my session hash.
>>>...
>>>What do you percieve and suggest as an elegant solution?
>
>> I think this works in more cases than the other response in this
>> thread, which doesn't respect existing values.
>
>it does... maybe you haven't read my second posting.

Ah, so it does. I had seen your second post, but clearly hadn't
understood the reason for removing that line. My apologies. 

<grover>Oh I am so embarrassed</grover>

--damian


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

Date: Thu, 28 Nov 2002 23:05:51 +0000
From: Mark Marsella <mark@lismark.org>
Subject: Learning Perl 3rd Edition Chapter 8 ex3.
Message-Id: <as67fk$oadbb$1@ID-162318.news.dfncis.de>

I am currently working through this excellent book but after attempting 
Exercise 3 in chapter 8 on regular expressions which is -:

Make a pattern which matches a string containing nothing but a scalar 
variable's name like $fred $barney or $_ but not $0 etc. I got this
/^\$\D\w*/

and wondered if it is correct as the anwser in the appendix is longer.

markmm
-- 
 22:59:01 up 2 days,  8:05,  1 user,  load average: 0.04, 0.06, 0.01
 Running Debian 3


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

Date: Fri, 29 Nov 2002 00:47:26 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Learning Perl 3rd Edition Chapter 8 ex3.
Message-Id: <x7y97d2ode.fsf@mail.sysarch.com>

>>>>> "MM" == Mark Marsella <mark@lismark.org> writes:

  MM> I am currently working through this excellent book but after attempting 
  MM> Exercise 3 in chapter 8 on regular expressions which is -:

  MM> Make a pattern which matches a string containing nothing but a scalar 
  MM> variable's name like $fred $barney or $_ but not $0 etc. I got this
  MM> /^\$\D\w*/

that matches $~foo among many other things which are not proper variable
names. so the answer has to match tighter than your regex does.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 29 Nov 2002 01:12:26 GMT
From: Tim bush <bush_tim@hotmail.com>
Subject: New user problem with installing mods
Message-Id: <Xns92D4CD8C458D5sardanfl.bush.tim@65.32.1.7>

Hi

Just recently installed perl for the first time. Initially I was trying to
install a module but that didn't work and so I tried a test search for an
obvious one from the FAQ and stilled got the error in PPM.

With this

ppm> search CGI
Searching in Active Repositories
The system cannot find the path specified.
Error: connect: Unknown error

I reading the FAQ s and stuff for these path's but can't seem to find what
its talking about.

IM running this on NT and version 5.8 of PERL

Any Help would be appreciated

Thanks
-Tim


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

Date: 28 Nov 2002 12:40:51 -0800
From: seanpor@acm.org (Sean)
Subject: nortel mmcs call records
Message-Id: <f0f986b5.0211281240.2027ff7e@posting.google.com>

Hi folks,
before I go re-inventing the wheel... :-)

anybody already parsed the records out of a Nortel MMCS telephone
switch in perl?

I had a quick look at the manual and there appear to many different
types of records so it isn't just a simple parse...

Thanks in advance,
Sean


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

Date: 28 Nov 2002 13:44:36 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Please take my two-minute software engineering survey!
Message-Id: <3de68e44@news.victoria.tc.ca>

Tassilo v. Parseval (tassilo.parseval@post.rwth-aachen.de) wrote:
: Also sprach Malcolm Dew-Jones:

: > Jeremy Leipzig (jnleipzi@unity.ncsu.edu) wrote:
: >: http://zigster.com/survey.html
: > 
: > perl -S get. zigster.com/survey.html | grep -i perl
: > 
: > => no output from grep <=
: > 
: > Why is this in a perl group?

: If you replace perl with most of the other languages you wont get any
: output from grep either. Does that mean that it would belong in no
: newsgroup at all?

He claims it's about software engineering.  Perhaps the software
engineering group would be appropriate?  Other points conceded for the
sake of (no) argument.



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

Date: Thu, 28 Nov 2002 20:02:06 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: rounding numbers
Message-Id: <Pine.LNX.4.40.0211281924100.25908-100000@lxplus074.cern.ch>

On Nov 28, Kevin Brownhill inscribed on the eternal scroll:

[quotes entire posting in order to say]

> But some people may want to round in the way they learned in elementary
> school, college or university

Indeed they might, but that doesn't make it "consistent", nor "best",
nor even "right".

> They may not care if it is statistically balanced, or whether someone has
> recently discovered that it is fundamentally incorrect.

That's better.  Now you dropped your claim that the right answer was
inconsistent, and you concede that the layman's version might be
theoretically unsound.  That seems to be progress, of a kind.

> My way may be *wrong* according to your definition, but it is what may
> people believe it to be, including the writers of Excel, and even if the
> customer is sometimes *wrong* they only pay if they get what they want.

OK, I'll only pay you if you agree to testify that the Earth is flat.
I don't care that someone recently discovered that it is fundamentally
incorrect.  It's in the spec.  Fair do's?   You can redefine pi, while
you're at it.

> As I said, the arithmetic way is best if you want to specify how the
> rounding is to work.

I think you're just putting a positive spin on "if you want a
different definition than the one agreed by current best practice,
you'll need to supply the code to do it your way".



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

Date: Thu, 28 Nov 2002 23:07:37 GMT
From: "Jean-Luc" <jeanluc.chaillat@chello.fr>
Subject: Script Ok from the Shell, not Ok from Apache Rh8.0
Message-Id: <ZkxF9.153246$up.1631103@news.chello.at>

Hi everyone,

I'am porting a web application from RedHat 6.2 to RedHat 8/0
I have a script which run fine when I test it from the command line
(all the HTML code is well generated).
When this script is started by Apache it is then blocked right from the
begin.
I use CGI.pm and DBI.pm (with Pg).
I tried to split the script in a smaller ones in order to localte the faulty
part but
I came to the conclusion that everything is Ok when I test each part alone !
It seems that when there is more than 350 lines of code something does'nt
work.
Whatever I remove if I'am smaller than 350 lines of codes it works.
The -Tw doesn't give any usefull data.

With the ps command I can see there is a perl process executing my script
file with.
But this process is blocked on  writing to pipe ?? It's like the stdout of
my script was
redirected to something wrong when my script is larger than 350 lines ?

Thanks for your help.

Jean-Luc






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

Date: Fri, 29 Nov 2002 04:02:58 GMT
From: Derek Thomson <derek@wedgetail.com>
Subject: Re: Teaching Perl complex data structures
Message-Id: <SFBF9.65$_27.2034@news.optus.net.au>

Tina Mueller wrote:
> Derek Thomson <derek@wedgetail.com> wrote:
>>Because of Perl's behaviour, I can't just do this:
> 
> 
>>@list = ( 'one', 'two', 'three', 'four' );
>>$list[2] = ( 'first', 'second', 'third' );
> 
> 
>>... because I end up with ( 'one', 'two', 'first', 'four').
> 
> 
> no, you don't. you end up with qw(one two third four).

D'oh! You're right. I actually tested this, then just typed the wrong thing!

> 
> 
>>Now, I understand why that happens, but as you can imagine this causes 
>>some confusion.
> 
> 
>>Obviously, I need to do this
> 
> 
>>@list = ( 'one', 'two', 'three', 'four' );
>>$list[2] = [ 'first', 'second', 'third' ];
> 
> 
> well, array elements can only be scalars (or references,
> which are scalars, too). the same goes with hash values.
> once you keep that in mind it's easy to deal with nested
> data structures in Perl. IMHO.

Yes, I think so, too, but this is the third or fourth time I've had 
trouble teaching it.

I'm wondering if it only makes sense to me because I know the history 
from the Perl 4 days, or something, and to n00bs it's incomprehensible.

> but it's also a matter of taste. i don't like that python
> thing that everything is a reference. but this wouldn't stop
> me from learning it (well, if i had the time)
> 

It does make thing more consistent. I don't have this problem teaching 
Python, for example.

 > hth

Thanks for the answer, but I guess perhaps I need a compelling use case 
for "list/array flattening" or something so I can say, "yes, it's a bit 
of a pain at first, but it makes more sense if you're doing *this*".

Or something ... if I could start with an example that shows why list 
flattening is a "good thing" it would be a start.

Thanks anyway,
D.



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

Date: Fri, 29 Nov 2002 04:11:54 GMT
From: Derek Thomson <derek@wedgetail.com>
Subject: Re: Teaching Perl complex data structures
Message-Id: <eOBF9.67$_27.1745@news.optus.net.au>

Hi Brian,

brian d foy wrote:
> In article <bjjF9.31$_27.782@news.optus.net.au>, Derek Thomson
> <derek@wedgetail.com> wrote:
> 
> 
>>Because of Perl's behaviour, I can't just do this:
> 
> 
>>@list = ( 'one', 'two', 'three', 'four' );
>>$list[2] = ( 'first', 'second', 'third' );
> 
> 
>>... because I end up with ( 'one', 'two', 'first', 'four').
> 
> 
> are you sure you end up with that?  did you try it?

Sure did. I just made an error typing it up for the posting. My mistake!

> 
> 
> 
>>Now, I understand why that happens, but as you can imagine this causes 
>>some confusion.
> 
> 
> 
>>How can I convince people that this is sensible?
> 
> 
> sensible has no place here.  that's how it does it.  you don't
> have to infer anything because it is arbitrary and documented.
> it is just the way Perl does it.  :)
> 

Yeah, yeah, I know. But I'm looking at this from a teaching and 
mentoring perspective. How can I teach this stuff in a way that people 
*appreciate* it's value? Right now, the reaction I get is "this is much 
simpler in Java/Python/whatever". And it even feels awkward to me while 
teaching it - I have to get a fair chunk of concepts and new syntax 
across before we can just nest arrays.

For example, people just try to say:

@a = ('one', 'two', ( 'first', 'second', 'third' ), four);

 ... and then I have to launch into the whole "references" thing before 
they'll understand why they need to say:

@a = ('one', 'two', [ 'first', 'second', 'third' ], four);

I've successfully converted a lot of people to Perl, but I've lost at 
least one due to this issue. I'm just looking for suggestions on how 
other people get their colleagues over this hurdle.

If I had a day or two to do a proper training session that might help, 
but it's not going to happen, in reality.

--
D.



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

Date: Fri, 29 Nov 2002 04:13:34 GMT
From: Derek Thomson <derek@wedgetail.com>
Subject: Re: Teaching Perl complex data structures
Message-Id: <OPBF9.68$_27.1745@news.optus.net.au>

Derek Thomson wrote:
> 
> For example, people just try to say:
> 
> @a = ('one', 'two', ( 'first', 'second', 'third' ), four);
> 
> ... and then I have to launch into the whole "references" thing before 
> they'll understand why they need to say:
> 
> @a = ('one', 'two', [ 'first', 'second', 'third' ], four);

'four'

It's not my day/week ...



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

Date: Thu, 28 Nov 2002 22:39:22 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Teaching Perl complex data structures
Message-Id: <slrnaudrrq.1rr.tadmc@magna.augustmail.com>

Derek Thomson <derek@wedgetail.com> wrote:

> But I'm looking at this from a teaching and 
> mentoring perspective. How can I teach this stuff


There are a lot more Perl trainers on this mailing list:

   http://lists.perl.org/showlist.cgi?name=perl-trainers


than there are sloshing around here in the clp.misc swamp.  :-)

You might want to ask over there too.


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


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

Date: Thu, 28 Nov 2002 12:17:09 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Use package only if installed
Message-Id: <slrnaucnd5.2p0.tadmc@magna.augustmail.com>

Mike Bobbitt <Bobbitt@CdnArmy.ca> wrote:

> I'm trying to write some code that'll use the Digest::MD5 package if
> present, and skip it if not:

> The problem is, for systems that don't have MD5, it throws an error,
> but I want it to just "skip" that section and move on. Does anyone
> have advice on how to do that? 


Trap it with "eval BLOCK".


> I've been given the following code
> snippet, 


Which appears to be taken from:

   perldoc -f use

That's probably where you saw it?


> but can't get it working for my needs:
> 
> eval { 
>   require NetUtils; 
>   import Module LIST; 
           ^^^^^^ ^^^^

Those are "meta". You are supposed to replace them with things
appropriate to your situation. Something like:

   import NetUtils qw/ a_netutils_func another_netutils_func /;


> I've been using PERL for quite some time,


But still haven't learned to spell its name correctly.  :-)


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


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

Date: 28 Nov 2002 16:25:16 -0800
From: nathantwist@attbi.com (Colin)
Subject: Wierd file renaming
Message-Id: <24fda70e.0211281625.fff66f5@posting.google.com>

Hey guys. Ive got a directory full of files that i need to rename, but
its kind of a wird situation. they are all in the form of
howdy_captain.html
with the last name, underscore, then a first name. ive thrown a quick
script together to try and rename them as
captain_howdy.html
but im running into some problems. sorry for posting, but heres the
code:

******************************************************
#!/usr/bin/perl

#Script to try to rename names by underscore.

	my $dir = '.';
	opendir( NAMEDIR, $dir) || die ("Couldnt open directory\n");
	while ( my $name = readdir(NAMEDIR) ){
	
		@fields = split(/_/, $name) || die ("Couldnt split\n");
	
	                @secondhalf = split(/./,$fields[1]);
		rename($name, $secondhalf[0] . _ .  $name[0] . ".html") ||
					die ("Couldnt do the renamy thing.");
			}
	printf("All done\n");
	exit(0);
*********************************************************
Its kind of dicey, but the way im seeing it, i split the filename at
the underscore and put the result in an array, giving me the first
part of the name, and then the second part of the name with a '.html'
trailing at the end. the second split takes care of that. then its
just a matter of wading through the different arrays that have been
set up, and using them to rename the file. not working though ;-)
anyone have any ideas ?
Thanks !
-Cheers


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

Date: Fri, 29 Nov 2002 01:34:33 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Wierd file renaming
Message-Id: <as6g79$9kf$1@wisteria.csv.warwick.ac.uk>

nathantwist@attbi.com (Colin) wrote:
>	my $dir = '.';
>	opendir( NAMEDIR, $dir) || die ("Couldnt open directory\n");

I would suggest using C<or> rather than C<||>: it has lower precedence so you
can omit the brackets on C<open>. Purely taste, though...

>	while ( my $name = readdir(NAMEDIR) ){
>	
>		@fields = split(/_/, $name) || die ("Couldnt split\n");
>	
>	                @secondhalf = split(/./,$fields[1]);
>		rename($name, $secondhalf[0] . _ .  $name[0] . ".html") ||
                                            (1)^  (2)^^^^
(1) should be '_' or "_". (or q/_/ or...)
(2) you mean $fields[0].

I would suggest replacing the contents of the C<while> loop with

rename $name, "${2}_$1.$3" if $name =~ /(.*?)_(.*)\.(.*)/;

which is more Perly.

>					die ("Couldnt do the renamy thing.");
>			}
>	printf("All done\n");

Don't use C<printf> when C<print> will do.

>	exit(0);

You don't need this. Dropping off the end of the file is considered a normal
and perfectly acceptable way of exiting a program in Perl.

Ben


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

Date: Fri, 29 Nov 2002 02:26:24 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Wierd file renaming
Message-Id: <3DE6CFF8.5010000@dev.null>



Ben Morrow wrote:

> nathantwist@attbi.com (Colin) wrote:
> 
>>	my $dir = '.';
>>	opendir( NAMEDIR, $dir) || die ("Couldnt open directory\n");
>>
> 
> I would suggest using C<or> rather than C<||>: it has lower precedence so you
> can omit the brackets on C<open>. Purely taste, though...
> 
> 
>>	while ( my $name = readdir(NAMEDIR) ){
>>	
>>		@fields = split(/_/, $name) || die ("Couldnt split\n");
>>	
>>	                @secondhalf = split(/./,$fields[1]);
>>		rename($name, $secondhalf[0] . _ .  $name[0] . ".html") ||
>>
>                                             (1)^  (2)^^^^
> (1) should be '_' or "_". (or q/_/ or...)
> (2) you mean $fields[0].
> 
> I would suggest replacing the contents of the C<while> loop with
> 
> rename $name, "${2}_$1.$3" if $name =~ /(.*?)_(.*)\.(.*)/;
> 
> which is more Perly.
> 
> 
>>					die ("Couldnt do the renamy thing.");
>>			}
>>	printf("All done\n");
>>
> 
> Don't use C<printf> when C<print> will do.
> 
> 
>>	exit(0);
>>
> 
> You don't need this. Dropping off the end of the file is considered a normal
> and perfectly acceptable way of exiting a program in Perl.
> 
> Ben


Also,

@secondhalf = split(/./,$fields[1]);

means "split $fields[1] on any character", since . will match any 
character. Since split eats the character(s) on which you are splitting, 
the end result is that @secondhalf will be empty. What you probably mean 
here is

@secondhalf = split(/\./,$fields[1]);

which will split $fileds[1] on the dot.

By the way, consider using something like this instead of all that split 
business:

$file='joe_schmoe.html';
$file=~s/([^_]*)_([^.]*).html/$2_$1.html/;
print $file;








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

Date: Thu, 28 Nov 2002 16:42:14 -0500
From: "Avantage" <mgiga@logava.com>
Subject: win32::ole with act!
Message-Id: <04wF9.66539$e%.1331171@news20.bellglobal.com>

I am trying to create a connection between ACT! and a Perl script (v5.6.0
built for MSWin32-x86-multi-thread
) to add a contact in this system, based on a VB example :

-------------------
dim objData as object
dim szUniqueId as string
Set objData = CreateObject("ACTOLE.DATABASE")
objData.Open dbName
objData.CONTACT.Add
'Set field data
objData.CONTACT.Data CF_Company, "WhatCo"
objData.CONTACT.Data CF_Name, "Chris Huffman"
objData.CONTACT.Data CF_Address1, "20323 SomeWhere Avenue"
objData.CONTACT.Data CF_Title, "President"
'Update the records contents
szUniqueId = objData.CONTACT.Update
objData.Contact.GoTo (szUniqueId)
objData.Close
set objData = Nothing
------------------------

I've tried to convert these lines into Perl script but the system always
returns an error like :

    Win32::OLE(0.13) error 0x80020007: "No named arguments" in
METHOD/PROPERTYGET "Data"

Here is the conversion I made with Perl :
------------------------
  my $objDatabase;
  eval { $objDatabase = Win32::OLE->GetActiveObject('ACTOLE.DATABASE') };
  die "ACT! is not installed on this workstation!" if $@;
  unless (defined $objDatabase) { $objDatabase =
Win32::OLE->new('ACTOLE.DATABASE', sub {$_[0]->Close;}) or die "Impossible
to start ACT!"; }
  $objDatabase -> Open('C:\\Documents and Settings\\Administrator\\My
Documents\\ACT\\Database\\ACT5demo.dbf');
  $objDatabase -> CONTACT -> Add;
    ########################################
    # This next line return the previous error message :
    $objDatabase -> CONTACT -> Data({$CF_Company => 'WhatCo', $CF_Name =>
'Chris Huffman'});
    ########################################
  $objDatabase -> CONTACT -> Update;
  $objDatabase -> Close;
  undef $objDatabase;
-------------------------

Someone have a hint?

Best regards,

Michel G.






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

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.  

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


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