[22707] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4928 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 2 18:05:38 2003

Date: Fri, 2 May 2003 15:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 2 May 2003     Volume: 10 Number: 4928

Today's topics:
        Adding time in perl (AJ Miller)
    Re: Adding time in perl <emschwar@pobox.com>
    Re: Adding time in perl <mbudash@sonic.net>
        Comm.pl "could not open slave" error (Robert Jacobson)
        creating class hierarchies with h2xs <jasonp@uq.net.au>
        duration of a mp3 file <zebuwin@yahoo.fr>
    Re: duration of a mp3 file <mbudash@sonic.net>
    Re: Forms structure <spamtrap@nowhere.com>
    Re: Forms structure <jurgenex@hotmail.com>
    Re: Get somthing between ( ) from a long string - how - <michael.p.broida@boeing.com>
        haiku for french perl <serge.john.swilting@wanadoo.fr>
    Re: Help: Save Search Terms in an Array? <spamtrap@nowhere.com>
    Re: Is it possible to pass @somethig and $something_els <michael.p.broida@boeing.com>
    Re: Is it possible to pass @somethig and $something_els <michael.p.broida@boeing.com>
    Re: Is it possible to pass @somethig and $something_els (Tad McClellan)
        Perl Editor : Whats Recommended <chris_12003@yahoo.com>
    Re: Perl Editor : Whats Recommended <nospam@raytheon.com>
    Re: Perl Editor : Whats Recommended <spamtrap@nowhere.com>
    Re: Perl Editor : Whats Recommended (Malcolm Dew-Jones)
    Re: Perl Editor : Whats Recommended <abuse@mweb.co.za>
    Re: Perl Editor : Whats Recommended <zebuwin@yahoo.fr>
    Re: regex negating a search/word (Sara)
    Re: regex negating a search/word <emschwar@pobox.com>
    Re: regex with /\G .. /gc <skuo@mtwhitney.nsc.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 2 May 2003 13:34:35 -0700
From: ajmiller@crutchfield.com (AJ Miller)
Subject: Adding time in perl
Message-Id: <f13dd2ac.0305021234.7cf96bc0@posting.google.com>

Hello,

I have a list of start times and the duration of the event in the
format

start time    duration
8:00 am       1000
10:00 am      800
1:30 pm       1030
 
etc....

what this stands for is start at 8:00 am and go for 10 hours till 6:00
pm.

what i need is a PERL way to add the duration to the start time, and
have an End Time.  In my above example, the end result would be:

start time     end time
8:00 am        6:00 pm
10:00 am       6:00 pm
1:30 pm        11:30 pm

if anyone has any thoughts, i would appreciate the feedback.


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

Date: 02 May 2003 14:37:58 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Adding time in perl
Message-Id: <etoade53x09.fsf@wormtongue.emschwar>

ajmiller@crutchfield.com (AJ Miller) writes:
> what i need is a PERL way to add the duration to the start time, and
> have an End Time.

You want Date::Calc, which is an XS module, or Date::Manip if you need
a pure-Perl module (Date::Calc is much faster, though).

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Fri, 02 May 2003 21:10:14 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Adding time in perl
Message-Id: <mbudash-C0732A.14101302052003@typhoon.sonic.net>

In article <f13dd2ac.0305021234.7cf96bc0@posting.google.com>,
 ajmiller@crutchfield.com (AJ Miller) wrote:

> Hello,
> 
> I have a list of start times and the duration of the event in the
> format
> 
> start time    duration
> 8:00 am       1000
> 10:00 am      800
> 1:30 pm       1030
>  
> etc....
> 
> what this stands for is start at 8:00 am and go for 10 hours till 6:00
> pm.
> 
> what i need is a PERL way to add the duration to the start time, and
> have an End Time.  In my above example, the end result would be:
> 
> start time     end time
> 8:00 am        6:00 pm
> 10:00 am       6:00 pm
> 1:30 pm        11:30 pm
> 
> if anyone has any thoughts, i would appreciate the feedback.

you could use a module, or if your data is reliable and you fancy 
hand-rolled solutions, this will start you out:

my @starts = ("8:00 am", "10:00 am", "1:30 pm");
my @durs   = ("1000", "800", "1030");

for my $i (0..$#starts) {
   my ($shr, $smn, $ap) = $starts[$i] =~ /^(\d+):(\d+) (..)$/; 
   my ($dhr, $dmn) = $durs[$i] =~ /^(\d+)(\d{2})$/;
   my $ehr = $shr + $dhr;
   my $emn = $smn + $dmn;
   if ($emn >= 60) {
      $emn -= 60;
      $ehr++;
   }
   if ($ehr > 12) {
      $ehr -= 12;
      $ap = ($ap eq "am") ? "pm" : "am";
   }
   printf "%2d:%02d %s\n", $ehr, $emn, $ap;
}

mind you, i've never quite been sure about when am changes to pm (i.e., 
is noon 12am or 12pm?), so i mighta gotten the am/pm part wrong, but 
otherwise...

hth-

-- 
Michael Budash


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

Date: 2 May 2003 11:44:33 -0700
From: q2m3eft02@sneakemail.com (Robert Jacobson)
Subject: Comm.pl "could not open slave" error
Message-Id: <8f82078d.0305021044.66222254@posting.google.com>

I guess this is a two-part question -- first, maybe I'm just going
about this program in a stupid way.  Maybe someone can point me in a
simpler direction?  Second, I sometimes get an error with the Comm.pl
program:

"could not open slave, /dev/pts/18, errno=Permsssion denied at Comm.pl
line 1342."

I only seem to get this error when there are already alot of existing
ptys (remote login sessions) in use.  I'm only using the open_proc()
function from Comm.pl (see below).  Am I doing something wrong?  Is
there a way to work around the error?

The program is a data monitor, using the modules Term::Screen,
IO:Select, and Comm.pl.  I use Term::Screen for the fancy puts(), and
to allow the user to quit the monitor using a keyboard command (and
possible future expansion of keyboard commands).  I use IO::Select to
select STDIN or INPUT (text output from an external perl program).  I
use Comm.pl so that the output from the external program will not be
block buffered by the OS.  The meat of the program is below; again, I
welcome your comments for improvements if I've done something
incredibly dumb :)

BTW, this is for perl 5.005 (or maybe 5.003, my memory sucks :(  )

--- BEGIN horrible code :-D  ---

use IO::Select;
use Term::Screen;
require 'Comm.pl';

$scr = new Term::Screen;
# lots of $src->at(x,y)->puts("foo");

# Comm.pl requires me to do this before calling any Comm.pl functions
&Comm'init;

# get input from external perl program "scan"
# "scan" monitors a network port for data from an external source
# output is constant if data is available from external source
# output stops if data stops from external source
# use open_proc instead of open(INPUT, "scan $port |") so that
# input is not block buffered
($PTY, $TTY, $PID) = open_proc("scan $port") or die "oh no!";

$STDIN_ref = \*STDIN;
$INPUT_ref = \*$PTY;

$sel = IO::Select->new();
$sel->add($STDIN_ref);
$sel->add($INPUT_ref);

while(@ready = $sel-can_read) {
    foreach $fh (@ready) {
        if ($fh == $STDIN_ref) {
             # test for "quit" keypress
             if ($scr->key_pressed()) {
                 $char = $scr->getch();
                 if ($char eq "q") {exit};
             }
        }  # end STDIN processing

        if ($fh == $INPUT_ref) {

             $lines_read = 0;

             while (<$PTY>) {
                 @lines_read++;

                 # (do some processing, and output to $scr)
                 # Only process ONE LINE of "scan" output
                 # then read next "ready" $fh
                 if ($lines_read > 0) {last};
             }
        } # end INPUT processing

    } # end foreach $fh
} # end while (@ready)


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

Date: 02 May 2003 17:36:39 -0400
From: Jason Parker-Burlingham <jasonp@uq.net.au>
Subject: creating class hierarchies with h2xs
Message-Id: <878ytpdo9k.fsf@freezer.burling>

I'm about to start work on a hierarchy of classes about three or four
levels deep.  The code, when completed, will need to be distributed to
a number of different systems so I'm planning to use h2xs to handle
the Makefile.PL and such.

My question---such as it is---is about how to go about creating child
and grandchild classes once I've started work.  I see that perlnewmod
recommends running

        h2xs -AX -n Net::Acme

so my question is what does one do when I want to create Net::Coyote
and Net::Anvil?  Should h2xs be run again from the same directory used
to create Net::Acme?  Should I just edit the files created by h2xs for
Net::Acme?  What about when I need Net::Anvil::Heavy?

My current guess is that I could just run h2xs over and over but that
looks as though it will lead to lots of duplicated (or at least
disparate) Changes files, READMEs, etc, which might *not* be the end
of the world, but I'm not sure it's desirable either.

Can anyone offer an opinion here?
-- 
``Oooh!  A gingerbread house!  Hansel and Gretel are set for life!''


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

Date: Fri, 2 May 2003 20:08:52 +0200
From: "Francois Wisard" <zebuwin@yahoo.fr>
Subject: duration of a mp3 file
Message-Id: <3eb2b483$1_2@news.bluewin.ch>

I need a way to access the duration information of a mp3. I can't install
mp3::info so I need another way... anyone has a clue?




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

Date: Fri, 02 May 2003 20:45:21 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: duration of a mp3 file
Message-Id: <mbudash-CAFBB9.13452102052003@typhoon.sonic.net>

In article <3eb2b483$1_2@news.bluewin.ch>,
 "Francois Wisard" <zebuwin@yahoo.fr> wrote:

> I need a way to access the duration information of a mp3. 

ok

> I can't install mp3::info

why (not)?

perldoc -q "my own module/library directory"

> so I need another way... 

maybe not

> anyone has a clue?

now THERE's a good question!

-- 
Michael Budash


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

Date: Fri, 02 May 2003 19:34:33 GMT
From: Andrew Lee <spamtrap@nowhere.com>
Subject: Re: Forms structure
Message-Id: <tah5bv02kipa1lsco1lsjumf3j87stdkrq@4ax.com>

On Fri, 02 May 2003 04:34:16 GMT, "Sam Jesse" <samj@austarmetro.com.au>
wrote:

>Hello every one.. great to have a group like you.
>since my back groud is Microsfot Access and VB6..  and after doing lots of
>reading and buying some very good books on perl and regex. I have not come
>accross an example on how to construct a form with text boxs, botton,
>dataGrids ...etc.
>is  this going to happen under perl or perl uses html which I have to learn
>to custom make my form and link data and other info to it. I am confused as
>to how perl does it. and what is the differnet between CGI and GUI? I would
>appriciagte a link to some basic reading on this issue. thanks to all
>Sam

Welcome to the world of Perl "The Swiss Army Chainsaw of scripting
languages."

Perl knows nothing about Graphical User Interfaces. However there is Tk,
which does.  Perl::Tk is a powerful package for creating GUI's on many
platforms ... take a look at some of the documentation on CPAN.

Perl is often used, also, to create CGI programs -- that is, programs
that sit between a webserver and a web browser.  One does not need to
really understand the protocols involved -- just that CGI.pm (also on
CPAN as well as in the standard distribution) can handle requests to the
webserver.  To do 'cool' things with CGI requires good knowledge of HTML
and possibly JavaScript.


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

Date: Fri, 02 May 2003 20:39:07 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Forms structure
Message-Id: <LHAsa.15815$Tb.14232@nwrddc02.gnilink.net>

Andrew Lee wrote:
> Perl is often used, also, to create CGI programs -- that is, programs
> that sit between a webserver and a web browser.

Pardon me but that is nonsense.
A web browser sends a request to a web server, the web server in turn may
call a CGI program.
The CGI program returns a result to the server which in turn forwards the
result to the web client.

The CGI program sits at the back end of the chain, not between client and
server.
At least in the standard scenario. I'm sure you can come up with some odd
applications, where a web browser communicates directly with a CGI program.

jue




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

Date: Fri, 2 May 2003 18:00:04 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Get somthing between ( ) from a long string - how - newbie Q
Message-Id: <3EB2B224.CD145667@boeing.com>

Damian James wrote:
> 
> On Thu, 1 May 2003 23:02:16 GMT, Michael P. Broida said:
> >Tony wrote:
> >> I need every part between the " " to be a seperate $scalar
> >> or an @array list so it can be passed to anoter sub for processing.
> >>
> >> I could pass the $scalar and process it at the "other end" but
> >> the problem remains that assigning to an @array by means of
> >> splitting causes it to be split like
> >...
> >       Don't split on spaces.  Try splitting on the comma
> >       between the quoted strings:
> >               @newarray = split /,/, $list;
> 
> The OP's string had spaces after the comma as well (as well as the
> enclosing parentheses), so:
> 
>   $list =~ s/^(//;
>   $list =~ s/)$//;
>   my @new = split /, /, $list;
> 
> But then you have to worry about embedded commas. Do you want to
> allow them if escaped (\,)? Does every field have quotes around it?

	Oops, you're correct.  I hadn't even thought about
	commas inside the quotes.  I guess his solution will
	depend on just what those strings CAN have in them.
	If their content is limited, then he can use a
	simpler solution.

		Mike


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

Date: Fri, 02 May 2003 21:30:42 +0000
From: "serge.john.swilting" <serge.john.swilting@wanadoo.fr>
Subject: haiku for french perl
Message-Id: <b8ugvp$h6c$1@news-reader14.wanadoo.fr>

#!/usr/bin/env perl

#use strict;
#
#
#troll haiku french perl programmeur
###################
#big bad in english
###################
#new version of language wiever
###################
#my wife: http://perso.wanadoo.fr/john.swilting/only/bellaminette.xpm
#answer1: http://perso.wanadoo.fr/john.swilting/only/answer1.xpm
#answer2: http://perso.wanadoo.fr/john.swilting/only/answer2.xpm

#do you like my wife
#
#yes
#
#if(/$answer1/)
#ok its nice
#if(/$answer2/)
#bad be careful
#
###################
#new version of language viewer
###################
#
#serge.john.swilting@wanadoo.fr
#
#dedicasse au statisticien

print "do you like my wife";
chomp($answer);
$answer=<STDIN>;



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

Date: Fri, 02 May 2003 19:19:46 GMT
From: Andrew Lee <spamtrap@nowhere.com>
Subject: Re: Help: Save Search Terms in an Array?
Message-Id: <ctg5bvkjphbbasbh458jdn0t52i3s9gk04@4ax.com>

On 1 May 2003 21:45:52 -0700, email_entropy123@yahoo.com (entropy123)
wrote:

>Hey all,
>
>Thanks for all your help. My program is looking pretty damned good
>right now and I appreciate all you've collectively done. (I found
>perlfaq and that is pretty damned good also....)...
>
>My program has many regexs which look awfully similar i.e.
>
>if ($line =~ /\s(Fred)\s/) {

You are storing 'Fred' in $1 -- are you going to use $1?
 
>         $Fred +=1;
>if ($line =~ /\s(Barney)\s/) {
>         $Barney +=1;
>
>How do I most efficiently pull this off?
>

Hashes

The correct answer to many Perl programming questions is : "use a hash"
:-)

if ($line =~ /\bFref\b/) {
	$Fintonses{Fred}++;
}


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

Date: Fri, 2 May 2003 18:02:34 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Is it possible to pass @somethig and $something_else to sub
Message-Id: <3EB2B2BA.B95F7FF1@boeing.com>

"Eric J. Roode" wrote:
> 
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
> 
> "Michael P. Broida" <michael.p.broida@boeing.com> wrote in
> news:3EB1A8B3.23C4C70A@boeing.com:
> 
> > "Eric J. Roode" wrote:
> >>
> >> Do not use & to invoke functions.
> >
> >      I'm not arguing, but I've never been able to get Perl to
> >      ACCEPT the function call unless I use the & on the call.
> >
> >      I've read the docs, and seen that they say the same thing:
> >      it's better to NOT use the & to call functions.
> >
> >      But I can't figure out what I need to do to make it WORK
> >      without the & there.  It usually says that it can't find
> >      the function. But if I just add an & it finds it easily.
> 
> What version of perl are you using?
> 
> Can you give an example of a short program which has a subroutine
> which you can't invoke without an &?  Cause... it "just works" for
> me.  :-)  No hints or tips needed.  No secret trick.

	Perl 5.6.0 for Win32

	Um, no, I don't have any examples left where it doesn't
	work; I've changed them all to stuff that works.  :)

	It's quite possible that there's something else that I
	was doing wrong that caused it not to work.  I'll see
	if I can kludge up an example.

		Mike


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

Date: Fri, 2 May 2003 18:09:18 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Is it possible to pass @somethig and $something_else to sub
Message-Id: <3EB2B44E.8E53C0AC@boeing.com>

Tad McClellan wrote:
> 
> Michael P. Broida <michael.p.broida@boeing.com> wrote:
> > "Eric J. Roode" wrote:
> >>
> >> Do not use & to invoke functions.
> >
> >       I'm not arguing, but I've never been able to get Perl to
> >       ACCEPT the function call unless I use the & on the call.
> 
> >       Please give some hints as to what is needed to make a
> >       function call without "&" work.
> 
> Parenthesis.
>    func()
> instead of
>    &func

	Hmm, for MY OWN functions, I ALWAYS use the parens.
	(For built-ins, I usually leave them off.)

	But I still had problems until I added the "&".
	So, all my calls to my own functions look like this:
		&functionname(arguments)

	Hmm, I just tried removing the "&" from one of my
	existing function calls and it worked just fine.
	So now I don't know what caused me to need them
	before.  Most annoying.  :/

	OK, I'll start removing the & from them all so I'll
	be "in line" with the recommendations.

	Umm, what is the actual REASON for not using & there?

		Mike


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

Date: Fri, 2 May 2003 14:13:40 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Is it possible to pass @somethig and $something_else to sub
Message-Id: <slrnbb5gr4.3rd.tadmc@magna.augustmail.com>

Michael P. Broida <michael.p.broida@boeing.com> wrote:
> Tad McClellan wrote:
>> Michael P. Broida <michael.p.broida@boeing.com> wrote:
>> > "Eric J. Roode" wrote:
>> >>
>> >> Do not use & to invoke functions.

>> >       Please give some hints as to what is needed to make a
>> >       function call without "&" work.
>> 
>> Parenthesis.
>>    func()
>> instead of
>>    &func
> 
> 	Hmm, for MY OWN functions, I ALWAYS use the parens.
> 	(For built-ins, I usually leave them off.)


Me too.


> 	Umm, what is the actual REASON for not using & there?


   perldoc perlsub


       To call subroutines:
       ...
       &NAME(LIST);   # Circumvent prototypes.
       &NAME;         # Makes current @_ visible to called subroutine.


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


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

Date: Fri, 2 May 2003 11:51:03 -0700
From: "Chris" <chris_12003@yahoo.com>
Subject: Perl Editor : Whats Recommended
Message-Id: <vb5ff3962ji6cd@corp.supernews.com>

Is there an editor that will allow me to clearly see code thats in { }.  I
have a perl script that has lots of nested { } brackets and its hard for me
to tell where the code stops and which else statements belong to which if.
Will homesite do this or is there something else available?

Thanks,
Chris




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

Date: Fri, 02 May 2003 14:13:22 -0500
From: Chris Olive <nospam@raytheon.com>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <9rzsa.3182$c6.2955@bos-service2.ext.raytheon.com>

Chris wrote:
> Is there an editor that will allow me to clearly see code thats in { }.  I
> have a perl script that has lots of nested { } brackets and its hard for me
> to tell where the code stops and which else statements belong to which if.
> Will homesite do this or is there something else available?
> 
> Thanks,
> Chris
> 

Not to make an example of you publicly as much as to allow others to 
consider this too, but questions like this are a little bit like asking 
"What's the best way to get to San Diego?"  Well, it depends a little 
bit on where you are.  If you are in CA somewhere, there are a number of 
ways at your disposal.  If you are in Tokyo, Japan, your initial options 
are limited, esp. if you want to arrive in SD quickly.

Not everyone in this newsgroup is effected by Bill Gate's "mind tricks" 
and automatically suppose it's a Windows world.  In fact, I would 
suspect quite a number of people despise that platform and it's entire 
paradigm from a purely technical stand-point, myself included (not 
withstanding we sometimes have to stoop to make a living.)  Not everyone 
here USES Windows...

Anyway...  THE POINT IS, when you ask a question like this, at least 
tell us WHAT IS YOUR TARGET PLATFORM.  Your Homesite comment is the only 
thing that provides any indication of what you really desire (eg. 
Windows editors) and narrows the choices for those from whom you are 
soliciting advice.

Now, to answer your question, Homesite on Windoze WILL highlight Perl 
syntax for you, and is a very good editor (in my opinion) for editing 
Perl CGI programs on that platform.  I wouldn't use it for general Perl 
editing just because it highlights syntax.

I use Cygwin on Windoze, so I use Emacs there for Perl editing in a 
XFree86 window.  Emacs on Linux/Unix would provide much the same 
features and has extensive capabilities in "perl-mode."  I would think a 
lot of people here use Emacs, but the answers will vary because the 
platforms represented by the participants will vary.

Chris
-----
Chris "Watto" Olive
Systems Consultant
Raytheon Technical Services Corporation
Indianapolis, IN

email: olivec(AT)indy(DOT)raytheon(DOT)com



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

Date: Fri, 02 May 2003 19:20:30 GMT
From: Andrew Lee <spamtrap@nowhere.com>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <v6h5bvkafg61evhf9edbt5288kn6fo0n83@4ax.com>

On Fri, 2 May 2003 11:51:03 -0700, "Chris" <chris_12003@yahoo.com>
wrote:

>Is there an editor that will allow me to clearly see code thats in { }.  I
>have a perl script that has lots of nested { } brackets and its hard for me
>to tell where the code stops and which else statements belong to which if.
>Will homesite do this or is there something else available?
>
>Thanks,
>Chris
>

TextPad now has syntax coloring for Perl and it's free -- search Google.



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

Date: 2 May 2003 12:51:49 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <3eb2cc55@news.victoria.tc.ca>

Chris (chris_12003@yahoo.com) wrote:
: Is there an editor that will allow me to clearly see code thats in { }.  I
: have a perl script that has lots of nested { } brackets and its hard for me
: to tell where the code stops and which else statements belong to which if.
: Will homesite do this or is there something else available?

Years ago I spent many hours debugging a complex numerical calculation in
a pascal program.  As often in numerical analysis, it was not possible to
check the answer from the program except by writing a program to find the
answer, which makes it tricky to know if the answer was correct.  It was
certainly very close.

Eventually I found that an end statement was not correctly aligned with
the appropriate begin within a nested calculation.

Every since then I virtually always align ny braces vertically.  (That's
begin/end in pascal of course.)  It requires absolutely no support of any
kind from any editor or other tool, and even allows you to check the
syntax when you have no tool at all, such as reading a printout on the
bus.  It's was a trivial change in my editing style that virtually
eliminates bugs due to misplaced braces.

	while ( short simple expr, horizontal alignment )
	{
		block of code, or complex expressions
		vertical alignment
	}


$0.02



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

Date: Fri, 02 May 2003 22:39:35 +0200
From: "Nico Coetzee" <abuse@mweb.co.za>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <pan.2003.05.02.20.39.32.596592@mweb.co.za>

On Fri, 02 May 2003 11:51:03 -0700, Chris wrote:

> Is there an editor that will allow me to clearly see code thats in { }.  I
> have a perl script that has lots of nested { } brackets and its hard for me
> to tell where the code stops and which else statements belong to which if.
> Will homesite do this or is there something else available?
> 
> Thanks,
> Chris

I recommend NEdit - http://www.nedit.org/

My Perl Screenshot: http://www.itfirms.co.za/snapshot17.png

More Screenshots: http://www.nedit.org/about/shots1.shtml

Cheers

-- 
Nico Coetzee

http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/

To the systems programmer, users and applications serve only to provide a
test load.



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

Date: Fri, 2 May 2003 21:17:04 +0200
From: "Francois Wisard" <zebuwin@yahoo.fr>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <3eb2dcd8$1_5@news.bluewin.ch>

If you're under Windows try this:
http://open-perl-ide.sourceforge.net/




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

Date: 2 May 2003 13:32:35 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: regex negating a search/word
Message-Id: <776e0325.0305021232.3da45f05@posting.google.com>

Lance Hoffmeyer <lance-news@augustmail.com> wrote in message news:<CK6dnUM8RdxwHS-jXTWcqA@august.net>...
> Hello,
> 
> Given the following regex:
> 
> $file2 =~ /TABLE\s+70.*?TELEVISION.*?(\d{1,3}\.\d)\D+/s;$P33A23 = $1
> 
> 
> I want a way to have the search fail or to stop the search if it
> finds "TABLE 71".
> 
> Any ideas how I might accomplish this?
> 
> Lance

Hello Lance:

I'm not sure I understand your entire objective here, but I presume
this line is inside a block such as

  open F, $someFile;
  while <F>
   {last if /TABLE\s+71/; # add this line to short-circuit the search?
    $file2 =~ /TABLE\s+70.*?TELEVISION.*?(\d{1,3}\.\d)\D+/s;
    $P33A23 = $1;
   }

It seems odd to loop though a whole file to store one value. So lets
look at another tact (I havent tested this code, beware it's FRIDAY
and almost beer-thirty)..

  open F, $someFile;

# snag the file file cram it into a scalar, close it to be tidy
  my @f = <F>;
  close F;
  my $f = join '', @f;

# now truncate the inputfile at /TABLE\s+71/
  $f =~ s/TABLE\s+71.+$//sm;
  $f =~ s/^.*TABLE\s+70.*?TELEVISION.*?(\d{1,3}\.\d).+$/$1/;
 
# at this point $f either contains $1, if it matched, or the truncated
file if
# it didn't. There are a few ways to test that, perhaps another regex?

  $f = '' unless $f =~ /^\d{1,3}\.\d$/;

Again I'm not certain this is what you were after, if not please
disregard. However, note that this approach is loop-less, which can be
desirable. Dont forget your old friends Mr "Strict" and Mr warnings
either!

Finally- that variable $P33A23 looks very odd, as if perhaps its
related to some coordinate like (33,23) or something like that? If so,
and you have others with similar names, I recommend a hash for them
like

 my $p = {};
  .
  .
 $p->{23}={};
 $p->{23}{33} = blah blah...

But again, I may be misinterpreting between the lines of your post.

Have a great Perl weekend! Oh wait I forgot the obligatory flame that
the other poster said all contributors give here. Let's see.. *think*
*think*

Ahhh forget it I need a beer!

-Gx


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

Date: 02 May 2003 14:35:46 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: regex negating a search/word
Message-Id: <etoel3h3x3x.fsf@wormtongue.emschwar>

genericax@hotmail.com (Sara) writes:
> # now truncate the inputfile at /TABLE\s+71/
>   $f =~ s/TABLE\s+71.+$//sm;
>   $f =~ s/^.*TABLE\s+70.*?TELEVISION.*?(\d{1,3}\.\d).+$/$1/;
>  
> # at this point $f either contains $1, if it matched, or the truncated
> file if
> # it didn't. There are a few ways to test that, perhaps another regex?

Ack, no.  Just test the result of the one you just applied:

if($f =~ s/$regex/) {
  <do stuff with $1>
} else {
  <complain about not matching, or whatever>
}

-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Fri, 2 May 2003 12:26:52 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: regex with /\G .. /gc
Message-Id: <Pine.GSO.4.21.0305021217270.13588-100000@mtwhitney.nsc.com>

On Fri, 2 May 2003 foobear@nospam.zoom.net wrote:

> Steven Kuo <skuo@mtwhitney.nsc.com> wrote:

(snipped) 

> > my %h;
> > $_ =    'S89 Key: 255.255.255.255:319510, NAS: 1.1.1.1, NAS-Port: 666,
> >         User-Name: foo@bar.baz, Time: 94:35:09, GSL 1,
> >         NOTES: "Acct-Session-Id" "0048939656", "FooNote" "1.2.3.4",
> >         "BarNote" "whee"';
> >
> > substr($_,0,0) = 'id: ';
> >
> > LOOP:
> > {
> >     # With some extra print statements for debugging thrown in:
> >     $h{$1} = $2, redo LOOP if m#\G(\S+)(?<!NOTES):\s([^,\s]+),?\s+(?{print pos,$/;})#gc;
> >     print "Begin again at ", pos , "\n";
> >     $h{'notes'}{$1} = $2, redo LOOP if m/"([^"]+)"\s+"([^"]*)"/g;
> > }
> [snipped]
> 
> Hi Steve,
> 
> The use of substr is clever to achieve the matches with one pattern :)
> 
> I am curious, is there a way to solve this without using a zero-width
> negative lookbehind assertion. (?<!pattern) I dont think some tools
> support that. (and older versions of perl)
> 
> -v
 



Yes, of course.  Without lookbehind:


#!/usr/local/bin/perl

use Data::Dumper;
my %h;
$_ =    'S89 Key: 255.255.255.255:319510, NAS: 1.1.1.1, NAS-Port: 666,
        User-Name: foo@bar.baz, Time: 94:35:09, GSL 1,
        NOTES: "Acct-Session-Id" "0048939656", "FooNote" "1.2.3.4",
        "BarNote" "whee"';


substr($_,0,0) = 'id: ';


LOOP:
{
    next if /\G[^:]+NOTES:/;
    
    $h{$1} = $2, redo LOOP if m#\G(\S+):\s([^,\s]+),?\s+(?{print pos,$/;})#gc;

} continue {
    print "Begin again at ", pos , "\n";
    %{$h{'notes'}} = m/"([^"]+)"\s+"([^"]*)"/g;
    last;
}

print Dumper \%h;

-- 
Hope this helps,
Steven



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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 4928
***************************************


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