[21976] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4198 Volume: 10

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

Date: Fri, 29 Nov 2002 15:05:12 -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           Fri, 29 Nov 2002     Volume: 10 Number: 4198

Today's topics:
        [newbie] Error running xsllint.pl <Oschler@earthlink.net>
        Automatically installing Perl with my software... <extendedpartition@NOSPAM.yahoo.com>
    Re: back quotes in NT <goldbb2@earthlink.net>
    Re: beginner in perl <BROWNHIK@Syntegra.Bt.Co.Uk>
    Re: C to perl, very large data files, efficiency, idiom <pa@panix.com>
    Re: calling inherited constructor, is this valid? (Bryan Castillo)
        help - reading from STDIN <linuxnb@yahoo.com>
    Re: Help with perldoc, please. <spikey-wan@bigfoot.com>
    Re: Help with perldoc, please. edgue@web.de
    Re: Help with perldoc, please. <lusol@Pandora.cc.lehigh.edu>
    Re: Help with perldoc, please. <jurgenex@hotmail.com>
    Re: Help with perldoc, please. <spikey-wan@bigfoot.com>
    Re: Help with perldoc, please. (Helgi Briem)
    Re: Help with perldoc, please. <spikey-wan@bigfoot.com>
    Re: Help with perldoc, please. <jurgenex@hotmail.com>
    Re: Help with perldoc, please. <tassilo.parseval@post.rwth-aachen.de>
        How do I delete multiple lines from flat file (newbie) <zeldabutt@hotmail.com>
    Re: How do I delete multiple lines from flat file (newb (Tad McClellan)
        Input record separator (Ian)
    Re: Input record separator <uri@stemsystems.com>
    Re: Input record separator <wksmith@optonline.net>
        Mail::Sender failing <s.patterson@freeuk.com>
    Re: Mail::Sender failing (Tad McClellan)
    Re: need help assigning reference numbers (Alan Barclay)
        Need Help with OLE ! <Mark@ecc-limited.com>
    Re: Need Help with OLE ! (Jay Tilton)
    Re: Sentence splitter (Caie)
        String replacement (Kaz)
    Re: String replacement <kurzhalsflasche@netscape.net>
        Timezone (BrianWhitehead)
        win32 <carlson.kw@verizon.net>
    Re: win32 <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: win32 (Helgi Briem)
    Re: win32 <kurzhalsflasche@netscape.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 29 Nov 2002 19:40:15 GMT
From: "Robert Oschler" <Oschler@earthlink.net>
Subject: [newbie] Error running xsllint.pl
Message-Id: <zoPF9.4512$ov6.2003031@news2.news.adelphia.net>

I'm trying to run the XSLLint.pl script (an XSL doc checker script).  When I
do get an error message saying:

Can't locate XML/DOM.pm in @INC.

I'm running ActiveState's Perl on a Win2k box.  Is there something else I
need to install, fix, etc?

thx







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

Date: Thu, 28 Nov 2002 12:49:50 -0600
From: "Extended Partition" <extendedpartition@NOSPAM.yahoo.com>
Subject: Automatically installing Perl with my software...
Message-Id: <3de7b741_2@nntp2.nac.net>

Hello Everyone,

Is there a way to automatically install Perl (from ActiveState) on the
target machine at the time that my software is installed?

Thanks!

--
Anthony M. Saffer
SCS Consulting Services
Professional Web, Software, and Database Development
www.safferconsulting.com
ICQ 96698595




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

Date: Fri, 29 Nov 2002 16:02:41 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: back quotes in NT
Message-Id: <3DE7D5F1.1C40D8D3@earthlink.net>

Marc wrote:
> 
> Thanks for the help everyone.  Turns out that the .exe I was using,
> db2cmd.exe, for db2connect was causing a cmd.exe to start up for every
> user that triggered it.  That is, whenever the script was called,
> there was a line:
> 
> system "db2cmd db2 connect to . . .etc."
> 
> getting run.  Over time, there were several cmd.exe processes started
> up on the server, sucking up memory.  By adding a /c, the command I
> wanted to use executes and then terminates the cmd.exe.  That is
> system "db2cmd /c db2 connect to.... etc." fixes the problem.  The
> recommendation over here to use backticks wasn't a solution at all.

The *proper* solution to your problem is to switch from the "db2cmd"
program to the DBI.pm and DBD::DB2 modules.  This avoids unnecessary
external processes, and thus uses less memory and is faster.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Fri, 29 Nov 2002 12:39:08 -0000
From: "Kevin Brownhill" <BROWNHIK@Syntegra.Bt.Co.Uk>
Subject: Re: beginner in perl
Message-Id: <as7nhl$hc7$1@pheidippides.axion.bt.co.uk>


"regus" <regus_nospam@pandora.be> wrote in message
news:gF7F9.22987$Ti2.4663@afrodite.telenet-ops.be...
> Hi,
>
> I'm a beginner in Perl. I have written a simple script. Now i want it to
run
> each day once, for example each morning How can i do that in perl ?
>
> Bart
>
>

Include an infinite loop containing a sleep() command, check the time
periodically and run the main program at the correct time.





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

Date: Fri, 29 Nov 2002 21:08:24 +0000 (UTC)
From: Pierre Asselin <pa@panix.com>
Subject: Re: C to perl, very large data files, efficiency, idioms.
Message-Id: <as8l05$b6d$1@reader1.panix.com>

In <62b4710f.0211280847.2c268aa3@posting.google.com> fumail@freeuk.com (qanda) writes:

>I'm working on a large legacy system (12 year old C code [ ... ]

With luck, perl on today's computers won't suck too much compared with
C on the computers of 12 years ago...


>The first issue for me is size of files and how to read them, there
>could be 1 to 5000 data files to read every day (new files daily),
>each containing 1 to 500000 records resulting in filesizes from 1Kb to
>just over 1GB, so assuming we don't have enough memory we can't (or
>wouldn't want to) read in the whole file.

If the C could do it without soaking in entire files, perl should be
able to do it too.


>What options are there for this type of processing, by that I mean
>perlisms for this kind of processing?

If the files are binary, you may need to read records with sysread()
and preprocess them with unpack().  And re-pack() them before writing.

For the processing itself, you could duplicate whatever the C code was
doing, but you should also try to leverage the perl primitives that
aren't directly available in C.  Hashes, array slices, regexps, that
sort of thing.



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

Date: 29 Nov 2002 14:19:43 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: calling inherited constructor, is this valid?
Message-Id: <1bff1830.0211291419.3229dd62@posting.google.com>

Josef Drexler <nospam1102@joesbox.cjb.net> wrote in message news:<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.

Most OO modules bless the object into the child class using the 2
argument form of bless.

When you use syntax like:

Foo::Bar->new;

'Foo::Bar' is the first argument in @_, when inside the new method.

If you inherit from the class and say
Foo::Bar::Child->new;

'Foo::Bar::Child' is the first argument in @_ in Foo::Bar::new, (if
new is not redefined by Foo::Bar::Child.)  Foo::Bar::new will then use
that argument to bless the new object into 'Foo::Bar::Child'.

So there is no reason to rebless the object.

If the parent module is coded correctly, you shouldn't need to
rebless.


> 
> 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;
> }

# try something like this instead 
# if you don't have any specific initialization 
# don't even define a new method.
sub new {
  my $self = LWP::UserAgent::new(@_);
  print "I am doing some initialization\n";
  return $self;
}


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

Date: Fri, 29 Nov 2002 22:02:10 GMT
From: matt <linuxnb@yahoo.com>
Subject: help - reading from STDIN
Message-Id: <CtRF9.160438$WL3.66040@rwcrnsc54>

Hi All,

I'm having trouble reading from STDIN and exiting the program with Ctrl-C on 
Windows. Works fine on Linux.

Below is a snip of my code. If the script tries to connect to the database, 
and fails, the loop continues and It is then that I lose the ability to use 
Ctrl-C to exit the program. Not only can I not interrupt the program, but 
if I enter the correct password the second time around, the connection 
still fails. Entering the correct password the first time works fine, and 
entering a blank password any number of times, which matches the first if 
condition, still lets me use Ctrl-C.

---- code snip -------
my $go = 0;
my $dbpass;
while ($go == 0) {
        print "What is the password for the MySQL user?:";

        $dbpass = <STDIN>;

        chomp ($dbpass);

        $dbpass =~ s/\r//;

        if ($dbpass =~ /^\s*$/) {

                print "Blank password is not allowed!\n\n";
                
        } elsif 
        (my $dbh = DBI->connect( "DBI:mysql:test:localhost", "testuser", $dbpass,
        {PrintError =>0}))

         {

                $go =1;
                $dbh->disconnect();

        } else {
                print "Unable to connect to database using this password!\n\n";
        }
}

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

What am I missing? Any help and/or a reference to some documentation would 
be much appreciated.

Matt


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

Date: Fri, 29 Nov 2002 12:53:09 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: Help with perldoc, please.
Message-Id: <as7o13$p4k$1@newshost.mot.com>


"Helgi Briem" <helgi@decode.is> wrote in message
news:3de745ed.3829246785@news.cis.dfn.de...
> I much prefer Perl/Tk, but thats just a personal preference,
>
> I have never really used Win32::GUI, only looked at it.
> Perl/Tk is certainly far more complete and enterprise ready.

Ah! Thanks Helgi.

I am using Tk for my GUI, but I am also using Win32::GUI for other parts, as
I have gleaned a lot of my knowledge from google, etc, being a newbie. Maybe
I'm doing things wrong.

SO...is Tk capable of doing the things that I'm using Win32::Gui for?

Here's what I'm using Win32::GUI for...

When Tk starts, it minimises the DOS window, but I need it at the start of
my script, so I bring it back with:

use Win32::GUI;
 # ** OPEN THE CONSOLE WINDOW AFTER IT MINIMISES (CAN'T STOP MINIMISE) **
 my $perlwin = Win32::GUI::GetPerlWindow();
 Win32::GUI::OpenIcon($perlwin);
 Win32::GUI::Move($perlwin, 0, 0);

Later in my script, I don't need it any more, so I hide it with:

my $perlwin = Win32::GUI::GetPerlWindow();
Win32::GUI::Hide($perlwin);
# ( It can be brought back with "Win32::GUI::Show($perlwin);" )

Also, is there a good way of disabling the x at the top right hand corner of
the DOS window? If the user closes it like this, it really buggers up my
script.

Thanks.

R.






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

Date: Fri, 29 Nov 2002 14:47:04 +0100
From: edgue@web.de
Subject: Re: Help with perldoc, please.
Message-Id: <3DE76FD8.1080909@web.de>



Richard S Beckett wrote:
> SO...is Tk capable of doing the things that I'm using Win32::Gui for?

Just guessing: no.
Win32:GUI sounds like a module that allows you to manipulate the
Windows GUI (giving you access to the Win32 GUI API).
Like Win32::Process allows you to use the Win32 API process stuff.

Tk is just a GUI toolkit that allows you to create windows,
buttons, and so on. I doubt that it gives you the power to
manipulate other windows.

> Also, is there a good way of disabling the x at the top right hand corner of
> the DOS window? If the user closes it like this, it really buggers up my
> script.

Sounds like bad plan.

You see - when a user is running your script, he wants to do so.
If he decides to stop this script, he wants to do so.
He is the one who decides what is going on.
It is his machine, remember?

So - why do you think you should people tell what they are allowed
to do on their own machine?
And btw: there are more ways to kill an application than
just clicking the "x":
- one could use the taskmanager to stop Perl
- one could find out the process ID (with tools like ps) and kill
   the process.

So - disabling the "x" wont help you. If you dont want the
user to stop your program, tell him:

"Program is now doing this and that; that will take a while; pls dont 
interrupt me!"



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

Date: 29 Nov 2002 14:27:12 GMT
From: "Stephen O. Lidie" <lusol@Pandora.cc.lehigh.edu>
Subject: Re: Help with perldoc, please.
Message-Id: <as7tg0$er6@fidoii.CC.Lehigh.EDU>

edgue@web.de wrote:


> Richard S Beckett wrote:
>> SO...is Tk capable of doing the things that I'm using Win32::Gui for?


You should ask in comp.lang.perl.tk for expert answers.

> Just guessing: no.
> Win32:GUI sounds like a module that allows you to manipulate the
> Windows GUI (giving you access to the Win32 GUI API).
> Like Win32::Process allows you to use the Win32 API process stuff.

> Tk is just a GUI toolkit that allows you to create windows,
> buttons, and so on. I doubt that it gives you the power to
> manipulate other windows.

>> Also, is there a good way of disabling the x at the top right hand corner of
>> the DOS window? If the user closes it like this, it really buggers up my
>> script.

> Sounds like bad plan.

> You see - when a user is running your script, he wants to do so.
> If he decides to stop this script, he wants to do so.
> He is the one who decides what is going on.
> It is his machine, remember?

It's very common to intercept this "quit" method to perform
application cleanup duties.

Steve
-- 
@_=map{eval"100${_}"}split/!/,'/5!*2!+$]!/10+$]';use Tk;$m=tkinit;$t='just an'.
'other perl hacker';$z='createText';$c=$m->Canvas(-wi,$_[1],-he,25)->grid;$c->$
z(@_[2,3],-te,$t,-fi,'gray50');$c->$z($_[2]-$],$_[3]-$],-te,$t);$m->bind('<En'.
'ter>',sub{$y=int(rand($m->screenheight));$m->geometry("+$y+$y")});MainLoop;


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

Date: Fri, 29 Nov 2002 15:41:24 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Help with perldoc, please.
Message-Id: <EULF9.924$361.908@nwrddc04.gnilink.net>

Richard S Beckett wrote:
> This is probably a stupid question, buy hey, if you help me with this
> one, it'll save you from more stupid questions about Win32::GUI, etc.
>
> I must have Win32::GUI installed, because I'm using it in my script,
> and the "use Win32::GUI;" command doesn't error.[1] The html doc
> files that came with my active state installation don't have much
> information on Win32::GUI, and I really need to read up on all the
> features of this module.
>
> So, I tried perldoc...

Good thinking! 10 bonus points!

>
> The only option in perldoc that doesn't say "no documentation
> available" is perldoc -m Win32::GUI, but the stuff it spews out is
> useless to a newbie like me.
>
> So...How, where, why, what do I have to do to get all the info I need
> to use Win32::GUI properly?

Don't use the '-m' option. '-m' tells perldoc to display the source code and
the unformated POD source text.
Do just a plain 'perldoc Win32::GUI'. This should be much easier to read ;-)

jue




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

Date: Fri, 29 Nov 2002 15:36:43 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: Help with perldoc, please.
Message-Id: <as81jo$shc$1@newshost.mot.com>


"Stephen O. Lidie" <lusol@Pandora.cc.lehigh.edu> wrote in message
news:as7tg0$er6@fidoii.CC.Lehigh.EDU...
> edgue@web.de wrote:

> > Sounds like bad plan.
>
> > You see - when a user is running your script, he wants to do so.
> > If he decides to stop this script, he wants to do so.
> > He is the one who decides what is going on.
> > It is his machine, remember?
>
> It's very common to intercept this "quit" method to perform
> application cleanup duties.

Precisely!

If the user exits my script by any method they like, all is well, UNLESS
they close the DOS window by it's x. When this happens the script exits, but
leaves Excel running in the background, and the only way to get Excel
working properly again, is to terminate it's process in the task manager.

THAT'S why I want to disable the x.

Does anyone know how I can do this, please?

Thanks.

R.




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

Date: Fri, 29 Nov 2002 16:17:09 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Help with perldoc, please.
Message-Id: <3de792d4.3848935716@news.cis.dfn.de>

On Fri, 29 Nov 2002 15:41:24 GMT, "Jürgen Exner"
<jurgenex@hotmail.com> wrote:

>> So...How, where, why, what do I have to do to get all the info I need
>> to use Win32::GUI properly?
>
>Don't use the '-m' option. '-m' tells perldoc to display the source code and
>the unformated POD source text.
>Do just a plain 'perldoc Win32::GUI'. This should be much easier to read ;-)

As I said in another post to the OP, Win32::GUI appears
to lack the proper pod documentation.
-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: Fri, 29 Nov 2002 16:32:04 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: Help with perldoc, please.
Message-Id: <as84rh$jf$1@newshost.mot.com>


"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:EULF9.924$361.908@nwrddc04.gnilink.net...
> Richard S Beckett wrote:
> > This is probably a stupid question, buy hey, if you help me with this
> > one, it'll save you from more stupid questions about Win32::GUI, etc.
> >
> > I must have Win32::GUI installed, because I'm using it in my script,
> > and the "use Win32::GUI;" command doesn't error.[1] The html doc
> > files that came with my active state installation don't have much
> > information on Win32::GUI, and I really need to read up on all the
> > features of this module.
> >
> > So, I tried perldoc...
>
> Good thinking! 10 bonus points!
>
> >
> > The only option in perldoc that doesn't say "no documentation
> > available" is perldoc -m Win32::GUI, but the stuff it spews out is
> > useless to a newbie like me.
> >
> > So...How, where, why, what do I have to do to get all the info I need
> > to use Win32::GUI properly?
>
> Don't use the '-m' option. '-m' tells perldoc to display the source code
and
> the unformated POD source text.
> Do just a plain 'perldoc Win32::GUI'. This should be much easier to read
;-)

Oh yes! It's _very_ much easier to read...

my computer> perldoc Win32::GUI
No documentation found for "Win32::GUI".
my computer>

Erm...what was my question?

R.




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

Date: Fri, 29 Nov 2002 17:44:48 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Help with perldoc, please.
Message-Id: <kINF9.1447$ic6.949@nwrddc01.gnilink.net>

Richard S Beckett wrote:
> "Jürgen Exner" <jurgenex@hotmail.com> wrote in message
> news:EULF9.924$361.908@nwrddc04.gnilink.net...
>> Richard S Beckett wrote:
>>> This is probably a stupid question, buy hey, if you help me with
>>> this one, it'll save you from more stupid questions about
>>> Win32::GUI, etc.
>>>
>>> I must have Win32::GUI installed, because I'm using it in my script,
>>> and the "use Win32::GUI;" command doesn't error.[1] The html doc
>>> files that came with my active state installation don't have much
>>> information on Win32::GUI, and I really need to read up on all the
>>> features of this module.
>>>
>>> So, I tried perldoc...
>>
>> Good thinking! 10 bonus points!
>>
>>>
>>> The only option in perldoc that doesn't say "no documentation
>>> available" is perldoc -m Win32::GUI, but the stuff it spews out is
>>> useless to a newbie like me.
>>>
>>> So...How, where, why, what do I have to do to get all the info I
>>> need to use Win32::GUI properly?
>>
>> Don't use the '-m' option. '-m' tells perldoc to display the source
>> code and the unformated POD source text.
>> Do just a plain 'perldoc Win32::GUI'. This should be much easier to
>> read ;-)
>
> Oh yes! It's _very_ much easier to read...
>
> my computer> perldoc Win32::GUI
> No documentation found for "Win32::GUI".
> my computer>
>
> Erm...what was my question?

Hrrrrrmm, well, I don't have that module installed, so I can't confirm.
But if 'perldoc -m Win32::GUI' works then I really don't understand why
'perldoc Win32::GUI' should fail.

jue




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

Date: 29 Nov 2002 19:05:29 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Help with perldoc, please.
Message-Id: <as8dpp$3b1$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Richard S Beckett:

> If the user exits my script by any method they like, all is well, UNLESS
> they close the DOS window by it's x. When this happens the script exits, but
> leaves Excel running in the background, and the only way to get Excel
> working properly again, is to terminate it's process in the task manager.
> 
> THAT'S why I want to disable the x.

I am not sure, but wont get an END block triggered when the users clicks
this little 'x'? So add this to your script:

    END {
        # do clean-up here
    }

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Fri, 29 Nov 2002 19:20:39 GMT
From: "zelda" <zeldabutt@hotmail.com>
Subject: How do I delete multiple lines from flat file (newbie)
Message-Id: <b6PF9.183108$YSz1.52037@news01.bloor.is.net.cable.rogers.com>

Thanks in advance for any assistance.

I am trying to delete multiple entries from a flat file (I.E a list of email
addresses) I have created a script which displays a list of email addresses
stored in a flat file, with corresponding checkboxes. I would like to be
able to select multiple checkboxes and delete the email addresses from the
file.

my latest feeble effort
@userdata = param('action');



open (DATA, "$userdata") || die "cant open $userdata\n";
@data = <DATA>;
close (DATA);

foreach $x (@data) {
if (param('action') = = 1) {



open (DATA, ">$userdata") || die "cant open $userdata\n";
print DATA $x;
close (DATA);




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

Date: Fri, 29 Nov 2002 14:10:00 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How do I delete multiple lines from flat file (newbie)
Message-Id: <slrnaufico.3tu.tadmc@magna.augustmail.com>

zelda <zeldabutt@hotmail.com> wrote:


> Subject: How do I delete multiple lines from flat file (newbie)
                    ^^^^^^

   perldoc -q delete

      "How do I change one line in a file/delete a line in a
       file/insert a line in the middle of a file/append to the
       beginning of a file?"


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


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

Date: 29 Nov 2002 11:08:10 -0800
From: iang@optonline.com (Ian)
Subject: Input record separator
Message-Id: <e3cb452a.0211291108.10e3d71f@posting.google.com>

Hi,

I am having problems using the Input Record  Separator.

I have a file contianing records. Each Record is separated
by a single line beginning with a hash (#).  It is possible
however to have data withing the records to contain a hash.

I have set the $/ to "#" which works fine for files with
no # in the data.  However I do not read the records correctly
if I have a "#" embeded in some data.

I have attempted to set the $/ to "#$" and "^#$" and "#/$" with no
success.

Any pointers will be appreciated.

Thanks
Ian


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

Date: Fri, 29 Nov 2002 19:18:29 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Input record separator
Message-Id: <x7adjs2ni4.fsf@mail.sysarch.com>

>>>>> "I" == Ian  <iang@optonline.com> writes:


  I> I have a file contianing records. Each Record is separated
  I> by a single line beginning with a hash (#).  It is possible
  I> however to have data withing the records to contain a hash.

  I> I have set the $/ to "#" which works fine for files with
  I> no # in the data.  However I do not read the records correctly
  I> if I have a "#" embeded in some data.

  I> I have attempted to set the $/ to "#$" and "^#$" and "#/$" with no
  I> success.

$/ is not a regex but a plain string. this is a known limitation and
documented. since your record marker is a single line it would be simple
to do a line by line read and the process when you get a # line

my $record_text ;
while( my $line = <INPUT> ) {

	if ( $line =~ /^#/ ) {
		process_record( $record_text ) ;
		$record_text = '' ;
		next ;
	}

	$record_text .= $line ;
}

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 20:29:21 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Input record separator
Message-Id: <B6QF9.24018$Kk2.2785@news4.srv.hcvlny.cv.net>


"Ian" <iang@optonline.com> wrote in message
news:e3cb452a.0211291108.10e3d71f@posting.google.com...
> Hi,
>
> I am having problems using the Input Record  Separator.
>
> I have a file contianing records. Each Record is separated
> by a single line beginning with a hash (#).  It is possible
> however to have data withing the records to contain a hash.
>
> I have set the $/ to "#" which works fine for files with
> no # in the data.  However I do not read the records correctly
> if I have a "#" embeded in some data.
>
> I have attempted to set the $/ to "#$" and "^#$" and "#/$" with no
> success.
>
> Any pointers will be appreciated.


Try $/ = "\n#\n";
The following program prints a row of dashes between
the records.

use strict;
use warnings;
local $/ = "\n#\n";
while (<DATA>){
 print;
 print "--------------------\n";
}
__END__
abc
def
#
ghi
jkl
#
m#n#o#
pqr
#

Good Luck,

Bill




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

Date: 29 Nov 2002 14:25:20 GMT
From: Stephen Patterson <s.patterson@freeuk.com>
Subject: Mail::Sender failing
Message-Id: <slrnaueu6g.728.s.patterson@seagoon.localdomain>

I've got the following code in a script to email a report file out

my $sender = new Mail::Sender(smtp => $mailserver,
                  from => $mailfrom);
print "Sender defined\n" if ($sender ne undef);
$sender->MailFile( { to => $mailto,
             subject => 'Daily report file',
             file => $outfile } );

but it fails with
Sender defined
Can't call method "MailFile" without a package or object reference at
freeserve
daily.pl line 672.

I've tested just about everything I can think of. All the variables are
defined including $sender, but I can't print $sender or ref($sender) (both
don't print anything).

Any thoughts? It's probably something simple.

-- 
Stephen Patterson http://www.lexx.uklinux.net http://patter.mine.nu
steve@SPAM.lexx.uklinux.net  remove SPAM to reply        
Linux Counter No: 142831 GPG Public key: 252B8B37        
Last one down the pub's an MCSE


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

Date: Fri, 29 Nov 2002 08:44:40 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Mail::Sender failing
Message-Id: <slrnauevao.31h.tadmc@magna.augustmail.com>

Stephen Patterson <s.patterson@freeuk.com> wrote:

> I've got the following code in a script to email a report file out
> 
> my $sender = new Mail::Sender(smtp => $mailserver,
                               ^
                               ^
>                   from => $mailfrom);
                                     ^
                                     ^

> Can't call method "MailFile" without a package or object reference at
> freeserve
> daily.pl line 672.

> Any thoughts? It's probably something simple.


You are supposed to be giving a hash reference argument.

You are instead giving a list argument.


   my $sender = new Mail::Sender { smtp => $mailserver,
                                   from => $mailfrom
                                 };
                                 ^
                                 ^


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


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

Date: 29 Nov 2002 19:03:29 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: need help assigning reference numbers
Message-Id: <1038596609.561565@elaine.furryape.com>

In article <pkent77tea-9BA6F8.23093026112002@news-text.blueyonder.co.uk>,
pkent  <pkent77tea@yahoo.com.tea> wrote:
>Do they absolutely have to be an unbroken sequence of integers starting 
>at 1? You could use Time::HiRes to get the current time, multiply by 
>10^6 and very unlikely to get 2 people filling out the form at the same 
>millisecond. Append a random number to work around this unlikely event.

No, you will get 2 people filling out the form at the same millisecond
10 minutes after the site goes live while your boss is showing it off
in front of 5,000 people at a conference, causing your program to
download pr0n from usenet and displaying it on the big screens, causing
your company to be sued, you to be fired, your dog to starve to death
because you can't afford to feed it, and your arrest for animal cruelty.
Murphy loves this sort of thing.

Make it so it can't go wrong, and you'll never have worry.


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

Date: Fri, 29 Nov 2002 17:14:09 -0000
From: "mark wildey" <Mark@ecc-limited.com>
Subject: Need Help with OLE !
Message-Id: <uuf7t61jpp84f3@corp.supernews.com>

Hi there


I need to alter an Excel Graph that has been created in Perl using OLE
statements. Creating the statements in Excel, using record macro, gives the
following statements..


1  ActiveSheet.ChartObjects("Chart 22").Activate

2  ActiveChart.PlotArea.Select

3  ActiveChart.SeriesCollection(1).Delete

Converting them to Perl, statement "1" works fine but the method "Select" in
statement 2 appears to be an unknown value for PlotArea. Looking at the OLE
documentation the option "Select" for statement "2" and "Delete" for "3"
aren't documented options yet Excel generates them.


Can anyone advise how I can overcome this problem ?

Regards and thanks in advance


Mark







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

Date: Fri, 29 Nov 2002 22:36:05 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Need Help with OLE !
Message-Id: <3de7e7fb.80166177@news.erols.com>

"mark wildey" <Mark@ecc-limited.com> wrote:

: I need to alter an Excel Graph that has been created in Perl using OLE
: statements. Creating the statements in Excel, using record macro, gives the
: following statements..
: 
: 1  ActiveSheet.ChartObjects("Chart 22").Activate
: 
: 2  ActiveChart.PlotArea.Select
: 
: 3  ActiveChart.SeriesCollection(1).Delete
: 
: Converting them to Perl, statement "1" works fine but the method "Select" in
: statement 2 appears to be an unknown value for PlotArea. Looking at the OLE
: documentation the option "Select" for statement "2" and "Delete" for "3"
: aren't documented options yet Excel generates them.

That ain't right.  Those are valid methods for those objects.  As crummy
as the VBA documentation may be, they're in there.

Anyway, recasting that macro into Perl worked here with no troubles.

: Can anyone advise how I can overcome this problem ?

Debugging would be easier if you could share your Perl code.



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

Date: 29 Nov 2002 08:19:27 -0800
From: caie@elixa.co.uk (Caie)
Subject: Re: Sentence splitter
Message-Id: <9fd5216f.0211290819.dbddeab@posting.google.com>

helgi@decode.is (Helgi Briem) wrote in message news:<3de60f74.3749759609@news.cis.dfn.de>...
> On 28 Nov 2002 04:36:57 -0800, caie@elixa.co.uk (Caie)
> wrote:
> 
> >If I comment out the "use Lingua::...." line then the only errors are
> >generated as the module hasn't been called and methods are therefore
> >unavailible.  Even if I don't actually try to use any of
> >Lingua::EN::Sentences methods I get the same crash message.
> 
> <SNIP>
> 
> What happens if you use Lingua::EN::Sentences
> on its own, without any extra code?  Something like:
> 
> #!perl
> use warnings;
> use strict;
> use Lingua::EN::Sentence qw(get_sentences);
> my $text = 'Hello, world.  I am a computer program that 
> separates sentences.  I use a module.';
> my $sentences=get_sentences($text);    
> foreach my $sentence (@$sentences) 
> {
> print "\n$sentence\n########";                  
> }
> __END__
> 
> >I agree that it is odd that a Perl module should do anything like this
> >- even on Windows98, and it would suggest that I'm unique in this
> >problem as the module has had 25 revisions!
> >
> 
> There is definitely something fishy going in, but
> I have difficulty testing as our company has no
> Win95/98/Me machines.  We use only NT/2K/XP.
> 
> >I'm pretty close to giving up on this one and putting on my thinking
> >cap to revise my regex so I can write my own splitter.  Ideas and
> >thoughts are always welcome lads and gents,
> 
> The whole module is only about a 100 lines.
> 
> You could always cut and paste the relevant code
> from it.

Och!

That doesn't work either.  I even tried putting in some errors
(missing parenthesis) but it doesn't even get round to telling me
about it - same message as always.  I'm giving up, shall try and
deciper the regexes from the source.

Thanks anyways, peace,

Caie


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

Date: 29 Nov 2002 12:40:55 -0800
From: techcity247@yahoo.com (Kaz)
Subject: String replacement
Message-Id: <93106727.0211291240.132e6696@posting.google.com>

I'm having a bit of a problem with some variable substitution.  It
seems easy but I can't seem to get it right.  What I'm doing is
reading a template and replacing text with variables.  My text that is
to be replaced looks like this:

%%SOME_VAR%%

and that is to be replaced with form value $form_hash{'SOME_VAR'}.

That isn't too hard, I can strip the % signs and get the token I need
to use in the hash, but where I'm having a problem is in the
replacement.  The strings may look like this:

<%%SOME_VAR%%>

and I want to keep the < and >

So

$form_hash{'EMAIL'} = "me@isp.com";

<%%EMAIL%%>

replaced shoudl be:

<me@isp.com>

I have managed some crazy hack where I split <%%EMAIL%%> into tokens
then loop through and do replacement but I'm sure there must be an
easier way.  I have tried substr and tr but can't seem to get it.  Any
help would be appreciated.


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

Date: Fri, 29 Nov 2002 21:54:13 +0100
From: Dominik Seelow <kurzhalsflasche@netscape.net>
Subject: Re: String replacement
Message-Id: <3DE7D3F5.9080904@netscape.net>

Kaz announced:
> I'm having a bit of a problem with some variable substitution.  It
> seems easy but I can't seem to get it right.  What I'm doing is
> reading a template and replacing text with variables.  My text that is
> to be replaced looks like this:
> 
> %%SOME_VAR%%
> 
> and that is to be replaced with form value $form_hash{'SOME_VAR'}.
> 
> That isn't too hard, I can strip the % signs and get the token I need
> to use in the hash, but where I'm having a problem is in the
> replacement.  The strings may look like this:
> 
> <%%SOME_VAR%%>
> 
> and I want to keep the < and >
> 
> So
> 
> $form_hash{'EMAIL'} = "me@isp.com";
> 
> <%%EMAIL%%>
> 
> replaced shoudl be:
> 
> <me@isp.com>
> 
> I have managed some crazy hack where I split <%%EMAIL%%> into tokens
> then loop through and do replacement but I'm sure there must be an
> easier way.  I have tried substr and tr but can't seem to get it.  Any
> help would be appreciated.

are you looking for something like this?

$form_hash{EMAIL} = 'me@isp.com';
$_='<%%EMAIL%%>';
s /%%(\w+)%%/$form_hash{$1}/;

HTH,
Dominik



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

Date: 29 Nov 2002 11:10:34 -0800
From: bgwhite@uofu.net (BrianWhitehead)
Subject: Timezone
Message-Id: <945814d4.0211291110.7209b63e@posting.google.com>

Howdy,

I receive data from all different timezones.  I usually convert the
data and store it in one common timezone.

In the past I do this by minipulating the TZ variable.  For example:

$ENV{TZ} = "GMT+8";
print scalar localtime;
print "\n";

$ENV{TZ} = "GMT+9";
print scalar localtime;
print "\n";


This is supposed to print out two different times... it does work on a
Sun box, but when I move to a linux (Redhat 7.2, Redhat 7.3 and Redhat
8.0), it doesn't work


From the command line it does work on linux, for example:
perl -e '$ENV{TZ}="GMT+8"; print scalar localtime, "\n"'
perl -e '$ENV{TZ}="GMT+9"; print scalar localtime, "\n"'


Does anyone have any help?


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

Date: Fri, 29 Nov 2002 14:07:28 GMT
From: "Kris Carlson" <carlson.kw@verizon.net>
Subject: win32
Message-Id: <AwKF9.762$361.442@nwrddc04.gnilink.net>

Hi,

Are there shortcomings to learning perl on win32 systems (my system at
home)? What about if the end goal is to do bioinformatics?

K




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

Date: Fri, 29 Nov 2002 14:11:41 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: win32
Message-Id: <as7sit$7lt$1@korweta.task.gda.pl>

In article <AwKF9.762$361.442@nwrddc04.gnilink.net>, Kris Carlson
wrote:
> Hi,
> 
> Are there shortcomings to learning perl on win32 systems (my system at
> home)?


Yes - you have to use Windows.


> What about if the end goal is to do bioinformatics?


You still have to use Windows.


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Fri, 29 Nov 2002 14:40:35 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: win32
Message-Id: <3de77bd4.3843047269@news.cis.dfn.de>

On Fri, 29 Nov 2002 14:07:28 GMT, "Kris Carlson"
<carlson.kw@verizon.net> wrote:

>Are there shortcomings to learning perl on win32 systems 
>(my system at home)? 

No.  I recommend the Activeperl distribution
from www.activestate.com which comes
bundled with most common modules and the
excellent PPM for quick installation of new
ones.  

>What about if the end goal is to do bioinformatics?

I use Perl for bioinformatics.  I do most of my
programming on Windows and deploy the programs
on Linux.  Many of us do here.  
-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: Fri, 29 Nov 2002 15:43:32 +0100
From: Dominik Seelow <kurzhalsflasche@netscape.net>
Subject: Re: win32
Message-Id: <as7uhs$ob9r7$1@fu-berlin.de>

Recently, Kris Carlson told us:
> Hi,
> 
> Are there shortcomings to learning perl on win32 systems 
No.

(my system at
> home)? What about if the end goal is to do bioinformatics?
Hmm. For certain programs, you won't find any Windows binaries, i.e. you
will have to spend some time to find out how to compile them for Windows.

However, installing cygwin (www.cygwin.com) might help you. It provides
a Unix-like environment - ... and comes with a C compiler.


HTH,
Dominik



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

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


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