[18267] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 435 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 7 14:06:09 2001

Date: Wed, 7 Mar 2001 11:05:21 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983991920-v10-i435@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 7 Mar 2001     Volume: 10 Number: 435

Today's topics:
        "uninitiatlized value" errors? <jazrant@zsc.nrcan.zc.ca>
    Re: "uninitiatlized value" errors? (Tad McClellan)
        A problem with $SIGs <igor_aptekar@programmer.net>
        Am I a naughty perl coder? <jhall@ifxonline.com>
    Re: Am I a naughty perl coder? <julien.quint@imag.fr>
    Re: Am I a naughty perl coder? (Jon Bell)
    Re: Am I a naughty perl coder? <shanem@ll.mit.edu>
    Re: cookie <parrot0123@yahoo.ca>
    Re: cookie (Rafael Garcia-Suarez)
        Defining Global Script Variables <jmowat@digitalpraxis.com>
        Emacs modules for Perl programming (Jari Aalto+mail.perl)
    Re: flock and close   with  empty read strangeness <mischief@velma.motion.net>
    Re: Grokking map and grep (Philip Lees)
    Re: Grokking map and grep (Randal L. Schwartz)
    Re: Grokking map and grep <mischief@velma.motion.net>
    Re: HELP needed: using regular expressions (regex; rege (Tad McClellan)
    Re: HELP needed: using regular expressions (regex; rege <ekliao@pacbell.net>
    Re: Help to Install Perl <suzanne@campustech.com>
    Re: Help to Install Perl (Glyndwr)
    Re: Help to Install Perl <suzanne@campustech.com>
        How do I combine filehandles, refs and strict? <stop@statoil.com>
    Re: is there a better way ? (Anno Siegel)
    Re: Perl CGI.pm RESET problem <idontreadthis56@hotmail.com>
    Re: Perl CGI.pm RESET problem <godzilla@stomp.stomp.tokyo>
    Re: Perl Newbie ??? <john@particlewave.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 7 Mar 2001 10:24:17 -0500
From: "John A. Grant" <jazrant@zsc.nrcan.zc.ca>
Subject: "uninitiatlized value" errors?
Message-Id: <985jul$hb611@nrn2.NRCan.gc.ca>

I'm using "strict" and "perl -c" is ok. My program works fine,
but when I use -w, I get these warnings. Even with "diagnostics",
I don't understand it.

1547:  my $lastslash=rindex($filename,"/");
1548: if($lastslash){
Use of uninitialized value in rindex at contact.cgi line 1547.
Use of uninitialized value in substr at contact.cgi line 1548.

1704:    if($method eq "POST"){
Use of uninitialized value in string eq at contact.cgi line 1704.
Use of uninitialized value in string eq at contact.cgi line 1704.

100:    my $MAGIC_XXX="!";
1639:    if (substr($message,0,1) eq $MAGIC_XXX){
Use of uninitialized value in string eq at contact.cgi line 1639.

On reflection, I see I've used both "==" and "eq" in my program.
for strings, i.e.:
    if($xxx=="hello")
    if($xxx eq "hello")

Can someone explain the difference?  I normally use C++, so
this is a bit weird for me.

Also, how do I redirect the "-w" output to a file? I'm using Active
Perl 5.6 on NT and I can do it like this:
    > perl -w myapp.cgi 2>err

But 2>err doesn't work on my solaris box (also running perl 5.6)

Thanks.

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here





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

Date: Wed, 07 Mar 2001 16:08:01 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: "uninitiatlized value" errors?
Message-Id: <slrn9ack2f.9vo.tadmc@tadmc26.august.net>

John A. Grant <jazrant@zsc.nrcan.zc.ca> wrote:
>I'm using "strict" and "perl -c" is ok. My program works fine,
>but when I use -w, I get these warnings. Even with "diagnostics",
>I don't understand it.


When perl says "uninitialized value" you should think "undef".

You are using the special "undef" value somewhere in your program.


>1547:  my $lastslash=rindex($filename,"/");
>1548: if($lastslash){
>Use of uninitialized value in rindex at contact.cgi line 1547.
>Use of uninitialized value in substr at contact.cgi line 1548.


Looks like $filename got the undef value somehow.


>On reflection, I see I've used both "==" and "eq" in my program.
>for strings, i.e.:
>    if($xxx=="hello")


Aren't you getting a warning about "isn't numeric" there?


>    if($xxx eq "hello")
>
>Can someone explain the difference?  I normally use C++, so
>this is a bit weird for me.


Use == to compare numbers.

Use eq to compare strings.

Your first example is a bug in your program. Enabling warnings
has uncovered a bug for you. Better fix it :-)

The first example converts both operands to numbers (because it
is a numeric operator). Due to the rules used for converting,
most strings will convert to the number zero, so the test will
nearly always be "true" ( 0 == 0 ).  Not what you want.


>Also, how do I redirect the "-w" output to a file? I'm using Active
>Perl 5.6 on NT and I can do it like this:
>    > perl -w myapp.cgi 2>err
>
>But 2>err doesn't work on my solaris box (also running perl 5.6)
                              ^^^^^^^

The OS is not an issue, the _shell_ used may be the issue though.

That should work in Bourne-ish shells. 

Were you perhaps using a csh-ish shell instead?


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


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

Date: Wed, 7 Mar 2001 16:32:06 -0000
From: "Igor Aptekar" <igor_aptekar@programmer.net>
Subject: A problem with $SIGs
Message-Id: <Hqtp6.21$HR6.5747@nnrp4.clara.net>

I am using the following code

$SIG{"__DIE__"} = $SIG{"__WARN__"} = \&dead;

I have Active perl 5.2 and windows 2000.

The above causes the following error

Can't locate SetDualVar.pm in @INC (@INC contains:
C:/Applications/Development/Perl/ActivePerl522/lib
C:/Applications/Development/Perl/ActivePerl522/site/lib .) at
C:/Applications/Development/Perl/ActivePerl522/site/lib/Win32/TieRegistry.pm
line 42.



do i need to install SetDualVar.pm? or is there something more i need to do



thanks





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

Date: Wed, 07 Mar 2001 18:12:33 GMT
From: "John Hall" <jhall@ifxonline.com>
Subject: Am I a naughty perl coder?
Message-Id: <lSup6.11304$o7.347896@news1.rdc1.sdca.home.com>


One of the first pieces of code I 'borrowed' spit out html pages by using
this method:


_________________________________
$text = <<HTML;

<br><br>
<font "arial">HTML goes here with embedded $variables etc... Doesn't need to
be "escaped" \ because as far as i can tell it's within a debugging
function?</font><br><br>

HTML

print header();
print $text;
_________________________________

So this works fine, but I can't really find a good description of what i'm
actually doing in any of my books. It looks like i'm using some debugging
stuff as actually part of the program? Is that correct? if so, should I not
do it? Or is it something that's been deprecated?






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

Date: 07 Mar 2001 19:25:04 +0100
From: Julien Quint <julien.quint@imag.fr>
Subject: Re: Am I a naughty perl coder?
Message-Id: <khvg0gph1xb.fsf@imag.fr>

"John Hall" <jhall@ifxonline.com> writes:

> So this works fine, but I can't really find a good description of what i'm
> actually doing in any of my books. It looks like i'm using some debugging
> stuff as actually part of the program? Is that correct? if so, should I not
> do it? Or is it something that's been deprecated?

You might be interested about reading about Perl syntax in general, and
variable interpolation in string in particular.

[Not related to Perl:] And please do not use font tags.

-- 
Julien


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

Date: Wed, 7 Mar 2001 18:38:17 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Am I a naughty perl coder?
Message-Id: <G9uBrt.C7q@presby.edu>

In article <lSup6.11304$o7.347896@news1.rdc1.sdca.home.com>,
John Hall <jhall@ifxonline.com> wrote:
>
>One of the first pieces of code I 'borrowed' spit out html pages by using
>this method:
>
>
>_________________________________
>$text = <<HTML;
>
><br><br>
><font "arial">HTML goes here with embedded $variables etc... Doesn't need to
>be "escaped" \ because as far as i can tell it's within a debugging
>function?</font><br><br>
>
>HTML
>
>print header();
>print $text;
>_________________________________
>
>So this works fine, but I can't really find a good description of what i'm
>actually doing in any of my books. It looks like i'm using some debugging
>stuff as actually part of the program? 

Look up the term "here document" in the indexes of your books.  It's a 
standard Perl thing and rather commonly used.  In fact, the variable $text 
isn't necessary; you can just as well write

  print header();
  print <<HTML;

  blah blah blah

  HTML

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA


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

Date: Wed, 07 Mar 2001 13:43:42 -0500
From: Shane McDaniel <shanem@ll.mit.edu>
Subject: Re: Am I a naughty perl coder?
Message-Id: <3AA6815E.9000C410@ll.mit.edu>

The 

<<HTML;
 ......
HTML

is called a "here" document.  Basically it prints everything between the
<<MYTITLE; and MYTITLE without using the print function.  MYTITLE can be
anything as long as it is the same in both spots, and the ; at the end
of the firt MYTITLE is important.

John Hall wrote:
> 
> One of the first pieces of code I 'borrowed' spit out html pages by using
> this method:
> 
> _________________________________
> $text = <<HTML;
> 
> <br><br>
> <font "arial">HTML goes here with embedded $variables etc... Doesn't need to
> be "escaped" \ because as far as i can tell it's within a debugging
> function?</font><br><br>
> 
> HTML
> 
> print header();
> print $text;
> _________________________________
> 
> So this works fine, but I can't really find a good description of what i'm
> actually doing in any of my books. It looks like i'm using some debugging
> stuff as actually part of the program? Is that correct? if so, should I not
> do it? Or is it something that's been deprecated?


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

Date: Wed, 07 Mar 2001 14:06:08 GMT
From: "Parrot" <parrot0123@yahoo.ca>
Subject: Re: cookie
Message-Id: <kfrp6.327552$Pm2.4828988@news20.bellglobal.com>

Waarddebon <Waarddebon@chello.nl> wrote in message
news:i_qp6.1864616$%C1.24086918@Flipper...
> If i set up a cookie like this:
> <script language="javascript>SetCookie: (name=dewaard)</script>
>
> I can read it out with this :
>
> read (STDIN,$buffer, $ENV{'CONTENT_LENGTH'});
> @pairs=split(/&/, $buffer);
> foreach $pair(@pairs) {
> local ($name, $value)= split (/=/, $pair);
> $value=! tr/+/ /;
> $value=~ s/% ([a-fA-F0-9] [a-fA-F0-9])/pack("C",hex($1))/eg;
> $value=~ s/<!--(.|\n)*-->//g;
> $in{$name}=$value;}
>
> But somehow it doesn't work, who can help me out ?
>

A question just occured to me : Why are you setting your cookies in
Javascript and reading them in Perl?




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

Date: Wed, 07 Mar 2001 14:24:18 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: cookie
Message-Id: <slrn9ach45.thu.rgarciasuarez@rafael.kazibao.net>

Parrot wrote in comp.lang.perl.misc:
> 
> Waarddebon <Waarddebon@chello.nl> wrote in message
> news:i_qp6.1864616$%C1.24086918@Flipper...
> > If i set up a cookie like this:
> > <script language="javascript>SetCookie: (name=dewaard)</script>
> >
> > I can read it out with this :
> >
> > read (STDIN,$buffer, $ENV{'CONTENT_LENGTH'});
> > @pairs=split(/&/, $buffer);
> > foreach $pair(@pairs) {
> > local ($name, $value)= split (/=/, $pair);
> > $value=! tr/+/ /;
> > $value=~ s/% ([a-fA-F0-9] [a-fA-F0-9])/pack("C",hex($1))/eg;
> > $value=~ s/<!--(.|\n)*-->//g;
> > $in{$name}=$value;}
> >
> > But somehow it doesn't work, who can help me out ?
> 
> This should help you, it's code to retrieve all the cookies you've sent:
> 
> sub getCookies {
>  # cookies are seperated by a semicolon and a space, this will split
>  # them and return a hash of cookies
>  local(@rawCookies) = split (/; /,$ENV{'HTTP_COOKIE'});
>  local(%cookies);
> 
>  foreach(@rawCookies){
>      ($key, $val) = split (/=/,$_);
>      $cookies{$key} = $val;
>  }
> 
>  return %cookies;
> }

The code posted by the OP is apparently intended to read (more or less)
the POST parameters of the HTTP request. However it has several bugs that
will prevent it to run correctly.

Your getCookies function is a bit better, because it can actually work
in some specific cases. Note that you should not use local() in this
context. You should also decode url-encoded values in the cookie
environment variable.

But, instead of reinventing the wheel, and not a good one, you should
use one of the modules that people made just for this case: I suggest
CGI or CGI::Cookie. Good modules; easy to use; both of them are
standard, i.e. they come with any decently recent version of Perl.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 07 Mar 2001 18:51:39 GMT
From: "Jason Mowat" <jmowat@digitalpraxis.com>
Subject: Defining Global Script Variables
Message-Id: <%qvp6.1299$4x6.23673@news2.mts.net>

Greets,

I am wondering what is the best way to set up global defines in Perl.  I
would like to have a centralized configuration file that contains all of my
"user settable" variables, so that I don't have to hard code them in the
scripts.  I am using Perl object classes, and I'm not sure what the best way
to do this is.

In PHP, another language I am working with, I created a centralized DEFINES
file, and using the PHP 'define' function, was able to set my script
variables to the values in this centralized file.  For example:
define("LDAP_SERVER_IP", "192.168.0.1");  I can now make references to
$LDAP_SERVER_IP in my scripts with the information only being set in a
single spot.

What is the best way to do this in Perl, IYO?

Cheers,
Jason






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

Date: 07 Mar 2001 17:39:29 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_983986693@rtfm.mit.edu>

Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto <jari.aalto@poboxes.com>

Announcement: "What Emacs lisp modules can help with programming Perl"

    Preface

        Emacs is your friend if you have to do anything comcerning software
        development: It offers plug-in modules, written in Emacs lisp
        (elisp) language, that makes all your programmings wishes come
        true. Please introduce yourself to Emacs and your programming era
        will get a new light.

    Where to find Emacs/XEmacs

        o   Unix:
            http://www.gnu.org/software/emacs/emacs.html
            http://www.xemacs.org/

        o   Windows
            http://www.gnu.org/software/emacs/windows/ntemacs.html
	    ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe

	o   More Emacs resources at 
	    http://tiny-tools.sourceforge.net/emacs-elisp.html


Emacs Perl Modules

    Cperl -- Perl programming mode

        .ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
        .<olson@mcs.anl.gov>           Bob Olson (started 1991)
        .<ilya@math.ohio-state.edu>    Ilya Zakharevich

        Major mode for editing perl files. Forget the default
        `perl-mode' that comes with Emacs, this is much better. Comes
        standard in newest Emacs.

    TinyPerl -- Perl related utilities

	.http://tiny-tools.sourceforge.net/

        If you ever wonder how to deal with Perl POD pages or how to find
        documentation from all perl manpages, this package is for you.
        Couple of keystrokes and all the documentaion is in your hands.

        o   Instant function help: See documentation of `shift', `pop'...
        o   Show Perl manual pages in *pod* buffer
        o   Load source code into Emacs, like Devel::DProf.pm
        o   Grep through all Perl manpages (.pod)
        o   Follow POD manpage references to next pod page with TinyUrl
        o   Coloured pod pages with `font-lock'
        o   Separate `tiperl-pod-view-mode' for jumping topics and pages
            forward and backward in *pod* buffer.
        o   TinyUrl is used to jump to URLs (other pod pages, man pages etc)
            mentioned in POD pages. (It's a general URL minor mode)

    TinyIgrep -- Perl Code browsing and easy grepping

        [TinyIgrep is included in the Kit]

        To grep from all installed Perl modules, define database to
        TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
        how to set up datatbases for Perl5, Perl4 whatever you have
        installed

        TinyIgrep calls Igrep.el to run the find for you, You can adjust
        recursive grep options, ignored case, add user grep options.

        You can get `igrep.el' module from <kevinr@ihs.com>. Ask for copy.
	Check also ftp://ftp.ihs.com/pub/kevinr/

    TinyCompile -- Browsing grep results in Emacs *compile* buffer

        TinyCompile is minor mode for *compile* buffer from where
        you can collapse unwanted lines, shorten the file URLs

            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT

            -->
            cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
            file1:NNN: MATCHED TEXT
            file1:NNN: MATCHED TEXT

End



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

Date: Wed, 07 Mar 2001 18:04:08 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <tacu0oil7eja5b@corp.supernews.com>

Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> On Tue, 06 Mar 2001 20:05:58 -0500,
> 	ZepHead <groovyt@erols.com> wrote:
>> In article <slrn9a9anu.efn.mgjv@martien.heliotrope.home>,
>>  mgjv@tradingpost.com.au (Martien Verbruggen) wrote:
>>> 
>>> sysopen FH, $name, O_WRONLY|O_CREAT;
>> 
>> we still have not figured out if we should just 
>> use sysopen or add to open like  Bart? suggested
>> using +<<  (which I like)


>> I mean there has to be reason this was not included
>> with open , right?   could this just be a simple over sight?


> I suspect that C<open> is modelled on fopen(3), and fopen doesn't
> provide this mode. C<sysopen> is modelled on open(2), which does
> provide a combination of flags that support this.  Changing C<open> to
> accept this argument would mean you'd need to check for that case
> especially, and you'd need to make a system call, instead of a library
> call.

> I'm not even sure whether it would be possible to implement this on
> all platforms Perl runs on. Apart from needing a decent C library,
> you'd now also need a decent POSIX library, or a system call that can
> do the equivalent of open(2).

This sounds like a perfectly valid reason to me. Forcing Perl's open()
to conditionally use fopen(3) or open(2) depending on flags would be
a horrible, costly hack anyway. Better to let the Perl programmer do
some programming than to get the core to give us everything. This
reminds me of Abigail's quote, "By promoting postconditions to
preconditions, algorithms become remarkably simple."


Chris

-- 
Christopher E. Stith
People understand instinctively that the best way for computer programs to
communicate with each other is for each of the them to be strict in what they
emit, and liberal in what they accept. The odd thing is that people themselves
are not willing to be strict in how they speak, and liberal in how they listen.
 -- Larry Wall, 2nd State of the Onion Address, August 1998



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

Date: Wed, 07 Mar 2001 14:10:43 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Grokking map and grep
Message-Id: <3aa640e6.88531781@news.grnet.gr>

On Wed, 07 Mar 2001 12:57:01 GMT, pjlees@ics.forthcomingevents.gr
(Philip Lees) wrote:

>Ah, now I get it. I had somehow overlooked the second $_ in the 
>
>	map{ [ split ...
>
>part. That's a smart trick. Thanks again to Philip for showing me it
>and to Gwyn for explaining it so clearly.

 .. and of course, when I go back to the docs, I now find that I
understand the Schwartzian Transform example there, too.

Thanks yet again.

Phil
--
@x=split//,'Just another Perl decoder,';split//,'*'x@x;%i=split/=/,
'AA=a=aa= =1=,';for$i(0..$#x){$_[$i]=chr($=+5);while($_[$i]ne$x[$i])
{$_[$i]=$i{$_[$i]}if$i{++$_[$i]};print@_,"\r";while(rand!=rand){}}}
Ignore coming events if you wish to send me e-mail


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

Date: 07 Mar 2001 07:59:07 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Grokking map and grep
Message-Id: <m1ofvd1sfo.fsf@halfdome.holdit.com>

>>>>> "Philip" == Philip Lees <pjlees@ics.forthcomingevents.gr> writes:

Philip> .. and of course, when I go back to the docs, I now find that I
Philip> understand the Schwartzian Transform example there, too.

Good, then can someone explain it to me?

:-)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Wed, 07 Mar 2001 18:45:17 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Grokking map and grep
Message-Id: <tad0dtlf38kbf1@corp.supernews.com>

Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Philip" == Philip Lees <pjlees@ics.forthcomingevents.gr> writes:

> Philip> .. and of course, when I go back to the docs, I now find that I
> Philip> understand the Schwartzian Transform example there, too.

> Good, then can someone explain it to me?

> :-)

Someone once emailed me a detailed description of it. Maybe he
can help you. His address is merlyn@stonehenge.com  :-/

I'm surprised I don't hear more about many algorithms being named
after people in the Perl community. The flexibility of the language
allows many neat approaches to problems. Perhaps the Open Source
nature of the community, with the modules and everything being
handed out so freely, partially precludes the publishing of papers
about new ways to do things. It's widely known, Randal, that you
aren't the one who named the Schwartzian transform after you.

Perhaps it's the centralization of reusable implmentations with the
author's names that reduces the need of people to label the specific
algorithms? I can't believe that the Perl community develops
substantially fewer new algorithms than the C or Java communities.
There must be some social explanation. Perhaps ESR could shed some
light on this.

BTW, yes, I have been reading _Homesteading_the_Noosphere_ again.

Chris

-- 
Christopher E. Stith
You can never entirely stop being what you once were. That's
why it's important to be the right person today, and not put
it off till tomorrow. -- Larry Wall, 3rd State of the Onion



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

Date: Wed, 07 Mar 2001 14:13:07 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: HELP needed: using regular expressions (regex; regexp) or Parse::RecDescent to isolate Java/C++ statements
Message-Id: <slrn9ac9cl.9j1.tadmc@tadmc26.august.net>

Eric Liao <ekliao@pacbell.net> wrote:

>i want the regular expression approach to be correct, meaning
>satisfying all the requirements.  it either works or does not work.
>there's no gray area.
>
>the four types of delimiters are my own choices and they are good for
>the application.


So you want to have a "statement" array element for the data below?


/*
not a statement, but "looks like" one;
*/


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


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

Date: 7 Mar 2001 11:59:10 -0600
From: Eric Liao <ekliao@pacbell.net>
Subject: Re: HELP needed: using regular expressions (regex; regexp) or Parse::RecDescent to isolate Java/C++ statements
Message-Id: <9atcat8g2e3s8deljlh66dbnruq4btipvv@4ax.com>

Tad,

All /*...*/ and //... comments have been correctly preprocessed and eliminated,
so as not to make the statement grammar/regex patterns more complicated.  Sorry
for leaving out that detail.

Eric


On Wed, 07 Mar 2001 14:13:07 GMT, tadmc@augustmail.com (Tad McClellan) wrote:

        Eric Liao <ekliao@pacbell.net> wrote:
        
        >i want the regular expression approach to be correct, meaning
        >satisfying all the requirements.  it either works or does not work.
        >there's no gray area.
        >
        >the four types of delimiters are my own choices and they are good for
        >the application.
        
        
        So you want to have a "statement" array element for the data below?
        
        
        /*
        not a statement, but "looks like" one;
        */



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

Date: Wed, 7 Mar 2001 11:05:30 -0500
From: "Suzanne" <suzanne@campustech.com>
Subject: Re: Help to Install Perl
Message-Id: <985jbp$abk$1@slb3.atl.mindspring.net>

The last time I checked, I paid my bills for Internet service, and I lived
in a free country .... and I can ask questions and get answers in newsgroups
like any other red-blooded American .... and you are not the boss of the
Internet, unless someone promoted you and didn't tell me ...  UNDERSTAND!?
______________________________
Suzanne @CampusTech
http://www.campustech.com
Big Discounts on Software for Students & Teachers



<nobull@mail.com> wrote in message news:u9vgplybfz.fsf@wcl-l.bham.ac.uk...
> "Suzanne" <dream1625@aol.com> spams.
>
> Please do not spam.  Not ever.  Not even a little bit.  No for any
> reason.  Just say "no!" to spam.  Get it?
>
> Question answered in .modules where, as I pointed out, it is off-topic.
>
> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\




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

Date: Wed, 07 Mar 2001 15:19:02 GMT
From: glynFOOdwr@FSCKdeleteEmeD.co.uk (Glyndwr)
Subject: Re: Help to Install Perl
Message-Id: <slrn9ackbf.9ud.glynFOOdwr@glyndwr.dyndns.org>

On Wed, 7 Mar 2001 11:05:30 -0500, Suzanne scribbled:
>The last time I checked, I paid my bills for Internet service, and I lived
>in a free country .... and I can ask questions and get answers in newsgroups
>like any other red-blooded American .... and you are not the boss of the
>Internet, unless someone promoted you and didn't tell me ...  UNDERSTAND!?

All that, and it was top-posted too. I'm impressed.

-- 
                                          -=G=-
Web: http://www.fscked.co.uk                           ICQ: 66545073


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

Date: Wed, 7 Mar 2001 11:21:42 -0500
From: "Suzanne" <suzanne@campustech.com>
Subject: Re: Help to Install Perl
Message-Id: <985kps$6jm$1@slb7.atl.mindspring.net>

Beautiful .... thanks so much Tony .... got the wrong file last night ...
this one worked fine.

Suzanne
CampusTech
http://www.campustech.com


"Tony" <A7654323467897654@hotmail.com> wrote in message
news:Gnpp6.10134$v5.40883@newsfeeds.bigpond.com...
>
> Suzanne wrote in message ...
> >Hi,
> >
> >My boss wants to use Analog stats program with Report Magic, an add-on to
> >Analog that needs Perl to run.  My host told me to install the Report
Magic
> >on my computer and run it from there.  I have checked out and dowloaded
> what
> >I thought would be Perl to install it on my computer at work.  As it
turns
> >out, there is no executable (setup or install.exe) to install it.  How
does
> >a non-programmer install Perl for a Windows 98 system?  Is there an
> >executable file available somewhere?  Appreciate any help offered.
>
>
> Download the MSI version if you haven't already and also the
>  Windows installer, Windows 95/98 for the setup.exe
> http://www.activestate.com/Products/ActivePerl/Download.html
>
>




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

Date: Wed, 07 Mar 2001 19:29:13 +0100
From: Svein Tore Opdal <stop@statoil.com>
Subject: How do I combine filehandles, refs and strict?
Message-Id: <3AA67DF9.5D74CAC1@statoil.com>

hi, I am trying to adapt (more or less duplicate) the  code found on the
'perl.com' website:
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/open.html

But this does not work if I use 'strict', and I have not been able to
figure out how to modify tjhe program to
get around it.
I know that I can avoid the problem by being more lenient  (exlude
'refs' from strict) , but that does not sit well with me.

perl error message is
Can't use string ("fh01") as a symbol ref while "strict refs" in use at
 .//testOpen.pl line 15.

What is  a  'proper' solution for this?

regards
Svein

---------- here is the program:--------------
#!/local/perl/bin/perl -w
#
# process argument list of files along with any includes
use strict ;                              # this does not work
#use strict 'vars';                 # this is OK
#use strict 'subs';               # this is also OK
my $file;
foreach $file (@ARGV) {
  process($file, 'fh00');
}

sub process {
  my ($filename, $input) = @_;
  $input++;               # this is a string increment
  unless (open($input, $filename)) {
    print STDERR "Can't open $filename: $!\n";
    return;
  }
  local $_;
  while (<$input>) {              # note use of indirection
    if (/^ "(.*)"/) {
 process($1, $input);
 next;
      }
      #...                # whatever
  }
}



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

Date: 7 Mar 2001 16:10:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: is there a better way ?
Message-Id: <985mib$9mc$1@mamenchi.zrz.TU-Berlin.DE>

According to Bart Lateur  <bart.lateur@skynet.be>:
> Ralph Osle wrote:
> 
> ># given a text with records...
> ># ...
> >my $text = <<'EOF';
> >To : John
> >From : Tom
> >Subject : Hello
> >
> >To : Edgar
> >From : Raven
> >Subject : NeverMore
> ...
> >EOF
> 
> ># and a regex 
> >my $regex = 'To : (\w+)\s+From : (\w+)\s+Subject : (\w+)';
> >
> ># i want to extract fields To,From,Subject by iterating
> ># the regex (\g) over $text and get records in a bidimensional array like
> ># @records = ( 
> >['John','Tom','Hello'],['Edgar','Raven','NeverMore'],['Newbie','Larry','TMTO
> >WTDI'])
> >
> ># sub should accept a regex and a text as params
> ># that is : number of fields per record is unknown until run-time
> >
> ># it seems perl 's missing a token for the array ($1,$2,$3, ... , $+) after 
> >a match occurs
> 
> Yes... I don't understand your obsession with $+, it's just the last
> succesful capture, and is always one of ($1, $2, $3, ...). But that
> array is indeed missing. I lamented about this a few years ago, and the
> thing they came up with, is very clunky indeed, all in the name of
> efficiency (for the cases where you DON'T need it): @+ and @-, which are
> an array of starting and ending positions of the submatches. See perlvar
> for more info.

I've missed that array too.
 
> ># is there a better way than simulate missing array by eval? tnx anyways
> >
> >my @recs = extract($regex,$text);
> 
> 	sub extract {
> 	    my $regex = shift;
> 	    local $_ = shift;

You may want to say "local $_ = my $text = shift" here.  Otherwise,
$text below is a reference outside the sub.

> 	    my @result;
> 	    while(/$regex/g) {
> 	        my @submatch = map
> 	          { substr $text, $-[$_], $+[$_]-$-[$_] } 1 .. $#+;
> 	        push @result, \@submatch;
> 	    }
> 	    return @result;
> 	}
> 
> At least, it works.

Actually, the result of a regex in list context is what we want, but
using the regex for loop control like you do doesn't allow that.
If we take the efficiency hit and match each pattern again in the
loop body, we can do it in list context:

    sub extract1 {
        my $regex = shift;
        local $_ = shift;
        my @result;
        while ( /$regex/g ) {
            pos() -= length $&;           # so we can match it again
            push @result, [ /\G$regex/ ];
            pos() += length $&;           # same length, reset pos()
        }
        return @result;
    }

Works, too.

Anno


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

Date: Wed, 07 Mar 2001 11:20:03 -0600
From: Keep it to Usenet please <idontreadthis56@hotmail.com>
Subject: Re: Perl CGI.pm RESET problem
Message-Id: <idontreadthis56-17291E.11200307032001@newsrump.sjc.telocity.net>

In article <3A9F58CD.74A768D4@stomp.stomp.tokyo>,
 "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:

> > I just didn't want to have to use a JS onClick event handler. Why? 
> 
> Because Java totally sucks.

This is a semi-pitnick, but Java and INScript (the language formerly 
known as Javascript) have about as much in common as butter and 
butterflies.

-- 
Help!  I'm being held in a .sig factory.


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

Date: Wed, 07 Mar 2001 09:31:38 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Perl CGI.pm RESET problem
Message-Id: <3AA6707A.31723D8E@stomp.stomp.tokyo>

Keep it to Usenet please wrote:

> Godzilla! wrote:
 
> > > I just didn't want to have to use a JS onClick event handler. Why?

> > Because Java totally sucks.
 
> This is a semi-pitnick, but Java and INScript (the language formerly
> known as Javascript) have about as much in common as butter and
> butterflies.


This is related to this thread in what way, related
in what way to a concept which would be considered
intelligent per a reasonable person's perspective?

Godzilla!


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

Date: Wed, 07 Mar 2001 06:35:34 -0800
From: John Lockwood <john@particlewave.com>
Subject: Re: Perl Newbie ???
Message-Id: <oohcatonhns242kb0gfheos2epodhrfc1n@4ax.com>

On Tue, 6 Mar 2001 14:13:14 -0500, "Jason Cooke"
<jrcooke@hardynet.com> wrote:

>i have installed it in   c:\>perl\perl5\      i have created a simple print
>program and saved it as test.pl    i put that into the bin folder under
>perl5      i then went to my prompt and typed c:\>perl\perl5\bin\test.pl
>nothing..................
>

Have you tried c:\perl\perl5\bin\perl.exe test.pl?


John


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

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 V10 Issue 435
**************************************


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