[15850] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3263 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 6 09:05:30 2000

Date: Tue, 6 Jun 2000 06:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <960296711-v9-i3263@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 6 Jun 2000     Volume: 9 Number: 3263

Today's topics:
        Accessing a secure server <rjk@fprsdev3.fmr.com>
        ActiveState mailing lists <borkur@netverk.net>
    Re: Any Zmodem module? dial, connect, upload and discon (Bbirthisel)
    Re: BerkeleyDB Installation <jeff@vpservices.com>
    Re: CRON + system <joeb@jagas.demon.co.uk>
    Re: END{} alternative? nobull@mail.com
        Extracting info from /etc/printcap scarey_man@my-deja.com
    Re: good perl coding style <you.will.always.find.him.in.the.kitchen@parties>
    Re: Help: OOPS Inheritance... nobull@mail.com
        How to copy Data structures? <Stefan.Etschberger@hl.siemens.de>
        how to write on a file? <arun67@yahoo.com>
    Re: how to write on a file? <rhomberg@ife.ee.ethz.ch>
    Re: how to write on a file? <red_orc@my-deja.com>
    Re: IP/port check help wanted nobull@mail.com
        matrix inverse? happyhippi@my-deja.com
    Re: matrix inverse? <michael.schlueter@philips.com>
    Re: Newbie needs help with search and replace nobull@mail.com
    Re: NEWBIE: Parsing strings with quoted items nobull@mail.com
    Re: Not shifting what I want from an array nobull@mail.com
        PERL+LATEX+WINDOWS+CGI <emadrazo@it.uc3m.es>
    Re: PERL+LATEX+WINDOWS+CGI (John Gehman)
    Re: problem with perl garbage collecting poppln@my-deja.com
    Re: s?printf and format output feature nobull@mail.com
        Splitting But NOT Splitting <roberty@idirect.com>
    Re: Splitting But NOT Splitting <abe@ztreet.demon.nl>
    Re: strict doesnt like array references <mc@backwoods.org>
    Re: strict doesnt like array references <flavell@mail.cern.ch>
    Re: strict doesnt like array references <abe@ztreet.demon.nl>
    Re: strict doesnt like array references <michael.schlueter@philips.com>
    Re: use DBI gnari@my-deja.com
    Re: use DBI <abe@ztreet.demon.nl>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 05 Jun 2000 15:45:21 -0400
From: Rick Meldrum <rjk@fprsdev3.fmr.com>
Subject: Accessing a secure server
Message-Id: <393C0351.5167@fprsdev3.fmr.com>

Hi;

I may be barking up the wrong tree here, but I need to access pasword
protected URL from my script.

Typically I would:
  open a socket, 
  "print SOCK"     my http request
  while (<SOCK>)   to read in the info I'm after.

Problem is, this won't work when a username and password are required.

Does any one have a workaround? 

Or can you recommend a better approach? (I suspect there's a module out
there...)

Any help will be most appreciated.

Thanks
Rick


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

Date: Tue, 6 Jun 2000 12:07:08 -0000
From: "Borkur Gudjonsson" <borkur@netverk.net>
Subject: ActiveState mailing lists
Message-Id: <393d4c40.0@news.isholf.is>

Does anyone know why ActiveState's mailing lists are down?
And, when will they be back up?

Borkur Gudjonsson





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

Date: 06 Jun 2000 12:50:32 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Any Zmodem module? dial, connect, upload and disconnect
Message-Id: <20000606085032.29184.00001864@ng-fd1.aol.com>

Hi John,

>I am looking for Perl programs or modules to transfer files
>through modem, but not found at CPAN.  Do any of you ever
>heard of such implementation (Win32 version preferred)?

No, and I am pretty sure none exists (yet). Occasionally, someone
requests it - but I don't have time to do it. I did look at the zmodem
source when I wrote Win32::SerialPort. It should be possible to add
zmodem file transfer - but it would be a lot of work. I would be willing
to help someone who wanted to take it on (start with xmodem first).

-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)


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

Date: Tue, 06 Jun 2000 09:03:51 -0400
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: BerkeleyDB Installation
Message-Id: <393CF6B7.8823FA1C@vpservices.com>

Larry Kasoff wrote:
> 
> "Aaron D." wrote:
> 
> > OK, I'm having a tough time with this and maybe somebody out there can
> > point me in the right direction.  I'm trying to install BerkeleyDB for
> > Activestate Perl.> 
> Use PPM when connected to the Internet.
> In your perl directory, type ppm.
> 
> ppm
> ppm>install DB_File
> ppm>quit
> 

Those are good instructions for installing the DB_File.pm module. 
Unfortunately they don't come close to working for the BerkeleyDB.pm 
module, which is entirely different.  So far, I have not heard of anyone
successfully installing the BerkeleyDB.pm module on ActiveState.  If
anyone has had success with that, please share.

-- 
Jeff


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

Date: Tue, 06 Jun 2000 11:40:11 +0100
From: JoeB <joeb@jagas.demon.co.uk>
Subject: Re: CRON + system
Message-Id: <393CD50B.2CF2B85C@jagas.demon.co.uk>

Thank you all.

It worked. I used the absolute path.

JoeB wrote:

> Hello All,
>
> Can anyone tell me if I can call the "system" function in a cron job?
> My script runs fine from the command line. Hoewver, as a cron job
> it doesn't. I have managed to narrow it down to "system" function call.
> Any Help will be appreciated.



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

Date: 05 Jun 2000 21:04:15 +0100
From: nobull@mail.com
Subject: Re: END{} alternative?
Message-Id: <u966rnqa6w.fsf@wcl-l.bham.ac.uk>

Hemant Shah <shah@typhoon.xnet.com> writes:

> Folks,
> 
>   Is there an alternative to END{} block. It is supposed to be the replacement
>   of POSIX atexit() function,

Not exactly.

> The end block is not yet called, why does it delete the lock directory?

END {} is a compile-time directive.

I usually get atexit() semantics using a global variable which is a
reference to an object with a destructor.  (This trick works not only
in Perl but just about any language with any degree of OO support).

> I am looking for something like a trap statement in Korn shell or an atexit()
> function in C.

I don't you really claim you are looking if you've not tried "perldoc -q atexit".

This mentions an AtExit module - I'd guess this uses the global
destructor trick.

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


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

Date: Tue, 06 Jun 2000 10:19:57 GMT
From: scarey_man@my-deja.com
Subject: Extracting info from /etc/printcap
Message-Id: <8hij83$mld$1@nnrp1.deja.com>

Is there a perl modules for getting information on print queues e.g.
Remote Port (rp), Remote Machine (rm), Spool Directory (sd) for a
specified queue?
If not, does anyone have a good way to extract the info?
Format of printcap file is:
#comment
dfps03|lp4|DFPS03:\
        :lf=/usr/adm/lp4err:\
        :lp=:\
        :rm=dfps03:\
        :rp=pr2:\
        :sd=/usr/spool/lpd4:
#comment
dfps11|lp6|DFPS11:\
        :lf=/usr/adm/lp6err:\
        :lp=:\
        :rm=dfps11:\
        :rp=9100:\
        :sd=/usr/spool/lpd6:


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


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

Date: Tue, 6 Jun 2000 23:13:32 +1200
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: good perl coding style
Message-Id: <960289911.825996@shelley.paradise.net.nz>


"W Kemp" <bill.kemp@wire2.com> wrote in message
news:960279422.516.0.nnrp-07.c3ad6973@news.demon.co.uk...
>
> brian d foy wrote in message ...
> >In article <8hhudb$85k$1@nnrp1.deja.com>, eastking@my-deja.com posted:
> >
> >> I am leading a team to develop a CGI application by perl. Because
> >> almost every member of this team is C programer,I need a coding
> >> sytle/rule. Although perl doc have some suggestion, I'd rather to
> >> listen more advise here. Thank in advance.
> >
> >this has been discussed to death in comp.infosystems.www.authoring.cgi:
> >
> >    http://www.deja.com/=dnc/getdoc.xp?AN=604082828
> >
> I think I read that thread, but an extra question comes to mind.
> A C++ programmer commented that 'perl is all the wrong way round'.
> Meaning he doesn't like this type of syntax:-
>
> "do something" if "test condition"
>
> rather than
>
> if (test condition){
>     "do something";
> }
>
> I suppose the second looks more like what a C programmer would expect.
> My question is - where did the first style come from? (is it in other
> languages). does it have any real advantages?

Six of one, half a dozen of the other.

You may prefer saying:

If I need milk, I'll go to the shop.

or

I'll go to the shop if I need milk.




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

Date: 05 Jun 2000 19:58:31 +0100
From: nobull@mail.com
Subject: Re: Help: OOPS Inheritance...
Message-Id: <u97lc3qa8f.fsf@wcl-l.bham.ac.uk>

echao@interaccess.com (Eisen Chao) writes:

> I need some help in setting up my very-first .PM
> and getting the inheritance to work right. Given:
> 
> HTMLStrip.pm
> -------------------------------------------
>    package HTMLStrip;
>    require Exporter;
>    @ISA         = qw( Exporter HTML::Parser );

>    "Can't locate object method "new" via package HTLMStrip" at
>     test1.pl line 5"
> 
> what am I missing here ?

You forgot to "require HTML::Parser" in HTMLStrip.

You can avoid the need for this by changing is as follows

>    require Exporter;
>    @ISA         = qw( Exporter HTML::Parser );

use base qw( Exporter HTML::Parser );

If you are thinking of HTMLStrip as an OO class you don't want
Exporter in there.  Modules based on Exporter are used to implement
libraries that have a non-OO-API.

echao@interaccess.com (Eisen Chao) writes:

> -------------------------------------------
>    package HTMLStrip;
>    require Exporter;
>    @ISA         = qw( Exporter HTML::Parser );
>    @EXPORT_OK   = qw ( $global_string );
> 
> test1.pl
> ----------------------------------------------
>    use HTMLStrip;
> 
>    $p = new HTMLStrip;
> 
>    print "-->$p::global_string<--";

Should be:

print "-->$HTMLStrip::global_string<--";

Hoever, using a global string is ugly.

The export stuff is superfluous anyhow as you are acessing
$global_string with an explicit package name.

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


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

Date: Tue, 06 Jun 2000 14:45:50 +0200
From: Stefan Etschberger <Stefan.Etschberger@hl.siemens.de>
Subject: How to copy Data structures?
Message-Id: <393CF27E.DC925F53@hl.siemens.de>

Hi all,

maybe someone can help me out....

I have a data structure like e.g.

$a = {
      "key1"  =>  {
                   "k1" => "string",
                   "k2" => [0,1,2]
                   },
      "key2"  =>   [
                    {"a" => "b"},
      [0,1,2]
                   ]
      }

or similar ones.

Is there an easy way (not traversing the whole
structure's hierarchy) to copy the structure
(building a new structure with the same contents
but not using the old adresses)?

Maybe there's a module i couldn't find?

Regards,
Stefan

--
__________________
stefan etschberger\__                                ______________________
infineon technologies\_________                  ___/department: dat tec ti
stefan.etschberger@infineon.com\________________/phone/fax +49 89/234-23720





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

Date: Tue, 06 Jun 2000 10:30:04 GMT
From: Arun Mahajan <arun67@yahoo.com>
Subject: how to write on a file?
Message-Id: <sjpklcoj2t5152@corp.supernews.com>

Hello,

I know it must be sound silly but i donot know how to write on a file. i 
was trying the following syntax but ofcourse with no resut.

I have the following html code where I want the moment user select the one 
of the option and submit it will increment the no of respondent, in the 
text file,  by one. Will anybody help me to provide me the logic here.

html file:-
-------------
<html>
<head></head>
<body>
<form action="/cgi-bin/add.cgi" method=post>
<input type="radio" name="gender" value="male">&nbsp;Male<br>
<input type="radio" name="gender" value="female">&nbsp;Female<br>
<input type="submit" value="Click Now"><input typr="reset">
</form>
</body>
</html>

perl code:-
-----------
#!/usr/bin/perl -w

&ReadParse(input);

open (ABC_FILE, ">text.txt") or die "can not find the file: $!";
print "increament the value of male or female, whatever selected with one";
close(ABC_FILE)

text file:-
-------------
male:0
female:0

Thanks in advance for the help.

Arun mahajan

--
Posted via CNET Help.com
http://www.help.com/


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

Date: Tue, 06 Jun 2000 13:17:57 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: how to write on a file?
Message-Id: <393CDDE5.EF1102E4@ife.ee.ethz.ch>

Arun Mahajan wrote:

> I have the following html code where I want the moment user select the one
> of the option and submit it will increment the no of respondent, in the
> text file,  by one. Will anybody help me to provide me the logic here.

> perl code:-
> -----------
> #!/usr/bin/perl -w
> 
> &ReadParse(input);
> 
> open (ABC_FILE, ">text.txt") or die "can not find the file: $!";
> print "increament the value of male or female, whatever selected with one";
> close(ABC_FILE)
> 
> text file:-
> -------------
> male:0
> female:0

Start your CGI file with

#!/usr/bin/perl -wT
use strict;
use CGI;

Read the perlsec and CGI manpages for more information
Your problem is very similar to a counter, there is one in the faq
see perldoc -q locking

- Alex


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

Date: Tue, 06 Jun 2000 12:24:09 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: how to write on a file?
Message-Id: <8hiqgp$rfm$1@nnrp1.deja.com>

In article <sjpklcoj2t5152@corp.supernews.com>,
  Arun Mahajan <arun67@yahoo.com> wrote:
> Hello,
>
> I know it must be sound silly but i donot know how to write on a file.
> i was trying the following syntax but ofcourse with no resut.
>
> perl code:-
> -----------
> #!/usr/bin/perl -w
>
> &ReadParse(input);
>
> open (ABC_FILE, ">text.txt") or die "can not find the file: $!";
> print "increament the value of male or female, whatever selected with
one";

this print needs filehandle (ABC_FILE):

print ABC_FILE "increament the value of male or female, whatever
selected with one";

> close(ABC_FILE)

this line needs semi-colon at the end.


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


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

Date: 05 Jun 2000 19:34:35 +0100
From: nobull@mail.com
Subject: Re: IP/port check help wanted
Message-Id: <u98zwjqa9o.fsf@wcl-l.bham.ac.uk>

"Helza" <helza@planet.nl> writes:

> How do i make a quick ip/port check to see if the server is online?

You can't, this has nothing to do with Perl.

If you send an IP packets to a machine that isn't there you can only
infer that the machine isn't there if it fails to respond to several
packets.

> Currently i use this code:
> 
> #!/usr/bin/perl
> 
> use Socket;

Do yourself a favour and start using IO::Socket - it encapsulates all
the messy stuff for you (including timeouts) in a nice neat object. 

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


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

Date: Tue, 06 Jun 2000 10:57:13 GMT
From: happyhippi@my-deja.com
Subject: matrix inverse?
Message-Id: <8hile5$o46$1@nnrp1.deja.com>

Hola!
I was wondering if there is a module, script or library for matrix
functions. Most of all I'll need matrix inverse but also determinant and
adjungation would be useful.

thanks


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


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

Date: Wed, 7 Jun 2000 01:45:35 +0200
From: "Michael Schlueter" <michael.schlueter@philips.com>
Subject: Re: matrix inverse?
Message-Id: <8hio9o$dj7$1@porthos.nl.uu.net>

You could use Math::MatrixReal from CPAN. Or you could link existing
C-libraries on matrix inversion.




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

Date: 05 Jun 2000 21:41:18 +0100
From: nobull@mail.com
Subject: Re: Newbie needs help with search and replace
Message-Id: <u94s77qa37.fsf@wcl-l.bham.ac.uk>

Marco Natoni <blah@nospam.com> writes:

> Neil,
> 
> Neil Watson wrote:
> > I have a file that has lines similar to (each line is spaced 
> > the same):
> 
> 	[snip]
>  
> > I want to replace the 0A0 at the end of the line with 0S0 on any 
> > line that begins with PSteel. I wrote this script:
> >
> > #/usr/local/bin/perl -w -p
> > s/(PSteel[0-9]{4,5}[A-Z]?\sA\s[0-9]{16})0A0\n/\10S0\n/g

s/^(PSteel.*)0A0$/\10S0/;

> > I receive no errors yet no replacements are made.  
> 
>   I am sure that I/O handling has been snipped out from your code.


Nope, its all there, both characters of it '-p'

Except the shebang line (#!) can only accept a single word after the
interpreter name.

Change '-w -p' to '-wp'

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


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

Date: 05 Jun 2000 22:04:57 +0100
From: nobull@mail.com
Subject: Re: NEWBIE: Parsing strings with quoted items
Message-Id: <u93dmrqa10.fsf@wcl-l.bham.ac.uk>

Mark Miller <mark@chalkboardcom.com> writes:

>Subject: NEWBIE: Parsing strings with quoted items
          ^^^^^^ 

Good subject line, you should note that "NEWBIE" in this context will
be read (correctly) by most people as "I've not checked the FAQ".  A
better idea would be the read the FAQ first and drop the "NEWBIE" bit.

> I'm trying to parse a string into individual words and phrases in
> quotes.

Please see the answer given to a very similar this question in the FAQ
where the quotes are not to be preserved.   Make the necessary
ammendment (move quotes inside parentheses).

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


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

Date: 05 Jun 2000 22:14:45 +0100
From: nobull@mail.com
Subject: Re: Not shifting what I want from an array
Message-Id: <u9zoozovcn.fsf@wcl-l.bham.ac.uk>

Tina Mueller <tina@streetmail.com> writes:

> i made a little mistake; maybe you recognized:
> >>
> >>while(<@a>) {
> 
> this should be:
> while(<@lines>) {

No, it should be:

for(@lines) {

If you do:

while(<@lines>) {

This is like doing:

for (split /s+/ => pipeopen("echo @lines")) {

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


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

Date: Tue, 06 Jun 2000 12:00:11 +0200
From: Diane <emadrazo@it.uc3m.es>
Subject: PERL+LATEX+WINDOWS+CGI
Message-Id: <393CC796.C8D3C969@it.uc3m.es>

Hello,
Perphaps someone can help me. I am programming a CGI for generating some
documentation. The information is retrived from a database (oracle). And
this generation is doing through web service. I have a HTML page with a
form for select the documentation to generate, and this form call a cgi
program. Well, this cgi program generates a .tex file, and I want to
compile this .tex (I have a latex version installed in the server) and
return a HTML page with a link to the .ps file.  The server is a Windows
NT.

I have a problem  compiling the .tex. I have used a call to
system('latex document.tex') and then another system('dvips
document.dvi') and the navigator return a  'save as..' window instead
the html page. I know that this happen because the call to system prints
the response to the html page. So I tried system('latex document.tex >
latex.tmp') but the response was the same. I cant use exec() because it
doesn't return. Any idea??

A lot of thanks!



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

Date: 6 Jun 2000 11:56:55 GMT
From: jdg28@pantheon.yale.edu (John Gehman)
Subject: Re: PERL+LATEX+WINDOWS+CGI
Message-Id: <8hiou7$rgs$1@news.ycc.yale.edu>

I think all the perl/CGI stuff is a separate issue, and that at least
your system call must go as 

system('latex','file.tex');

then

system('dvips','-o','file.ps','file.dvi');

At least that's how I'd need to do it under linux. Maybe system calls
under M$ are different, but I've had issues when I did not put each
discreet command-line element in quotes unto itself.

j.

Diane (emadrazo@it.uc3m.es) wrote:
: Hello,
: Perphaps someone can help me. I am programming a CGI for generating some
: documentation. The information is retrived from a database (oracle). And
: this generation is doing through web service. I have a HTML page with a
: form for select the documentation to generate, and this form call a cgi
: program. Well, this cgi program generates a .tex file, and I want to
: compile this .tex (I have a latex version installed in the server) and
: return a HTML page with a link to the .ps file.  The server is a Windows
: NT.

: I have a problem  compiling the .tex. I have used a call to
: system('latex document.tex') and then another system('dvips
: document.dvi') and the navigator return a  'save as..' window instead
: the html page. I know that this happen because the call to system prints
: the response to the html page. So I tried system('latex document.tex >
: latex.tmp') but the response was the same. I cant use exec() because it
: doesn't return. Any idea??

: A lot of thanks!



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

Date: Tue, 06 Jun 2000 12:36:58 GMT
From: poppln@my-deja.com
Subject: Re: problem with perl garbage collecting
Message-Id: <8hir98$s7p$1@nnrp1.deja.com>

In article <8h8g21$15q$1@charm.magnus.acs.ohio-state.edu>,
  ilya@math.ohio-state.edu (Ilya Zakharevich) wrote:
> [A complimentary Cc of this posting was sent to
> <poppln@my-deja.com>],
> who wrote in article <8h856d$evn$1@nnrp1.deja.com>:
> > > Even if the debugger is run non-interactively in non-stop mode?
> >
> > How do you run the debugger non-interactively?
>
>   perldoc perldebug
>
> > > If yes, try to fiddle with bits of $^P until you can reproduce the
> > > change without -d.  Keep in mind that with a Perl so old directly
> > > fiddling with a couple of bits of $^P would lead to a segfault.
[But
> > > you will find them soon enough. ;-]
> >
Well $^P didn't help. what ever I tried either caused a core dump or
the script worked but with the garbage collecting problem.

However, setting PERLDB_OPTS='N' before running the script with perl -
wd DID solve the problem :)

Thanks for your help!

  Nadav.


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


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

Date: 05 Jun 2000 22:08:35 +0100
From: nobull@mail.com
Subject: Re: s?printf and format output feature
Message-Id: <u91z2bq9zk.fsf@wcl-l.bham.ac.uk>

mike@mix.nordlink.ru (Michael Kichanov) writes:

> Please explain how to fix this floating point rounding feature
> while using sprintf,printf and format (.##) output:
> sprintf("%.2f", 1.555) == 1.55 (should be 1.56)
> sprintf("%.2f", 0.555) == 0.56 (everything here is correct)

> How to resolve this problem?

You can't (in general).  See "perldoc -q round".  Actually this
problem is inherent in using floating point and has little to do with
Perl.

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


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

Date: Tue, 06 Jun 2000 11:49:17 GMT
From: "Robert Young" <roberty@idirect.com>
Subject: Splitting But NOT Splitting
Message-Id: <1z5%4.273752$Kv2.574593@quark.idirect.com>

Can anyone give me a regular expression to perform a split where the
expression is split on a character unless the character is preceded by a
backslash (\) ?





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

Date: Tue, 06 Jun 2000 14:58:57 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Splitting But NOT Splitting
Message-Id: <f4tpjsk8o1ksf1hjsvf662scmqi6fdfjtk@4ax.com>

On Tue, 06 Jun 2000 11:49:17 GMT, "Robert Young" <roberty@idirect.com>
wrote:

> Can anyone give me a regular expression to perform a split where the
> expression is split on a character unless the character is preceded by a
> backslash (\) ?

#!/usr/bin/perl -w
use strict;

$_ = 'this,is separated,on \, (comma),etc.';

my @result = split /(?<!\\),/;

print "$_\n", map "$_\n" => @result;
__END__

perldoc perlre
look for 'negative look-behind'

-- 
Good luck,
Abe


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

Date: Tue, 06 Jun 2000 07:54:53 -0400
From: MC <mc@backwoods.org>
Subject: Re: strict doesnt like array references
Message-Id: <393CE68D.54D561BF@backwoods.org>

Well, two of you seem to have totally missed the point of the question. However
from the various posts, and in particular Mark's (below) I have worked it w/o
the reference as follows (with strict on)....

sample code:

use strict;
my @ar_one = qw( this is a test );
my @ar_two = qw( hello world );
my $which = "ar_two"; # might be "ar_one" or "ar_two"
print @{($which eq "ar_one") ? @ar_one : @ar_two}[1];
## prints either "is" or "world"

actual code:
before: ($item) = grep(/^$order{item}$x/,(@{$order{db}});
after:  ($item) = grep(/^$order{item}$x/,($order{db} eq
"beanie")?@beanie:@pokemon);

actual code clip:
(have fun guys, yes this works... very nicely... comments welcome)

## my (%dbs, %order, $item, @beanie, @pokemon);
## my $x ## defines field separator in record;
## $dbs{ --database-- }{fields} is an anonymous array of fieldnames
##       created dynamicly on script load from file definitions

## parse string from 'orders' flatfile database into hash with field names
@order{@{$dbs{orders}{fields}}} = split($x,$_);
## use field from resulting hash to get record from appropriate stock database
($item) = grep(/^$order{item}$x/,($order{db} eq "beanie")?@beanie:@pokemon);
## parse record from stock database into hash with field names
@item{@{$dbs{$order{db}}{fields}}} = split($x,$item);

MC

Mark Holt wrote:
> 
> you are using symbolic references.  And this is forbidden by 'use strict'.  There is
> usually a way to program without symbolic references, but if not, do as it says below
> and wrap the offending code thus:
> no strict 'refs';
> --code--
> use strict 'refs';
> 
> Makarand Kulkarni wrote:
> 
> > > when i add "use strict". in the actual script, i have two arrays which i need to
> > > select between arbitrarily based on another variable. is there some way i can do
> > > this and still keep strict? other than using an if/then/else structure?
> > >
> >
> > use strict;
> > no strict 'refs' ;
> >
> > or else perl thinks you are using symbolic referecnes.

-- 
---------------------------------------------------------------------
My email address(s) are my private property.  They are NOT to be used
or recorded for ANY reason without my explicit permission.  Disregard
of this statement is in violation of federal privacy & copyright law.
---------------------------------------------------------------------
The new Decade/Century/Millennium doesnt start until the year 2001 !!
Lets make the year 2000, the last year of the Millennium, a good one!
--------------------------------------------+------------------------
                                            |
       <-- THIS SPACE FOR RENT -->          |    Question Reality
         advertise~backwoods.org            |
                                            |
     Time is nature's way of keeping        |  If at first you don't
     everything from happening at once      |  succeed...  REBOOT!
                                            |
--------------------------------------------+------------------------


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

Date: Tue, 6 Jun 2000 14:02:33 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: strict doesnt like array references
Message-Id: <Pine.GHP.4.21.0006061400490.21459-100000@hpplus03.cern.ch>

On Tue, 6 Jun 2000, MC wrote:

> Well, two of you seem to have totally missed the point of the question.

I think you meant to say "I apologise for posting such an incoherent
question that two people wasted their valuable time on answering
something else than what I had in mind" HTH.



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

Date: Tue, 06 Jun 2000 14:20:02 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: strict doesnt like array references
Message-Id: <snqpjscl08uqi4qdatool5rkk88qkaqvaa@4ax.com>

On Tue, 6 Jun 2000 21:48:25 +0200, "Michael Schlueter"
<michael.schlueter@philips.com> wrote:

> @$rl is the same as @($rl).
Nope, that's a syntax error. You should use curlies:
	@{$rl}
>                                                 $$rl[2] is the same as
> $($rl)[2] which has the same effect as $array[2].
Again that's ${$rl}[2]

If you don't like the curlies you can use the 'arrow':
	$rl->[2]
It looks cleaner to me too.

-- 
Good luck,
Abe


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

Date: Wed, 7 Jun 2000 02:47:22 +0200
From: "Michael Schlueter" <michael.schlueter@philips.com>
Subject: Re: strict doesnt like array references
Message-Id: <8hirtj$ft1$1@porthos.nl.uu.net>

Abe,

You're right on the parantheses.


Abe Timmerman <abe@ztreet.demon.nl> wrote in message
news:snqpjscl08uqi4qdatool5rkk88qkaqvaa@4ax.com...
> On Tue, 6 Jun 2000 21:48:25 +0200, "Michael Schlueter"
> <michael.schlueter@philips.com> wrote:
>
> > @$rl is the same as @($rl).
> Nope, that's a syntax error. You should use curlies:
> @{$rl}
> >                                                 $$rl[2] is the same as
> > $($rl)[2] which has the same effect as $array[2].
> Again that's ${$rl}[2]
>
> If you don't like the curlies you can use the 'arrow':
> $rl->[2]
> It looks cleaner to me too.
>
> --
> Good luck,
> Abe
>




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

Date: Tue, 06 Jun 2000 10:00:26 GMT
From: gnari@my-deja.com
Subject: Re: use DBI
Message-Id: <8hii3m$luu$1@nnrp1.deja.com>

In article <8hh78j$ncd$1@nnrp1.deja.com>,
  beer_girl@bigfoot.com wrote:
> here's the code:
>
> use DBI;
> ($db) = DBI->connect('DBI:mysql:DatabaseName, $dbusername);
>
> here's the corresponding errors:
> syntax error in file ParseEmail.cgi at line 66, next 2 tokens "use
DBI"
> syntax error in file ParseEmail.cgi at line 82, next 2 tokens "->"
>
how about posting a little more code?
seems to me that the error message is implying that there is a
syntax error just prior to the "use DBI"

gnari


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


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

Date: Tue, 06 Jun 2000 13:39:24 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: use DBI
Message-Id: <c0opjso6a562en9n5rfebti4kit8i4g0ii@4ax.com>

On Mon, 05 Jun 2000 21:49:14 GMT, beer_girl@bigfoot.com wrote:

> I wrote a perl script that accesses mySQL and the script is executed
> through a web browser (and it works great).  Now I need to run it from
> the command line and I get all kinds of syntax errors.  Some of them
> are:
> 
> here's the code:
> 
> use DBI;
> ($db) = DBI->connect('DBI:mysql:DatabaseName, $dbusername);
> 
> 
> here's the corresponding errors:
> syntax error in file ParseEmail.cgi at line 66, next 2 tokens "use DBI"
> syntax error in file ParseEmail.cgi at line 82, next 2 tokens "->"
I can't find that error in perldiag.
What does 'perl -v' report?

> All this works just great if it's run through a web browser.  What's
> going on?!?
Could there be another (old) perl on your system?


-- 
Good luck,
Abe


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 3263
**************************************


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