[8600] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2217 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 31 15:08:10 1998

Date: Tue, 31 Mar 98 12:00:28 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 31 Mar 1998     Volume: 8 Number: 2217

Today's topics:
    Re: 'Search and Replace' for multiple files spidaman@well.com
    Re: 'Search and Replace' for multiple files <jsd@hudsucker.gamespot.com>
        'Use'ing a module whose name is in a scalar ()
    Re: 'Use'ing a module whose name is in a scalar <wellss@iren.net>
    Re: Anon Scalar Expression (was: Evaluate expression in (Kevin Reid)
    Re: Anon Scalar Expression (was: Evaluate expression in <jdporter@min.net>
        Automate Telnet Keystrokes <Susser.Joel@ic.gc.ca>
    Re: Automate Telnet Keystrokes <wellss@iren.net>
        FTP server! <twrq@usa.net>
    Re: God Help Us All (was: Re: Sneex having problems) <stackhou@elk.cray.com>
    Re: How to conditionally put 'use OLE' in script which  (Kevin Reid)
    Re: HTML::Parse Won't pull data out of tables <jsd@hudsucker.gamespot.com>
    Re: Is there a "Newsgroup" for Newbies to Perl? <Howard@roslyn.demon.co.uk>
        mktime function inPerl <mohanh@neelum.com>
    Re: mktime function inPerl <westxga@ptsc.slg.eds.com>
    Re: Need help with "shared memory" module IPC::Shareabl <captain@pirate.de>
        Need perl/tk help.... <aderr@summa4.com>
    Re: need regexp help <smitty77@pacbell.net>
    Re: Odd or even function (Abigail)
    Re: Perl Cgi Questions (Kevin Reid)
    Re: Question about Perl script and form submit buttons  (susan cassidy)
    Re: small letters into capital letter (Abigail)
    Re: Suppressing "used only once" (Mike Stok)
    Re: Suppressing "used only once" <jdporter@min.net>
    Re: Win32::OLE and Word97 (Paul.Casteels)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 31 Mar 1998 13:00:58 -0600
From: spidaman@well.com
Subject: Re: 'Search and Replace' for multiple files
Message-Id: <6freba$47u$1@nnrp1.dejanews.com>

No need to cat from the command line, just do this
perl -pi -e 's/felines/rodents/g' filename
and filename could just as well be a shell wildcard
perl -pi -e 's/felines/rodents/g' *.html
would perform the substitution in all of the cwd html files...
-Ian

In article <351F0CC9.23DE7C93@netnuevo.com>,
  Stephanie Ray <sray@netnuevo.com> wrote:
> Cat worked wonderfully! I always did like cats :-)
>
>  perl -p -i -e  "s/search-for/replace-with/;" `cat test.txt`

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 31 Mar 1998 19:15:07 GMT
From: Jon Drukman <jsd@hudsucker.gamespot.com>
Subject: Re: 'Search and Replace' for multiple files
Message-Id: <6frfbr$72s$1@was.hooked.net>

Stephanie Ray <sray@netnuevo.com> wrote:
> Cat worked wonderfully! I always did like cats :-)

> A couple of things-  I had to be careful to use backquotes, and not
> single (forward quotes) and to double quote the search & replace string
> as well as use a semicolon:

>  perl -p -i -e  "s/search-for/replace-with/;" `cat test.txt`

read the perlrun manpage.  you can get rid of the cat if you eliminate 
the -i option (which says to edit the file in-place).  if you just
want to print a file with your edits, do this:

perl -p -e 's/search-for/replace-with/' test.txt


-- 
Jon Drukman                                            jsd@gamespot.com
-----------------------------------------------------------------------
Plan: Eat right, exercise regularly, die anyway.


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

Date: 31 Mar 1998 18:27:43 GMT
From: nicholas@neko.binary9.net ()
Subject: 'Use'ing a module whose name is in a scalar
Message-Id: <slrn6i2dcd.doq.nicholas@neko.binary9.net>

Hi folks -

I was wondering if I could have some input on something that I'm
attempting to build.

I'm creating a CGI (no, this is NOT a CGI question, :) that starts out 
with a 'stub' program that pulls in a module based on a parameter and
starts it up.

If things worked the way I wanted them to, it would look like this:

#!/usr/bin/perl

use strict;
use CGI;


use lib '/usr2/nicholas/work/eagle/sc/lib';
use Documents;

##############################################################################
# declarations

my $self;
my $mode;

##############################################################################
# assignments

$self=new CGI;
$mode=$self->param('mode') ? $self->param('mode') : 'init';

##############################################################################
# subs

##############################################################################
# main

use SC::$mode;
SC::$mode::init;

__END__

Of course, the last two lines don't work. And I can't seem to _make_
them work (which is the point of this question).

I tried:

eval "use SC::$mode";

but I get a "no such file or directory", it obviously can't find the
module (which is /usr2/nicholas/work/eagle/sc/lib/SC/init.pm). I 
_really_ thought this approach would work (even considering I don't
like using 'eval's). But it didn't.

And various other permutations (including 'require', which DID work,
but I don't want to bypass the startup stuff that 'use' performs).
Of course, if I hardwire:

if ($mode eq 'init') {
    use SC::init;
    SC::init::init;
}

it works fine, but defeats the purpose of this :) [ I want to be able
to literally _drop_ modules into ../lib/SC/ and not modify existing
code to have them accessable ].

So, here's the question(s)

1. How would you suggest I cleanly 'use' a module whose name resides
   in a scalar?

2. Or should I go an entire different route to this dynamic loading? 
   (pure opinion, I know :)

Thank you for your time!

-- 
___________________________________________________________________________

 simple is elegant         mrnick.binary9.net         nicholas@binary9.net
___________________________________________________________________________



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

Date: Tue, 31 Mar 1998 13:43:06 -0600
From: Steve Wells <wellss@iren.net>
Subject: Re: 'Use'ing a module whose name is in a scalar
Message-Id: <3521474A.AE750BCE@iren.net>

You could put the first part in a BEGIN block, or continue
to use the eval statement but be sure to put the lib 
definitions in there as well.

Hope that helps,
STEVE

----------------
Steve Wells
http://www.iren.net/wellss

nicholas@neko.binary9.net wrote:

> If things worked the way I wanted them to, it would look like this:
> 
> #!/usr/bin/perl
> 
> use strict;
> use CGI;
> 
> use lib '/usr2/nicholas/work/eagle/sc/lib';
> use Documents;
> 
> ##############################################################################
> # declarations
> 
> my $self;
> my $mode;
> 
> ##############################################################################
> # assignments
> 
> $self=new CGI;
> $mode=$self->param('mode') ? $self->param('mode') : 'init';
> 
> ##############################################################################
> # subs
> 
> ##############################################################################
> # main
> 
> use SC::$mode;
> SC::$mode::init;
> 
> __END__
> 
> Of course, the last two lines don't work. And I can't seem to _make_
> them work (which is the point of this question).
> 
> I tried:
> 
> eval "use SC::$mode";
> 
> but I get a "no such file or directory", it obviously can't find the
> module (which is /usr2/nicholas/work/eagle/sc/lib/SC/init.pm). I
> _really_ thought this approach would work (even considering I don't
> like using 'eval's). But it didn't.
> 
> And various other permutations (including 'require', which DID work,
> but I don't want to bypass the startup stuff that 'use' performs).
> Of course, if I hardwire:
> 
> if ($mode eq 'init') {
>     use SC::init;
>     SC::init::init;
> }
> 
> it works fine, but defeats the purpose of this :) [ I want to be able
> to literally _drop_ modules into ../lib/SC/ and not modify existing
> code to have them accessable ].
> 
> So, here's the question(s)
> 
> 1. How would you suggest I cleanly 'use' a module whose name resides
>    in a scalar?
> 
> 2. Or should I go an entire different route to this dynamic loading?
>    (pure opinion, I know :)


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

Date: Tue, 31 Mar 1998 12:54:16 -0500
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Anon Scalar Expression (was: Evaluate expression inside print "")
Message-Id: <1d6q9s6.inzi0ka3qvxoN@slip166-72-108-20.ny.us.ibm.net>

Stuart McDow <smcdow@arlut.utexas.edu> wrote:

> Tom Phoenix <rootbeer@teleport.com> writes:
> >     $scalar_ref = \eval { my $temp = 'default value' };
> 
> Tom, I believe that
> 
> $scalar_ref = \'default value';
> 
> will work. Or did I misunderstand the question?

Depends on what you use it for. If you attempt to modify the string
referenced, it will fail.

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Tue, 31 Mar 1998 13:06:36 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Anon Scalar Expression (was: Evaluate expression inside print "")
Message-Id: <352130AC.1ECF@min.net>

David A. Black wrote:
> 
> Not to say, of course, that references to scalars are useless - only
> examining the case of going from scalar value to ref to scalar value in
> the course of one expression.  I'm curious, actually, to know where (other
> than in double-quote interpolation) one would need/want that syntax.

I don't know; I was mainly just thinking of interpolative context.
(Camel p.46)


> Hmmmm....  somewhere in all this, though not very lucidly, I think I'm
> beginning to understand why it makes sense for \($x,$y,$z) to evaluate
> to a list of refs....

Your thought processes are similar to mine.


> Also - perhaps the hypothetical <> operator would conflict, logically
> and/or syntactically, with symbolic references?

Well, I'm not advocating the adoption of the angle braces for this
use...
but if perl were modified to use them that way, it would only be
par for the course.

John Porter


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

Date: Tue, 31 Mar 1998 13:32:58 -0500
From: Joel Susser <Susser.Joel@ic.gc.ca>
Subject: Automate Telnet Keystrokes
Message-Id: <352136DA.37493D9E@ic.gc.ca>

Hi,

I'm looking for a way to automate the process of loging into another
server with telnet and entering a series of keystrokes.  Some of the
keystrokes will be variable coming from a file. One of the keystrokes is

a <tab>.  Preferrably from my Linux Box.

I'm currently using a pc running Windows 3.1 to do this with a macro
language called Symatic Basic but after a hundred records the thing
craps out because of a memory leak.

Any help on this would be very much appreciated.

Sincerely,

Joel Susser
susser.joel@ic.gc.ca







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

Date: Tue, 31 Mar 1998 13:46:47 -0600
From: Steve Wells <wellss@iren.net>
Subject: Re: Automate Telnet Keystrokes
Message-Id: <35214827.B9311661@iren.net>

The non-perl answer is to use EXPECT. 
The perl answer is to use Net::Telnet...

Hope that helps,
STEVE

----------
Steve Wells
http://www.iren.net/wellss

Joel Susser wrote:

> I'm looking for a way to automate the process of loging into another
> server with telnet and entering a series of keystrokes.  Some of the
> keystrokes will be variable coming from a file. One of the keystrokes is
> 
> a <tab>.  Preferrably from my Linux Box.
> 
> I'm currently using a pc running Windows 3.1 to do this with a macro
> language called Symatic Basic but after a hundred records the thing
> craps out because of a memory leak.


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

Date: Tue, 31 Mar 1998 12:19:30 -0600
From: "Alex" <twrq@usa.net>
Subject: FTP server!
Message-Id: <6frbsk$k0s$1@ionews.ionet.net>

ftp: warezhut.dynip.com
port: 21
L/P: anonymous
To get passowrd for the FTP go to http://warezhut.dynip.com to find the
password.





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

Date: Tue, 31 Mar 1998 13:20:46 -0600
From: Mark P Stackhouse <stackhou@elk.cray.com>
Subject: Re: God Help Us All (was: Re: Sneex having problems)
Message-Id: <3521420E.6488@elk.cray.com>

Take a Valium John, you're overreacting here.  Who died and made YOU
the Perly Gate Keeper?


John Porter wrote:

> Between 10 March (when this guy first crashed in here) and
> 22 March, he posted over 100 messages, and yet managed to
> contribute absolutely zilch to the technical content of
> this newsgroup. 
 
Says you!  Are you now making judgement calls for newbies now?
I also read Sneex' posts here... and I've learned more from him
than I'll ever learn from the Ivory Tower.

I'm not sure what Mark Stackhouse has in mind
> when his says he's "knowledgeable AND a class A-1 guy (see his
> posts here)", but I've read every one of those posts, and
> I think Mark is being generous, to say the least.

He may not be as knowledgeable as some others here, but his responses
are always courteous and complete.  And yes, I think anyone who's
at least attempting to alleviate some of the irritation that exists
here is a "class A-1 guy".

> 
> "His server's down? Oh my! What ever shall we do!"
> Does he have any clue what it takes to be appreciated,
> and subsequently missed?
> 
> Suddenly that "newbie chat group" doesn't sound so bad...

You should be elated... you won't have to read 100 posts to find
out you're not interested in what someone has to say!  I'm just
a newbie but I think I could have figured THAT out in, maybe, 3 or 4.

> 
> John Porter

-- 
 Mark Stackhouse
 x64704

 *********************************************************
 *							 
 * Senior Electrical-Mechanical Technician		 
 * Homepage - http://wwwmfg.cray.com/~stackhou	 
 * E-mail - stackhou@elk.cray.com				 
 *							 
 * Off site homepage - http://www.execpc.com/~stackhou
 *
 * Home E-mail - stackhou@execpc.com				 
 *				 			 
 * "The best things in life aren't things"		 
 *							 
 *********************************************************


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

Date: Tue, 31 Mar 1998 12:54:14 -0500
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: How to conditionally put 'use OLE' in script which can run either in Unix or Win?
Message-Id: <1d6phnw.cf83ii1cdkgcwN@slip166-72-108-20.ny.us.ibm.net>

Wing Choy <whc@mink.att.com> wrote:

> I have a perl script which can I would like to run on both 
> Unix and PC.  If I am running on a PC, I need to use the OLE
> module.
> 
> Is there a way to put 'use OLE' conditionally inside a script?
> In Unix the OLE module does not exist, but even though that
> potion of the code is not executed, the compiler stills look
> for the module and won't even compile.
> 
> I am sure there is a way to conditionally ask perl to use
> certain modules.  But I couldn't find it in the FAQ.
> 
> Thanks for any pointer.
> 
>       Wing

BEGIN {
  if ($^O = "your OS name") {
    require your_module;
    your_module->import();
  }
}

This does exactly the same thing as use, except for the if statement.
Put the parameters to use in the import() statement.

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 31 Mar 1998 19:24:30 GMT
From: Jon Drukman <jsd@hudsucker.gamespot.com>
Subject: Re: HTML::Parse Won't pull data out of tables
Message-Id: <6frfte$72s$2@was.hooked.net>

Jerry Pank <jerryp.usenet@connected.demon.co.uk> wrote:
> I guess I'm using the wrong routine from HTML.  I am having problems
> getting to grips with the OO side of things.  Slowly but Slowly :-(

create a subclass of HTML::Parser and override the text method.
something like this...

#!/usr/local/bin/perl -w

use HTML::Parser;

package myParser;
  @ISA = qw/HTML::Parser/;  # myParser is a subclass of HTML::Parser
  sub text {
    my ($self,$text)=@_;
    print $text;
  }

package main;

my $p = myParser->new;

undef $/
$p->parse(<>);


note that due to a bug (or design limitation) in HTML::Parser
regarding <>, it will only parse the first file handed to it on the
command line.

-- 
Jon Drukman                                            jsd@gamespot.com
-----------------------------------------------------------------------
Plan: Eat right, exercise regularly, die anyway.


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

Date: Tue, 31 Mar 1998 19:29:12 +0100
From: Howard Davies <Howard@roslyn.demon.co.uk>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <fEMPABA4XTI1Ew$B@roslyn.demon.co.uk>

Having just gone through the 'trauma' of learning to program in Perl, it
seems to me that Perl having many ways to achieve the same result is a
major stumbling block for us Newbies.
We end up cobbling together 3 or so half remembered methods and end up
with a program that looks like it should work, but somehow never does!

The FAQ is a great help, but can't solve every problem.
Has anyone thought of setting up a "comp.lang.perl.help" newsgroup?
I read the java.help group and reading the threads there have solved
many of my Java problems, how about the same thing for Perl?

-- 
Howard Davies           Howard@roslyn.demon.co.uk


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

Date: Tue, 31 Mar 1998 11:27:17 -0800
From: "Mohan Hegde" <mohanh@neelum.com>
Subject: mktime function inPerl
Message-Id: <6frak0$5m7$1@usenet52.supernews.com>

Hi

Perl does not seem to have an equivalent of mktime in UNIX. I have day,
date, month, year and time in hours and minutes and I have to convert it to
time in seconds since epoch. How do I do this in Perl ?

Thanks
Mohan




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

Date: Tue, 31 Mar 1998 13:27:05 +0000
From: Glenn West <westxga@ptsc.slg.eds.com>
Subject: Re: mktime function inPerl
Message-Id: <3520EF29.662E@ptsc.slg.eds.com>

Mohan Hegde wrote:
> 
> Hi
> 
> Perl does not seem to have an equivalent of mktime in UNIX. I have day,
> date, month, year and time in hours and minutes and I have to convert it to
> time in seconds since epoch. How do I do this in Perl ?

timelocal?

> 
> Thanks
> Mohan


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

Date: Tue, 31 Mar 1998 19:59:35 +0200
From: Mark Seuffert <captain@pirate.de>
Subject: Re: Need help with "shared memory" module IPC::Shareable !
Message-Id: <35212F07.32BC@pirate.de>

Hi... back with another shm-example (somewhere below).

>From the view of a user, I still can not understand why I'm forced
to use eval-blocks... I think it's the modul that has to catch 
errors and should return (good) arguments if there was an error... 
that's not my work!
However... I don't want to rewrite IPC::Shareable... with some
more lines of sourcecode (after hours) it works for my purpose. :)

zenin@archive.rhps.org wrote:
> There still are strong reasons not to use shared memory.  There
> are limits on how many shared memory handles can be used at once
> on any given system.  There are security issues with using them.
> Bugs in code and interrupted programs can cause memory "leaks" that
> affect the entire system by never releasing the memory. -Yes, you
> can delete them manually, but that's a bandaid.
When I program my IPC stuff, I ask my brother sometimes (he is an 
Windows95 programmer) and he answers... yes U can do it on Windows95 
this or that way. So I try to make it with perl on Linux a similar way.
If Linux is more complicate to program than Windows95... that must be
bad joke!!!
Apache webserver ueses shared memory, more applications should use it 
if neccesary... and shared memory would be better implemented.
Actually sharded memory is a good choice if U need global data shared 
with multiple threads. What else should I use... another server (
sockets/TCP), where all childs are connected to and store/fetch data...
no thanx. Remembers me why I hate programming pascal.... :)

> : # Set up error handlers
> : sub catch_int { exit; }  #Note: Catch any other signals like this
> : $SIG{INT} = \&catch_int;
> This is the default for SIGINT anyway.  No need to set it.
U need it, Do it with all possible signals! 'exit' is needed for 
untieing variables (man perltie) or in our case shared memory. As far as 
I can understand: if there is an uncatched signal, the destructor will 
not be called and shared memory block will not given back. Larry why?

Maybe the author of IPC::Shareable (Ben Sugars) will say something about 
my problem, did not replyed yet. What makes me really wonder why the 
author is making things in his examples which will definitly not work.

Here is the new script.... I work now with something like that:

-------------------------- schnip -------------------------------
#!/usr/bin/perl -w
# A convinient and secure way (?) of using shared memory 
# module IPC::Shareable. Would be glad about any improvement.
# I hope the use of IPC::Shareable will be easier sometimes...
# Mark Seuffert <captain@pirate.de>

use IPC::Shareable;       #better redefine a smaller SHM_BUFSIZ
$ShmGlue    = 'moak';     #First shm (shared memory) identifyer
$ShmNext    = 1970;       #Difference to next shm identifyer
%ShmOptions = ( 'create' => 'yes',  'exclusive' => 'yes', 
                'mode' => 0600, 'destroy' => 'yes' );

# Set up error handlers
sub catch_int { exit; }   #Catch any possible signals like this
$SIG{INT} = \&catch_int;  #or do whatever U want, shutdown server
$SIG{TERM} = \&catch_int; #and so on... with other signals
$SIG{CHLD} ='IGNORE';     #We don't want zombies

sub catch_error {         #This will catch 'die' from modules
 my $errortext = shift;   #(Ben why do use croak any time?)
 my $package=caller(1);
 if ($package eq 'IPC::Shareable') { #check out which package
  $errortext = "Shared memory failure\n";
 }
 die "$errortext";      #don't use 'exit', would stop eval blocks
 #exit;
}
$SIG{'__DIE__'} = \&catch_error;

#
# Here we start our little program, let's go...
#

# Get shared memory for a hash
$ShmGlue = &NewSharedHash (\%Data,$ShmGlue);
if (!$ShmGlue) { die "Can't create shared memory block\n" }

# Uncomment the next line, to produce an error for testing
# tie(%Data, IPC::Shareable,  $ShmGlue, { %ShmOptions });

# Test shared memory... some real IPC
print "Testing shared memory...\n";
$error=$child=0;
if(($child=fork()) == 0) { #this is the child
  select (undef, undef, undef, 0.1); #wait 1/10 second
  print "child is working\n";
  tie(%Data, IPC::Shareable, $ShmGlue, { 'create' => 'no', 
                                         'destroy' => 'no' });
  $Data{'foo'}=42;  
  exit;
} else {                   #this is the parent
  print "parent is waiting\n";
  wait;
  if ($Data{'foo'}!=42) { print "NOT ok\n"; $error=1 }
}

# Free shared memory
eval { untie %Data };
if ($@) { die "Can't free shared memory\n" }
print "OK\n" if(!$error);
exit;

# Tries to get a new shared memory block for a hash
sub NewSharedHash {                 
  my ($hash)=$_[0];       #we really need a reference here
  my $t;                  #... or is there a better solution?
  $_[1] = unpack('i', pack('A4', $_[1])); #First make glue numeric
  for ($t=10;$t;$t--) {   #try'n'catch 10 times               
   eval { tie(%$hash, IPC::Shareable,  $_[1], { %ShmOptions }) };
   if ($@) { $_[1]+=$ShmNext } #if no success, try again
   else    { last }       #ok, we have a shared memory block
  }
  return $@ ?  0 : $_[1]  #give back error or new glue
}
-------------------------- schnap -------------------------------

greetings from Heidelberg, germany
Mark


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

Date: Tue, 31 Mar 1998 14:38:38 -0500
From: aderr <aderr@summa4.com>
To: aderr@summa4.com
Subject: Need perl/tk help....
Message-Id: <3521463D.AA78EF55@summa4.com>

I posted this question twice on comp.lang.perl.tk and got no response.
Can someone in the "greater perl" community help?

I'm trying to use the perl/tk function fileevent(). I've opened a socket
using:
   socket(SOCK, PF_INET, SOCK_STREAM, $proto);

 ... and I want to execute the callback function readskt() when data is
available for reading from the socket (SOCK). I have a button configured
to execute the callback when I press it, which allows me to read data
from the socket when I know data is available. This works fine, except
a) I have to press a button to read the data, and b) if no data is
available to read, recv() (in my call back) blocks.

The button (widget) that I press to read from the socket is called
$readrpt. The setup for fileevent looks like this:
    $readrpt->fileevent(SOCK, 'readable'=>\&readskt);

Am I doing something wrong? Please help!

Alan Derr
aderr@summa4.com



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

Date: Tue, 31 Mar 1998 09:53:06 -0800
From: david smith <smitty77@pacbell.net>
Subject: Re: need regexp help
Message-Id: <35212D80.8DBDD327@pacbell.net>

Ronald J Kimball wrote:

> Douglas Wilson wrote:
> >
> > Use "." not /./ if you want to split on dot characters and ""
> > if you want to split on every character.
>
> I don't think so.
>
>   DB<1> x split(".", 'foo.bar')
>   empty array
>   DB<2> x split("\.", 'foo.bar')
>   empty array
>   DB<3> x split("\\.", 'foo.bar')
> 0  'foo'
> 1  'bar'
>   DB<4> x split(/\./, 'foo.bar')
> 0  'foo'
> 1  'bar'
>
> The first argument to split is a regex.  If you give it a string, the string
> will be used as a regex.
>
> {split "."} is equivalent to {split /./}.  So is {split "\."}; do you see why?

I see why {split "."} is equivalent to {split /./}, but explain to me why {split
"\."} is the same.  Why isn't {split "\."} equivalent to {split /\./}?  Just
curious....

Dave

>
>
> --
>  _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
> ( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
>     /                                   http://www.ziplink.net/~rjk/
>         "It's funny 'cause it's true ... and vice versa."







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

Date: 31 Mar 1998 17:46:54 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Odd or even function
Message-Id: <6fra6e$842$5@client3.news.psi.net>

Tom Christiansen (tchrist@mox.perl.com) wrote on MDCLXXIII September
MCMXCIII in <URL: news:6fr08l$ohd$1@csnews.cs.colorado.edu>:
++  [courtesy cc of this posting sent to cited author via email]
++ 
++ In comp.lang.perl.misc, 
++     Casper Kvan Clausen <ckc@dmi.dk> writes:
++ :> Which leads to the obvious
++ :>     chomp($number);	 # integer divide by 10
++ :
++ :chomp() is much more useful than chop(); so much so, apparently, that
++ :even our own Tom C. has forgotten about chop()!
++ 
++ Well, ok.  I guess $/ = '0' doesn't win much. :-)
++ (See the p5p list/newsgroup.)


Hmmm.


$ perl -wle '$/ = "0"; $_ = 10; print chomp'
1
$ perl -wle '$/ =  0 ; $_ = 10; print chomp'
0

That's scary.


Abigail
-- 
perl -pwle '$_ .= reverse'


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

Date: Tue, 31 Mar 1998 12:54:10 -0500
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Perl Cgi Questions
Message-Id: <1d6mi2t.qqjtl7civcrqN@slip166-72-108-20.ny.us.ibm.net>

Mike Glenn <mglenn@no.spam.zbzoom.net> wrote:

> Second:
> I would also like to parse the above data for web URL's and email addresses
> and then add the aproprate tags. So when the data is rewritten on a web
> page, what I typed is displayed as a link. (Similar to what Outlook Express
> does).

s@\b((http|ftp|https|mailto)://[^> ]*[^> .;])@<A HREF="$1">$1</A>@g;

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 31 Mar 1998 08:35:33 -0800
From: susanc@news.SanDiegoCA.ncr.COM (susan cassidy)
Subject: Re: Question about Perl script and form submit buttons !!!!
Message-Id: <6fr60l$rbc@ssd3450.SanDiegoCA.NCR.COM>

In article <MPG.f89c021b6882ad69896b9@news.greatbasin.net>,
Mick Knutson <mknutson@websolution.com> wrote:
>I am having trouble with users clicking a submit button 2+ times because 
>they think it will help the 1.25 minute process speed up or something.
>
>Any ideas on how to eliminate this?
>
>QUESTION:
>If a user clicks a submit button once, a process is started for that 
>script.
>If they click again before the script returns, is that going to be 
>another process or the same one.
>
>And does the first click get fully processed before the second?
>-- 
>
>
>Thanks ...
>
You might be able to use some JavaScript (or similar) to check on
whether the submit has already been done: add some code for the
onSubmit event, and increment a counter.  Then if the counter is
already 1, just ignore the submit (return false, I think), or
even do a pop-up alert box saying the submission is already in
progress.

Just an idea.

-- 
Susan Cassidy
Remove xxx in replyto address when replying.


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

Date: 31 Mar 1998 19:02:50 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: small letters into capital letter
Message-Id: <6frekq$a8s$1@client3.news.psi.net>

and I can prove it! (jefpin@bergen.org) wrote on MDCLXXIII September
MCMXCIII in <URL: news:Pine.SGI.3.95.980331102143.11155A-100000@vangogh.bergen.org>:
++ >I4d like to transform small letters (saved in a variable) into capital
++ >letters.
++ 
++ You should look at the perlre man pages...
++ 
++ aw hell:
++ 	$word =~ tr/a-z/A-Z/;
++ is what you want.

No, it's not. That doesn't take locale into account.

         $word = uc $word;



Abigail
-- 
perl -pwle '$_ .= reverse'


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

Date: 31 Mar 1998 18:42:27 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Suppressing "used only once"
Message-Id: <6frdej$p49@news-central.tiac.net>

In article <352109BC.21FF@min.net>, John Porter  <jdporter@min.net> wrote:

>I have a similar situation, but opposite :-)
>
>In a .pm file, I have a bunch of "constants" being added to
>the main namespace, like so:
>
>	*MAXLEN = \256;
>
>and so on.
>Perl does not see this as a use of $MAXLEN, so in my program,
>if I use $MAXLEN only once -- I get that warning.

does

  use constant MAXLEN => 256;

which is possible with recent perls help at all?  They work pretty well
wherever you might have used $MAXLEN execpt in interpolation in qouble
quotes, but that's all covered in the podumentation.

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Tue, 31 Mar 1998 14:55:31 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Suppressing "used only once"
Message-Id: <35214A33.570E@min.net>

Mike Stok wrote:
> 
> In article <352109BC.21FF@min.net>, John Porter  <jdporter@min.net> wrote:
> 
> >In a .pm file, I have a bunch of "constants" being added to
> >the main namespace, like so:
> >       *MAXLEN = \256;
> 
> does
>     use constant MAXLEN => 256;
> which is possible with recent perls help at all?  They work pretty well
> wherever you might have used $MAXLEN execpt in interpolation in qouble
> quotes, but that's all covered in the podumentation.

In addition to that slight inconvenience, use constant also puts the 
subroutines in the package of the caller, which is not exactly what I
want.  I guess the work-around is trivial:

package Foo;

	{
	  package main;
	  use constant MAXLEN => 256;
	}

# back in Foo...


John Porter


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

Date: Tue, 31 Mar 1998 18:54:02 GMT
From: casteels@uia.ua.ac.be (Paul.Casteels)
Subject: Re: Win32::OLE and Word97
Message-Id: <Eqp5u2.Awv@uia.ua.ac.be>

Jan Dubois (jan.dubois@ibm.net) wrote:
: [mailed & posted]

: >$Word = Word->new('Word.Application', \&Quit);
: >$FileN = $Word->Documents->Add($CDTemplate);
: >$FileN->SaveAs('dada.doc');
: >
: >The last statement fails with
: >
: >OLE error 0x80020005: "Type does not match"
: >  in methodcall/getproperty "SaveAs" argument -4677756 at word.pl line 62
: >
: >What am I doing wrong ?

: I think I just understood your problem: You use Office 97 but don't have
: the Service Release 1 installed? There are serious bugs in the Word.8 type
: library, that are fixed in the SR1. For SaveAs you can use the WordBasic
: compatibility object as a workaround:

This is correct. Installing Service Release 1 solved my problem.
Many thanks to Jan Dubois.

	Paul Casteels (casteels@uia.ua.ac.be)


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 2217
**************************************

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