[24090] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6284 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 21 06:05:41 2004

Date: Sun, 21 Mar 2004 03:05:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 21 Mar 2004     Volume: 10 Number: 6284

Today's topics:
        ANNOUNCE: Class::DBI::Schema2Code V 1.00 <ron@savage.net.au>
        Changing a field separator (?) <data345@yahoo.com>
    Re: Changing a field separator (?) (Walter Roberson)
    Re: Changing a field separator (?) <jwillmore@remove.adelphia.net>
    Re: Changing a field separator (?) <roel-perl@st2x.net>
    Re: Changing a field separator (?) <krahnj@acm.org>
    Re: dollar sign and spaces from a string <vetro@online.no>
        getch <toylet_at_mail.hongkong.com>
    Re: getch <jwillmore@remove.adelphia.net>
    Re: getch <jurgenex@hotmail.com>
    Re: getch <toylet_at_mail.hongkong.com>
    Re: help me with if-else if-else <Joe.Smith@inwap.com>
    Re: How to fill a hash from the products of a split <Joe.Smith@inwap.com>
    Re: Multiple compares -- TMTOWTDI <tadmc@augustmail.com>
    Re: open (FAILEHANDLER, ">>$filename")  what is the ron (Sameh Abdelatef)
    Re: open (FAILEHANDLER, ">>$filename")  what is the ron <roel-perl@st2x.net>
    Re: open (FAILEHANDLER, ">>$filename")  what is the ron <krahnj@acm.org>
    Re: perl on windows <laststop@cwnet.com>
    Re: regex (pcre) variable number of (captures)*  - how? <x@x.x>
    Re: regex (pcre) variable number of (captures)*  - how? <x@x.x>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 20 Mar 2004 01:07:18 GMT
From: Ron Savage <ron@savage.net.au>
Subject: ANNOUNCE: Class::DBI::Schema2Code V 1.00
Message-Id: <HuwvJy.K92@zorch.sf-bay.org>

The pure Perl module Class::DBI::Schema2Code V 1.00
is available immediately from CPAN,
and from http://savage.net.au/Perl-modules.html.

On-line docs, and a *.ppd for ActivePerl are also
available from the latter site.

An extract from the docs:

NAME
Class::DBI::Schema2Code - Convert db schema to modules which use Class::DBI

Recent changes:
1.00  Thu Mar  18 10:23:29 2004
	- Original version
	- See examples/parent-module.tmpl and generic-module.tmpl for sample templates
		used to generate Perl source code
	- See examples/bootstrap.pl for code which loads 3 text files into 3 database
		tables
	- See examples/generator.pl for code which generates Local::Project::* modules for
		the 3 tables
	- See examples/reporter.pl for code which exercises the Local::Project::* modules
	- See examples/address-print.pl and campus-print.pl for subs which can be plugged
		into the generated modules Local::Project::Address.pm and Campus.pm to enhance
		the output of reporter.pl
	- See examples/reporter.log for my output after having plugged in those 2 subs.
		Your output should be identical, apart from OS-dependent line terminators.
--
Cheers
Ron Savage, ron@savage.net.au on 20/03/2004
http://savage.net.au/index.html




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

Date: Sat, 20 Mar 2004 20:34:23 -0900
From: "Al Sparks" <data345@yahoo.com>
Subject: Changing a field separator (?)
Message-Id: <405d2a61$1_2@news.athenanews.com>

I've been trying to do some array, @ary, and print it out.

If I do a
   @ary = (blah, blah);

   print "@ary\n"

the output will be
   blah blah

Is there a way I can tell perl to use tabs (\t) to separate the
elements of that array?
  === Al




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

Date: 21 Mar 2004 05:47:07 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Changing a field separator (?)
Message-Id: <c3ja8r$ns4$1@canopus.cc.umanitoba.ca>

In article <405d2a61$1_2@news.athenanews.com>,
Al Sparks <data345@yahoo.com> wrote:
:I've been trying to do some array, @ary, and print it out.

:If I do a
:   @ary = (blah, blah);

:   print "@ary\n"

:the output will be
:   blah blah

:Is there a way I can tell perl to use tabs (\t) to separate the
:elements of that array?

perldoc perlvars
-- 
Admit it -- you peeked ahead to find out how this message ends!


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

Date: Sun, 21 Mar 2004 00:54:09 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Changing a field separator (?)
Message-Id: <pan.2004.03.21.05.54.07.466624@remove.adelphia.net>

On Sat, 20 Mar 2004 20:34:23 -0900, Al Sparks wrote:

> I've been trying to do some array, @ary, and print it out.
> 
> If I do a
>    @ary = (blah, blah);
> 
>    print "@ary\n"

print join("\t", @ary),"\n";
 
> the output will be
>    blah blah
> 
> Is there a way I can tell perl to use tabs (\t) to separate the
> elements of that array?

`perldoc -f join`

Or ... you could itterate through the array (`perldoc -f foreach`),
printing each element as you go :-)  However, that's not very efficent if
all you really want to do is put tabs in between each element of the array
:-)

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
"If we were meant to fly, we wouldn't keep losing our luggage." 




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

Date: 21 Mar 2004 05:58:44 GMT
From: Roel van der Steen <roel-perl@st2x.net>
Subject: Re: Changing a field separator (?)
Message-Id: <slrnc5qbnu.atk.roel-perl@195-86-124-242.dsl.easynet.nl>

On Sun, 21 Mar 2004 at 05:34 GMT, Al Sparks <data345@yahoo.com> wrote:
> I've been trying to do some array, @ary, and print it out.
 
> Is there a way I can tell perl to use tabs (\t) to separate the
> elements of that array?
 
TIMTOWDY, e.g.:

#!/usr/bin/perl
use strict;
use warnings;

my @ary = ('blah', 'blah');
{
  local $,="\t";   # This sets the list separator... 
  print @ary;      # ... so make sure this is a list (no quotes)
}
print "\n";

# or:

print join("\t", @ary), "\n";

__END__


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

Date: Sun, 21 Mar 2004 09:04:49 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Changing a field separator (?)
Message-Id: <405D5AB5.7A21B85A@acm.org>

Al Sparks wrote:
> 
> I've been trying to do some array, @ary, and print it out.
> 
> If I do a
>    @ary = (blah, blah);
> 
>    print "@ary\n"
> 
> the output will be
>    blah blah
> 
> Is there a way I can tell perl to use tabs (\t) to separate the
> elements of that array?

Yes there is.

my @ary = qw( blah blah );
$" = "\t";
print "@ary\n"



John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 21 Mar 2004 10:25:47 +0100
From: Vetle Roeim <vetro@online.no>
Subject: Re: dollar sign and spaces from a string
Message-Id: <m3r7vmk0v8.fsf@quimby.dirtyhack.org>

* mr@sandman.net
> In article <c3hf1t$d7h$1@mamenchi.zrz.TU-Berlin.DE>,
>> I asked for evidence, you give me an anecdote (no news there, I
>> read this newsgroup too).
>> 
>> How many newbies are scared off by the elitist attitude of this NG,
>> and how do you know?
>
> I have showed you exactly what I wanted to show and I have no doubt
> my claim is adequately substantiated.

  Although I believe that Kenton _perhaps_ could have been treated a
  little better, your claim is that a lot of newbies are scared
  off. You have only showed us Kenton. Where's the rest of them?

  I can understand much of the attitude here, though. Sometimes it
  seems like 90% of the posts here are from people who haven't
  bothered to even pick up a book on Perl.


-- 
#!/usr/bin/vr


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

Date: Sun, 21 Mar 2004 11:29:26 +0800
From: toylet <toylet_at_mail.hongkong.com>
Subject: getch
Message-Id: <405d0bfb$1_3@rain.i-cable.com>

Which perl function would wait for a keypress and return its EBCDIC code?

-- 
   .~.    Might, Courage, Vision. In Linux We Trust.
  / v \   http://www.linux-sxs.org
/( _ )\  Linux 2.4.22-xfs
   ^ ^    11:26am up 3 days 15:05 load average: 1.01 1.02 0.95


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

Date: Sat, 20 Mar 2004 22:49:34 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: getch
Message-Id: <pan.2004.03.21.03.49.32.268287@remove.adelphia.net>

On Sun, 21 Mar 2004 11:29:26 +0800, toylet wrote:

> Which perl function would wait for a keypress and return its EBCDIC code?

You could use one of the following modules:
Encode::EBCDIC
Convert::EBCDIC

There are conversion charts available on the 'Net to find out how the
translation is done - if you *really* want to roll your own.  IBM would be
my first stop on this quest.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
I really hate this damned machine I wish that they would sell it.
It never does quite what I want But only what I tell it. 



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

Date: Sun, 21 Mar 2004 05:00:38 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: getch
Message-Id: <Wj97c.14248$VV1.12354@nwrddc01.gnilink.net>

toylet wrote:
> Which perl function would wait for a keypress

perldoc -q key:
    "  How can I read a single character from a file?  From the keyboard?"

> and return its EBCDIC code?

EBCDIC? Wow, someone is still using it!
Did you check CPAN? A straigh-forward search for CPAN in the name returns

1:  Convert::EBCDIC, ascii2ebcdic, ebcdic2ascii - Perl module for string
conversion between EBCDIC and ASCII
Database: cpan, Size: 1.5 kbytes, Type: CPAN, Score: 999
2:  Convert-EBCDIC README
Database: cpan, Size: 1.2 kbytes, Type: CPAN, Score: 999

Is that what you are looking for?

jue




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

Date: Sun, 21 Mar 2004 14:09:53 +0800
From: toylet <toylet_at_mail.hongkong.com>
Subject: Re: getch
Message-Id: <405d3196_3@rain.i-cable.com>


thank you.


-- 
   .~.    Might, Courage, Vision. In Linux We Trust.
  / v \   http://www.linux-sxs.org
/( _ )\  Linux 2.4.22-xfs
   ^ ^    2:08pm up 3 days 17:47 load average: 1.18 1.06 1.02


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

Date: Sat, 20 Mar 2004 23:10:53 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: help me with if-else if-else
Message-Id: <1c47c.48118$JL2.638616@attbi_s03>

Gunnar Hjalmarsson wrote:

> Danny wrote:
> 
>> What is wrong with this?
> <snip>
> 
> Didn't you ask a similar question a few hours ago? Weren't you advised 
> to study
> 
>     perldoc perlintro

Danny,
   To make Gunnar's point painfully obvious, perl is complaining that
you've misspelled the middle part of your if-elsif-else statement.
Hint: It's not spelled "else if".
Go look it up.
	-Joe


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

Date: Sat, 20 Mar 2004 23:38:04 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: How to fill a hash from the products of a split
Message-Id: <wB47c.51450$SR1.95091@attbi_s04>

moller@notvalid.se wrote:

> Yes. I got the regular expression part. It was the assignment bit that
> threw me off.
> 
> Im not used to things returning two or more things.

But that is the power of Perl.  You'll get used to things like:

   @array = split;			# Returns many values
   ($first,$second,$third) = @array;	# Assign three variables
   ($a,$b) = ($b,$a);			# Swap two variables
   my %hash = function_that_returns_values_in_pairs($_);

> And I have not used =~ yet so I'm a bit unsure how it works.

Think of

    my %img_titles = $text =~ /^(.*?)\t(.*)/gm;

as being like

    my %img_titles;
    {
      local $_;
      $_ = $text;
      %img_titles = /^(.*?)\t(.*)/gm;	# Find multiple matches
    }

> And I'm not used to languages that help you as much as perl does.

To get the maximum help from perl, be sure to put
   use strict;
   use warnings;
and optionally
   use diagnostics;
at the start of all your programs.

	-Joe


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

Date: Sat, 20 Mar 2004 16:31:36 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Multiple compares -- TMTOWTDI
Message-Id: <slrnc5phi8.mmj.tadmc@magna.augustmail.com>

Paul Lalli <ittyspam@yahoo.com> wrote:
> On Thu, 18 Mar 2004, Steve The Geek wrote:


>>       {return;}


>> I know the semicolon isn't required for return. 


The semicolon isn't required for the last statement in a block.

return() is not special with regards to the semicolon, it just
happens to be the last statement in that block.


>> Is it good practice to
>> put it in? How about changing return; to return(); ?
> 
> the semi colon is personal preference.  It makes no difference.  


Right.


> changing
> from return to return() actually is a very minor semantic change.  


No it isn't. They are equivalent forms.


> In the
> first case, you're returning undef.  In the second, you're returning an
> empty list.  


We can't know what the return value will be unless we know
what context the particular _call_ was in.

From perlsub.pod:

   If you specify no return value, the subroutine returns an 
   empty list in list context, the undefined value in scalar 
   context, or nothing in void context.


> Were I writing this, I would probably get rid of all these
> extra parens and braces:


Back to being right again.  :-)


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


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

Date: 20 Mar 2004 15:29:36 -0800
From: samehabdelatef@yahoo.com (Sameh Abdelatef)
Subject: Re: open (FAILEHANDLER, ">>$filename")  what is the rong with that
Message-Id: <a2f806f.0403201529.1a4100f9@posting.google.com>

Dear friends
 I'm very grateful to Keith Keller , Vilmos , Tintin, Joe Smith, and
Anno  for them response to my problem. You are right Keith I should
explain more details, any way here is the script. This script was
working fine and suddenly it did not work correct, it should store the
data whish comes from a form in the file (info.list) and  return a
home page contain thanks for the user. The problem is the data did not
written to the file and empty page  appear after that and the browser
show done sign. There was no error at the error file
 In line 12 I changed  open (FILEHANDLER, ">>$filename") to open
(FILEHANDLER, ">$filename"), it worked correct and the data stored and
the old data deleted, also the page of thanks to the user returned
correct.


#!/usr/bin/perl
#Turn off Perl buffering
$| = 1;
#Read and parse the form data
&ReadParse(*input);
print &PrintHeader;
$filename="info.list";
print &thank_you;
exit;
##########################################
#Write form data to file
open (FILEHANDLER, ">>$filename")  || die ("I am sorry, but I was
unable to open the file.");
flock (FILEHANDLER, 2);

print FILEHANDLER
"$input{'sender'}\|$input{'senderemail'}\|$input{'message'}\|";

flock (FILEHANDLER, 8);
close (FILEHANDLER);
############################
sub ReadParse {
  local (*in) = @_ if @_;
  local ($i, $key, $val);

  # Read in text
  if (&MethGet) {
    $in = $ENV{'QUERY_STRING'};
  }
  elsif (&MethPost) {
    read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
  }

  @in = split(/[&;]/,$in);

  foreach $i (0 .. $#in) {
    # Convert plus's to spaces
    $in[$i] =~ s/\+/ /g;
 # Split into key and value.
    ($key, $val) = split(/=/,$in[$i],2); # splits on the first =.

    # Convert %XX from hex numbers to alphanumeric
    $key =~ s/%(..)/pack("c",hex($1))/ge;
    $key =~ s/<!--(.|\n)*-->//g;
    $val =~ s/%(..)/pack("c",hex($1))/ge;
    $val =~ s/<!--(.|\n)*-->//g;
    # Associate key and value
    $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple
separator
    $in{$key} .= $val;

  }

  return scalar(@in);
}
##################################
# PrintHeader
# Returns the magic line which tells WWW that we're an HTML document

sub PrintHeader {
  return "Content-type: text/html\n\n";
}
# MethGet
# Return true if this cgi call was using the GET request, false
otherwise

sub MethGet {
  return ($ENV{'REQUEST_METHOD'} eq "GET");
}


# MethPost
# Return true if this cgi call was using the POST request, false
otherwise

sub MethPost {
  return ($ENV{'REQUEST_METHOD'} eq "POST");
}
##############THANK YOU
sub thank_you {
return <<EOTHANK;
<html>
the html code of the result placed here
</html>
EOTHANK
}


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

Date: 21 Mar 2004 07:23:30 GMT
From: Roel van der Steen <roel-perl@st2x.net>
Subject: Re: open (FAILEHANDLER, ">>$filename")  what is the rong with that
Message-Id: <slrnc5qgmr.atk.roel-perl@195-86-124-242.dsl.easynet.nl>

On Sat, 20 Mar 2004 at 23:29 GMT, Sameh Abdelatef wrote:
> Dear friends
> You are right Keith I should
> explain more details, any way here is the script.

Dear Sameh, your script has lots of problems. First of all, it's not
complete: you start reading from a filehandle that was presumably
opened somewhat further up in the script, but in your sample it's
still closed. The primary reason you are not able to spot these kind of
things easily, is because you didn't use strict and use warnings. If
you want to be able to debug this code, now and in the future, I
recommend cleaning it up. Read perldoc perlstyle. Below I'll briefly
comment your code. (Others may want to add to it, or wait until you
have produced a working sample that exactly describes your problem.)

(One other question in between: why don't you use one of Perl's
standard modules to parse form data? CGI::Lite's parse_form_data
will do a perfect job for you.)

> 
> #!/usr/bin/perl

use strict;
use warnings;

and optionally: use Fcntl qw(:flock);  

Note that you will need to put "my" declarations on all of your
variables the first time they are used.


> #Turn off Perl buffering
> $| = 1;
  ^^^^^^
Not sure what the intention of this line is (despite the comment).
It turns of buffering on the currently selected filehandle, which
is the default STDIN.

> #Read and parse the form data
> &ReadParse(*input);

I assume the ampersand is a rudiment from the conversion from Perl4.
Drop it. 
You haven't defined the filehandle "input". Also, it's convention
to make the filehandle identifiers stand out in CAPITALS.

> print &PrintHeader;
> $filename="info.list";

Move this line to the point where the variable will actually be used.

> print &thank_you;
> exit;

OK, here you quit the whole script. But I think you wanted the lines
below also get executed. Either put them in a sub and call the sub
from your main program, or drop the "exit" statement. Remember that
if you don't tell perl to "exit", your program will end gracefully
anyway, when there are no more statements to execute. 

> ##########################################
> #Write form data to file
> open (FILEHANDLER, ">>$filename")  || die ("I am sorry, but I was
> unable to open the file.");

This error will be sent to STDERR; you may want to modify your
script in such a way that the errors will be shown in your browser.
CGI::Carp does this for you.  

> flock (FILEHANDLER, 2);
 . . . . . . . . . . . ^
You may want to replace this with the constant LOCK_EX (but then
you have to "use Fcntl qw(:flock);")

> 
> print FILEHANDLER
> "$input{'sender'}\|$input{'senderemail'}\|$input{'message'}\|";
 . . . . . ^      ^ (etc.)
No need to quote your keys. But this is a minor issue compared to
to the really unclear handling of the %input hash. The only reason
this works is because you invisibly get that hash out of your
ReadParse sub. That's because you passed in a typeglob. This is
not the way to do it. Change the whole thing so the hash will
be the return value (list) of that sub. (In your current
implementation, the sub returns the number of keys, a value that
is of no use,-- proven by that fact that you call ReadParse in
a void context.) 

> 
> flock (FILEHANDLER, 8);
> close (FILEHANDLER);
> ############################
> sub ReadParse {
>   local (*in) = @_ if @_;
 . . ^^^^^
Yes, this is advertised as the way to pass filehandles into subs.
I already explained that you happen use this also to sneak out
your return values from this sub, and proposed a cleaner solution
for that.
I always prefer to pass the filehandle as a simple scalar, as in:

 perldoc -q filehandles

>   local ($i, $key, $val);
 . . ^^^^^
This definitely needs to be "my"!
 
> 
>   # Read in text
>   if (&MethGet) {
>     $in = $ENV{'QUERY_STRING'};
>   }
>   elsif (&MethPost) {
>     read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
>   }
> 
>   @in = split(/[&;]/,$in);
> 
>   foreach $i (0 .. $#in) {
>     # Convert plus's to spaces
>     $in[$i] =~ s/\+/ /g;
>  # Split into key and value.
>     ($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
> 
>     # Convert %XX from hex numbers to alphanumeric
>     $key =~ s/%(..)/pack("c",hex($1))/ge;
>     $key =~ s/<!--(.|\n)*-->//g;
>     $val =~ s/%(..)/pack("c",hex($1))/ge;
>     $val =~ s/<!--(.|\n)*-->//g;
>     # Associate key and value
>     $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple
> separator
>     $in{$key} .= $val;
> 
>   }
> 
>   return scalar(@in);
 . . . . .  ^^^^^^^^^^^
This return value is useless. If you return %in, you can get the
number of keys by doing 
"my %hash = ReadParse($fh); my $numkeys = scalar keys %hash;"

> }

Below you should clean up your commenting, so that it's clear
when a new sub starts. (This is mainly caused by an inconsistent
using of separator lines.) 

> ##################################
> # PrintHeader
> # Returns the magic line which tells WWW that we're an HTML document
> 
> sub PrintHeader {
>   return "Content-type: text/html\n\n";
> }
> # MethGet
> # Return true if this cgi call was using the GET request, false
> otherwise
> 
> sub MethGet {
>   return ($ENV{'REQUEST_METHOD'} eq "GET");
> }
> 
> 
> # MethPost
> # Return true if this cgi call was using the POST request, false
> otherwise
> 
> sub MethPost {
>   return ($ENV{'REQUEST_METHOD'} eq "POST");
> }
> ##############THANK YOU
> sub thank_you {
> return <<EOTHANK;
><html>
> the html code of the result placed here
></html>
> EOTHANK
> }

Hope this helps.


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

Date: Sun, 21 Mar 2004 09:45:23 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: open (FAILEHANDLER, ">>$filename")  what is the rong with that
Message-Id: <405D6436.8AD2207F@acm.org>

Roel van der Steen wrote:
> 
> On Sat, 20 Mar 2004 at 23:29 GMT, Sameh Abdelatef wrote:
> >
> > #Turn off Perl buffering
> > $| = 1;
>   ^^^^^^
> Not sure what the intention of this line is (despite the comment).
> It turns of buffering on the currently selected filehandle, which
> is the default STDIN.

Actually, $| has no effect on buffering.  What it does is turn on
autoflush for the currently selected file handle which flushes the
buffer automatically.  If you want unbuffered IO use
sysopen/sysread/syswrite.



John
-- 
use Perl;
program
fulfillment


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

Date: Sat, 20 Mar 2004 21:19:08 -0800
From: "laststop" <laststop@cwnet.com>
Subject: Re: perl on windows
Message-Id: <105q9gqpdnbjjf3@corp.supernews.com>


"Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message
news:ioN3c.34389$6y1.1105988@news20.bellglobal.com...
>
> "Ben Morrow" <usenet@morrow.me.uk> wrote in message
> news:c2nbrs$re7$1@wisteria.csv.warwick.ac.uk...
> >
> > Quoth "Matt Garrish" <matthew.garrish@sympatico.ca>:
> > >
> > > "chatiman" <chatiman@free.fr> wrote in message
> > > news:404f14a0$0$312$626a14ce@news.free.fr...
> > > > Hello,
> > > >
> > > > I'm willing to write an app for windows with perl having a GUI.
> > > > So here's a few questions :
> > > > - What are the supported libraries for the GUI (gtk ?, qt ?, ... ?)
?
> > >
Don't know much about this but I came across this a recently and it looks
interesting:

http://wxperl.sourceforge.net/




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

Date: Sun, 21 Mar 2004 00:29:02 +0000
From: ben <x@x.x>
Subject: Re: regex (pcre) variable number of (captures)*  - how?
Message-Id: <210320040029021360%x@x.x>

In article <BC81CB08.8C5D%janet@b3p0.com>, Janet <janet@b3p0.com> wrote:

> On 3/20/04 6:51 AM, in article 200320041151138348%x@x.x, "ben" <x@x.x>
> wrote:
> 
> > regarding regular expressions (pcre):
> > 
> > i keep wanting to do this but can't see how to do it: if, within the
> > regex pattern, you repeat a capture, as in rounded brackets followed by
> > a star, the capture results don't increase with the number of loops
> > that the repeating star.
> > 
> > the number or capture result spaces are fixed to the number of pairs of
> > brackets, even if those brackets are set to repleat/loop.
> > 



> > how can this be done? any help much appreciated.
> > 
> You could put the first result into a variable, then add (concatenate) other
> results to it after each capture.  This also keeps you from depending on $1
> (or whatever) later in the program, when it may be rewritten by another
> regex use.

thanks for the reply.

yes i think that's pretty much what Anno was saying -- basically
something outside of the regex pattern - the environment that's
calling/using the regex - is required.


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

Date: Sun, 21 Mar 2004 00:30:38 +0000
From: ben <x@x.x>
Subject: Re: regex (pcre) variable number of (captures)*  - how?
Message-Id: <210320040030387120%x@x.x>

In article <405C8EA6.1070606@rochester.rr.com>, Bob Walton 
> 
> Try:
> 
>      my $input='a b c d e';
>      my @output=$input=~/(\w)\s*/g;
>      print join "\n",@output;

yup that's pretty neat. i'm not actually doing this in perl (i know
this is a perl list so i can hardly compain!)

i've got to try and work out how to simply transpose that to the
language/environment i'm using. (a pcre wrapper in objective-c/cocoa)

the /g means pick up from where it had previously got to right? no /g
and it would keep starting from the start. and @output is an array and
expands to contain as much as it's given i think (i don't know too much
about perl).
but the repetition/loop aspect does come from the regex, not the
outside perl part, which is good - the perl part just takes/accepts
results as they come.

doesn't look like pcre has a /g equivelent. in any case, i'm rambling
-- thanks for that - most helpful.

ben.


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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