[30483] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1726 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 17 03:09:41 2008

Date: Thu, 17 Jul 2008 00:09: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           Thu, 17 Jul 2008     Volume: 11 Number: 1726

Today's topics:
    Re: C linked lists in Perl <smallpond@juno.com>
    Re: C linked lists in Perl <joost@zeekat.nl>
    Re: C linked lists in Perl <jurgenex@hotmail.com>
    Re: C linked lists in Perl <ben@morrow.me.uk>
    Re: C linked lists in Perl <ben@morrow.me.uk>
    Re: C linked lists in Perl <allergic-to-spam@no-spam-allowed.invalid>
    Re: comma quoted lists question <damercer@comcast.net>
    Re: comma quoted lists question <damercer@comcast.net>
        new CPAN modules on Thu Jul 17 2008 (Randal Schwartz)
    Re: Regular Expression Problem <Kryten68@googlemail.com>
    Re: Regular Expression Problem <Kryten68@googlemail.com>
    Re: Regular Expression Problem <npc@zomg.tk>
    Re: Regular Expression Problem <Kryten68@googlemail.com>
    Re: Regular Expression Problem <fawaka@gmail.com>
    Re: Regular Expression Problem <tadmc@seesig.invalid>
    Re: Regular Expression Problem <fawaka@gmail.com>
    Re: String comparison operator trouble <hansmu@xs4all.nl>
    Re: use/require, and variables <tadmc@seesig.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 16 Jul 2008 18:23:44 -0400
From: smallpond <smallpond@juno.com>
Subject: Re: C linked lists in Perl
Message-Id: <55faa$487e7503$29050@news.teranews.com>

cartercc wrote:
> I guess like almost everybody, I like to discuss (argue) the merits of
> different technologies. In my world, the big two are Java and
> ColdFusion. Recently, we had someone with a background in embedded
> systems who has been advocating C. The conversation goes something
> like this:
> 
> him - Does Perl have linked lists?
> me - No.
> him - Therefore, C is better than Perl because it has linked lists.
> me - But Perl has other data structures that are easier to use than
> linked lists.
> him - So what? Perl still doesn't have linked lists.
> 
> I've never studied linked lists and certainly never coded one (in C or
> anything else) but it aroused my curiosity. So after searching on
> c.l.p.m. and online, I decided to see if I couldn't do a linked list
> in Perl. My first  thought is to do something like this:
> 
> %linked_list{$key} = { prev => $linked_list{$prev_key}{prev},
>                                    value => $value,
>                                    next => $linked_list{$next_key}
> {next}  };
> 
> I know that most people will think I'm an absolute moron for thinking
> about this (and they likely would be right), but CAN you do a linked
> list in Perl (never mind that you would never want to), and if so, how
> would you go about it?
> 
> My motive is to say to my C friend, "Nya, nya, nya."
> 
> Thanks, CC.


The main reason for C++ was to hide pointers from your friend.
Programmers cannot be trusted doing their own memory allocation
or linked lists.  Tell him to do what everyone else does, which
is to attack perl on performance.

--S
** Posted from http://www.teranews.com **


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

Date: Thu, 17 Jul 2008 00:58:30 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: C linked lists in Perl
Message-Id: <878ww1cu7d.fsf@zeekat.nl>

cartercc <cartercc@gmail.com> writes:

> I guess like almost everybody, I like to discuss (argue) the merits of
> different technologies. In my world, the big two are Java and
> ColdFusion. Recently, we had someone with a background in embedded
> systems who has been advocating C. The conversation goes something
> like this:
>
> him - Does Perl have linked lists?
> me - No.

Perl does have linked lists at least as much as C does.

my $ll = [ 'bla', [ 'blie', [ 'bloe' ]]];

etc.

But expect perl's garbage collector to get in your face if you create
giant linked lists. Not that you'd want to do that, anyway.

> him - Therefore, C is better than Perl because it has linked lists.
> me - But Perl has other data structures that are easier to use than
> linked lists.

As I said, C doesn't have linked lists either.

> him - So what? Perl still doesn't have linked lists.
>
> I've never studied linked lists and certainly never coded one (in C or
> anything else) but it aroused my curiosity.

Get a copy of "practical common lisp", or browse the book for free
online at http://gigamonkeys.com/book/

It's not about perl, but it *will* show you some interesting uses of
linked lists and teach you the basics of lisp, so good things can be
expected.

-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


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

Date: Wed, 16 Jul 2008 23:06:26 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: C linked lists in Perl
Message-Id: <kjvs749higel5gc3b58num1g8j8o734m15@4ax.com>

xhoster@gmail.com wrote:
>Jürgen Exner <jurgenex@hotmail.com> wrote:
>>
>> >I know that most people will think I'm an absolute moron for thinking
>> >about this (and they likely would be right), but CAN you do a linked
>> >list in Perl (never mind that you would never want to), and if so, how
>>
>> Why wouldn't you want to? It's a totally valid request and if the nature
>> of a problem involves a sequential data structure with frequent add and
>> remove operations then a linked list should be much faster than doing
>> those operations on a large array.
>
>Maybe, but I'm having a hard time thinking up a real problem that would
>benefit in this way.  

Me too :-)

>As long as the add and remove operations are happing
>at or near the ends of the list, you would be hard pressed to implement
>linked lists in Perl that are faster than perl's splice on a large array.
>If you are doing a bunch of adds and removes from the middle of the list,
>then splicing a big array would be more problematic.  But with linked
>lists, getting to the middle is usually a performance problem in the first
>place.

Unless the linked list supports a concept of "current element", i.e. a
current location that could point anywhere in that list. Still, I am
hard pressed to find a real-world application for such data structure.

jue


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

Date: Thu, 17 Jul 2008 01:13:21 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: C linked lists in Perl
Message-Id: <1ef2l5-1q62.ln1@osiris.mauzo.dyndns.org>


Quoth xhoster@gmail.com:
> Jürgen Exner <jurgenex@hotmail.com> wrote:
> >
> > >I know that most people will think I'm an absolute moron for thinking
> > >about this (and they likely would be right), but CAN you do a linked
> > >list in Perl (never mind that you would never want to), and if so, how
> >
> > Why wouldn't you want to? It's a totally valid request and if the nature
> > of a problem involves a sequential data structure with frequent add and
> > remove operations then a linked list should be much faster than doing
> > those operations on a large array.
> 
> Maybe, but I'm having a hard time thinking up a real problem that would
> benefit in this way.

It's important to understand linked lists, though, and know how to
implement them, as they are a simple case of trees.

Ben

-- 
Many users now operate their own computers day in and day out on various
applications without ever writing a program. Indeed, many of these users
cannot write new programs for their machines...
    -- F.P. Brooks, 'No Silver Bullet', 1987             [ben@morrow.me.uk]


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

Date: Thu, 17 Jul 2008 01:17:13 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: C linked lists in Perl
Message-Id: <9lf2l5-1q62.ln1@osiris.mauzo.dyndns.org>


Quoth Joost Diepenmaat <joost@zeekat.nl>:
> 
> Perl does have linked lists at least as much as C does.
> 
> my $ll = [ 'bla', [ 'blie', [ 'bloe' ]]];
> 
> etc.
> 
> But expect perl's garbage collector to get in your face if you create
> giant linked lists.

What do you mean by this? Are you referring to Perl's inability to
collect cyclical garbage (which is not a problem with a singly-linked
list like the one above, but definitely is a problem with a
doubly-linked)? This can be solved with appropriate application of
weakrefs, though it can be a little awkward to work out which refs to
weaken under some circumstances.

Otherwise: what problem does Perl have with large data structures?

Ben

-- 
I have two words that are going to make all your troubles go away.
"Miniature". "Golf".
                                                         [ben@morrow.me.uk]


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

Date: Thu, 17 Jul 2008 08:58:33 +0200 (CEST)
From: Jim Cochrane <allergic-to-spam@no-spam-allowed.invalid>
Subject: Re: C linked lists in Perl
Message-Id: <slrng7trbg.upb.allergic-to-spam@no-spam-allowed.invalid>

On 2008-07-16, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "c" == cartercc  <cartercc@gmail.com> writes:
>
>  c> I guess like almost everybody, I like to discuss (argue) the merits of
>  c> different technologies. In my world, the big two are Java and
>  c> ColdFusion. Recently, we had someone with a background in embedded
>  c> systems who has been advocating C. The conversation goes something
>  c> like this:
>
>  c> him - Does Perl have linked lists?
>  c> me - No.
>  c> him - Therefore, C is better than Perl because it has linked lists.
>  c> me - But Perl has other data structures that are easier to use than
>  c> linked lists.
>  c> him - So what? Perl still doesn't have linked lists.
>
>
> your cow-orker is an idiot. and i say that from 20 years of deep c
> experience (and more with assemblers and other langs) and 15 years of
> perl. he is a total idiot. linked lists are NOT in c. in fact they

As well, the standard C library does not implement linked lists.

> aren't in ANY language. linked lists are a general data structure built
> upon various language constructs. you can make them from a single large
> allocated array (use indexes for links and manage your own ram) or from
> malloced buffers and hard pointers as in c, or in perl with references
> (which are better and safer than pointers).
>...


-- 



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

Date: Wed, 16 Jul 2008 17:26:56 -0500
From: "Dan Mercer" <damercer@comcast.net>
Subject: Re: comma quoted lists question
Message-Id: <-4CdnY9u0PYx6OPVnZ2dnUVZ_sudnZ2d@comcast.com>

"cartercc" <cartercc@gmail.com> wrote in message 
news:ab3658b8-f57b-4277-a49d-92d44062d8fb@i76g2000hsf.googlegroups.com...
>I create and deliver CSV files like this:
> "12345","John","Q","Public","123 Main Street","Anywhere,
> Alaska","800-555-1212"
> I create this in my program as a seven element array. Users modify the
> files, frequently using Excel, and return the files to me.
>
> Sometimes I get the original format back.
>
> Sometimes, Excel will mangle the file to this:
> 12345,John,Q,Public,123 Main Street,"Anywhere, Alaska",800-555-1212
> My script will read this as an eight element array (splitting
> "Anywhere, Alaska" on the comma).
>
> Sometimes Excel will produce a tab delimited file like this:
> 12345 John Q Public 123 Main Street "Anywhere, Alaska" 800-555-1212
> My script will read this as a two element array.
>
> My users like to use Excel and I am not inclined to tell them they
> can't, nor am I inclined to 'educate' them on making sure that Excel
> doesn't change the file format. They honestly need the filtering and
> sorting capabilities that Excel provides, as some of these files are
> 106 columns wide and thousands of rows deep. I have error checking in
> place that rejects improperly formed files, which I define as
> producing anything other than an X element array. However, this isn't
> satisfactory, because I have the burden of reformatting the file.
>
> Comments? Suggestions? Any module that automagically reformats files?
> Will I have to write a reformatting script myself?
>
> Thanks, CC.

If you want eXcel files,  why don't you create them instead of CSV's.
There is plenty of support for excel in perl.  I produce disk usage
reports using Spreadsheet::WriteExcel and it could not be easier.  I even
add a SUM column.

Dan Mercer 



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

Date: Wed, 16 Jul 2008 17:30:34 -0500
From: "Dan Mercer" <damercer@comcast.net>
Subject: Re: comma quoted lists question
Message-Id: <L6-dnXXPX4Qc6-PVnZ2dnUVZ_r7inZ2d@comcast.com>

"cartercc" <cartercc@gmail.com> wrote in message 
news:740f6022-bfa1-44a4-890d-dcba7a9b45b0@25g2000hsx.googlegroups.com...
> On Jul 15, 4:45 pm, Jim Gibson <jimsgib...@gmail.com> wrote:
>> The best solution was already provided: don't ask your users to save
>> their spreadsheets as CSV, tab-delimited, or any other type of file.
>> Ask them to send you their Excel documents and extract the data using
>> the Spreadsheet::ParseExcel module. To me, this is a "no-brainer".
>
> Okay, I got both WriteExcel and ParseExcel, and will play with them
> next week. Just offhand, do you know whether ParseExcel will work with
> Office 2007? Will WriteExcel work with Office 2007? If you know they
> will not, it will save me some time.
>
> Thanks, CC.

Have your users save the file as Excel 2003 format.  That's the format
you'll be providing them.

Dan Mercer



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

Date: Thu, 17 Jul 2008 04:42:22 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Jul 17 2008
Message-Id: <K44vqM.1FIt@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Acme-EyeDrops-1.53
http://search.cpan.org/~asavige/Acme-EyeDrops-1.53/
Visual Programming in Perl 
----
Apache2-Controller-0.0.5
http://search.cpan.org/~markle/Apache2-Controller-0.0.5/
framework for Apache2 handler apps 
----
Apache2-Controller-0.0004
http://search.cpan.org/~markle/Apache2-Controller-0.0004/
framework for Apache2 handler apps 
----
Apache2-Controller-0.4.1
http://search.cpan.org/~markle/Apache2-Controller-0.4.1/
framework for Apache2 handler apps 
----
Benchmark-Timer-0.7101
http://search.cpan.org/~dcoppit/Benchmark-Timer-0.7101/
Benchmarking with statistical confidence 
----
CGI-Cache-1.4201
http://search.cpan.org/~dcoppit/CGI-Cache-1.4201/
Perl extension to help cache output of time-intensive CGI scripts 
----
CORBA-C-2.62
http://search.cpan.org/~perrad/CORBA-C-2.62/
----
CORBA-Perl-0.43
http://search.cpan.org/~perrad/CORBA-Perl-0.43/
----
CORBA-Python-2.64
http://search.cpan.org/~perrad/CORBA-Python-2.64/
----
CORBA-XS-0.62
http://search.cpan.org/~perrad/CORBA-XS-0.62/
----
CORBA-XS.0.62
http://search.cpan.org/~perrad/CORBA-XS.0.62/
----
CPAN-Reporter-1.16_50
http://search.cpan.org/~dagolden/CPAN-Reporter-1.16_50/
Adds CPAN Testers reporting to CPAN.pm 
----
CPAN-Reporter-1.16_51
http://search.cpan.org/~dagolden/CPAN-Reporter-1.16_51/
Adds CPAN Testers reporting to CPAN.pm 
----
CPANPLUS-YACSmoke-0.01_01
http://search.cpan.org/~bingos/CPANPLUS-YACSmoke-0.01_01/
Yet Another CPANPLUS Smoke Tester 
----
Cache-CacheFactory-1.07
http://search.cpan.org/~sgraham/Cache-CacheFactory-1.07/
factory class for Cache::Cache and other modules. 
----
Catalyst-Action-Wizard-0.005
http://search.cpan.org/~davinchi/Catalyst-Action-Wizard-0.005/
actions like realization of wizards. You need this if you have some multi-actions data gathering which unlikely to be saved in session and to big to pass them as POST or GET parameters. 
----
Catalyst-Model-CouchDB-0.01
http://search.cpan.org/~rberjon/Catalyst-Model-CouchDB-0.01/
CouchDB model class for Catalyst 
----
Catalyst-Plugin-Authentication-Store-DBIC-0.11
http://search.cpan.org/~mstrout/Catalyst-Plugin-Authentication-Store-DBIC-0.11/
**DEPRECATED** Authentication and authorization against a DBIx::Class or Class::DBI model. 
----
Class-DBI-Lite-0.001
http://search.cpan.org/~johnd/Class-DBI-Lite-0.001/
Lightweight ORM for Perl 
----
Crypt-ECB-1.45
http://search.cpan.org/~appel/Crypt-ECB-1.45/
Encrypt Data using ECB Mode 
----
DBIx-Class-0.08099_03
http://search.cpan.org/~lsaunders/DBIx-Class-0.08099_03/
Extensible and flexible object <-> relational mapper. 
----
DateTime-Format-CLDR-1.01
http://search.cpan.org/~maros/DateTime-Format-CLDR-1.01/
Parse and format CLDR time patterns 
----
Devel-StackTrace-1.1902
http://search.cpan.org/~drolsky/Devel-StackTrace-1.1902/
Stack trace and stack trace frame objects 
----
File-Stream-2.20
http://search.cpan.org/~smueller/File-Stream-2.20/
Regular expression delimited records from streams 
----
FileHandle-Unget-0.1622
http://search.cpan.org/~dcoppit/FileHandle-Unget-0.1622/
FileHandle which supports multi-byte unget 
----
Games-SGF-0.07
http://search.cpan.org/~whitcode/Games-SGF-0.07/
A general SGF parser 
----
Geometry-Primitive-0.03
http://search.cpan.org/~gphat/Geometry-Primitive-0.03/
Primitive Geometry Entities 
----
Getargs-Long-1.1003
http://search.cpan.org/~dcoppit/Getargs-Long-1.1003/
Named subroutine arguments, with optional type checking 
----
Graphics-Primitive-0.03
http://search.cpan.org/~gphat/Graphics-Primitive-0.03/
Device and library agnostic graphics objects 
----
Gtk2-Ex-ListModelConcat-1
http://search.cpan.org/~kryde/Gtk2-Ex-ListModelConcat-1/
concatenated list models 
----
Gtk2-Ex-TreeModelFilter-DragDest-1
http://search.cpan.org/~kryde/Gtk2-Ex-TreeModelFilter-DragDest-1/
drag destination mix-in for TreeModelFilter subclasses 
----
HTML-ParseBrowser-1_0
http://search.cpan.org/~dodger/HTML-ParseBrowser-1_0/
Simple interface for User Agent string parsing. 
----
HTML-ScriptLoader-1.00
http://search.cpan.org/~hovenko/HTML-ScriptLoader-1.00/
Perl extension for loading scripts on a web page 
----
HTML-ScriptLoader-1.01
http://search.cpan.org/~hovenko/HTML-ScriptLoader-1.01/
Perl extension for loading scripts on a web page 
----
HTML-Tested-ClassDBI-0.19
http://search.cpan.org/~bosu/HTML-Tested-ClassDBI-0.19/
Enhances HTML::Tested to work with Class::DBI 
----
IO-Socket-SSL-1.14
http://search.cpan.org/~sullr/IO-Socket-SSL-1.14/
Nearly transparent SSL encapsulation for IO::Socket::INET. 
----
JSON-2.12
http://search.cpan.org/~makamaka/JSON-2.12/
JSON (JavaScript Object Notation) encoder/decoder 
----
Kwalify-1.18
http://search.cpan.org/~srezic/Kwalify-1.18/
Kwalify schema for data structures 
----
Kwiki-Archive-Cvs-0.103
http://search.cpan.org/~josephw/Kwiki-Archive-Cvs-0.103/
Kwiki Page Archival Using CVS 
----
Layout-Manager-0.06
http://search.cpan.org/~gphat/Layout-Manager-0.06/
2D Layout Management 
----
Module-Metadata-Changes-1.02
http://search.cpan.org/~rsavage/Module-Metadata-Changes-1.02/
Manage a module's machine-readable Changelog.ini file 
----
MojoMojo-0.999018
http://search.cpan.org/~mramberg/MojoMojo-0.999018/
A Catalyst & DBIx::Class powered Wiki. 
----
MooseX-App-Cmd-0.03
http://search.cpan.org/~dmaki/MooseX-App-Cmd-0.03/
Mashes up MooseX::Getopt and App::Cmd. 
----
MooseX-Q4MLog-0.00001
http://search.cpan.org/~dmaki/MooseX-Q4MLog-0.00001/
Log Data To Q4M 
----
MooseX-Q4MLog-0.00002
http://search.cpan.org/~dmaki/MooseX-Q4MLog-0.00002/
Log Data To Q4M 
----
Muldis-D-0.41.0
http://search.cpan.org/~duncand/Muldis-D-0.41.0/
Formal spec of Muldis D relational DBMS lang 
----
Mvalve-0.00010
http://search.cpan.org/~dmaki/Mvalve-0.00010/
Generic Q4M Powered Message Pipe 
----
MySQL-Slurp-0.16
http://search.cpan.org/~ctbrown/MySQL-Slurp-0.16/
Use PIPEs to import a file into MySQL table. 
----
Net-DBus-Skype-0.02
http://search.cpan.org/~ecarroll/Net-DBus-Skype-0.02/
Perl access to Skype's DBus API 
----
Net-SFTP-Foreign-1.41
http://search.cpan.org/~salva/Net-SFTP-Foreign-1.41/
SSH File Transfer Protocol client 
----
Object-eBay-0.3.2
http://search.cpan.org/~mndrix/Object-eBay-0.3.2/
Object-oriented interface to the eBay API 
----
POE-Component-CPANPLUS-YACSmoke-1.32
http://search.cpan.org/~bingos/POE-Component-CPANPLUS-YACSmoke-1.32/
Bringing the power of POE to CPAN smoke testing. 
----
POE-Component-CPANPLUS-YACSmoke-1.34
http://search.cpan.org/~bingos/POE-Component-CPANPLUS-YACSmoke-1.34/
Bringing the power of POE to CPAN smoke testing. 
----
POE-Filter-JSON-Incr-0.02
http://search.cpan.org/~nuffin/POE-Filter-JSON-Incr-0.02/
Parse JSON from streams without needing per-line input 
----
Path-Router-0.03
http://search.cpan.org/~stevan/Path-Router-0.03/
A tool for routing paths 
----
Perl-Critic-Pulp-5
http://search.cpan.org/~kryde/Perl-Critic-Pulp-5/
some add-on perlcritic policies 
----
Perl-Dist-1.02
http://search.cpan.org/~adamk/Perl-Dist-1.02/
Perl Distribution Creation Toolkit 
----
Search-Xapian-1.0.7.0
http://search.cpan.org/~olly/Search-Xapian-1.0.7.0/
Perl XS frontend to the Xapian C++ search library. 
----
XML-Grammar-Fortune-0.01
http://search.cpan.org/~shlomif/XML-Grammar-Fortune-0.01/
convert the FortunesXML grammar to other formats and from plaintext. 
----
XML-RelaxNG-Compact-PXB-0.08
http://search.cpan.org/~mpg/XML-RelaxNG-Compact-PXB-0.08/
create perl XML (RelaxNG Compact) data binding API 
----
threads-shared-1.26
http://search.cpan.org/~jdhedden/threads-shared-1.26/
Perl extension for sharing data structures between threads 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Wed, 16 Jul 2008 15:12:15 -0700 (PDT)
From: Kryten <Kryten68@googlemail.com>
Subject: Re: Regular Expression Problem
Message-Id: <1f51cd29-e7ce-4bdb-a30c-48a3649c7d82@l42g2000hsc.googlegroups.com>

Thanks Dave!
Appreciated.


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

Date: Wed, 16 Jul 2008 15:14:22 -0700 (PDT)
From: Kryten <Kryten68@googlemail.com>
Subject: Re: Regular Expression Problem
Message-Id: <c65039ec-4bba-4500-b9b5-5b76ed85ebb5@y38g2000hsy.googlegroups.com>

Thanks Leon.
I appreciate the advice.
Cheers,
Stuart

> In case of positive lookbehind you first search for bananas, and then you
> look back to see if it is preceded by orange. You could use that here,
> but I don't think that that approach is necessary. A simple
> /orangebananas/ would do fine too. Unless mismatching 'orange' is very
> expensive and frequent, I wouldn't recommend using using lookbehinds.
>
> Leon Timmermans



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

Date: Thu, 17 Jul 2008 00:17:16 +0200 (CEST)
From: npc <npc@zomg.tk>
Subject: Re: Regular Expression Problem
Message-Id: <g5ls1c$vde$1@aioe.org>


>> is this positive lookbehind? Or am I getting my regex terms mixed up?
> 
> Yes, you need something like
> 
> /(?<=oranges)bananas/
> 
> (tweak as needed)

forgive my naivity, whats wrong with:

/orangesbananas/

?


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

Date: Wed, 16 Jul 2008 16:01:43 -0700 (PDT)
From: Kryten <Kryten68@googlemail.com>
Subject: Re: Regular Expression Problem
Message-Id: <d47e534f-3cf6-49ff-be36-d5abac06836f@k30g2000hse.googlegroups.com>

Hi,

To be completely truthful with you...nothing at all.

Actually I'm learning Powershell but had noticed that the denizens of
this group seemed to really
know their Regular Expressions so I thought I'd ask here as the
concepts seem pretty similar.

I'm trying to figure out a way to break a text string into smaller
text strings, where a simple .split() method won't do it.

Eg. If  I have (forgive the $ prefix, but it's the only way I know to
express it!)

$a = "tty01 17 07 08 15:45 sch0999 some more text here"

I want to find a way to carve off "tty01 17 07 08 15:45" into one
variable.
"sch0999" into another variable (this is the important one) and lastly
"some more text here" into the last variable.

So that I can then go back and process the "sch0999" string later.

Now, I will never know what sch0999 wil look like exactly but I can
describe what it will look like as the regex : "\w{3}\d{4}"
and while I will never know what is going to precede it exactly, I do
know that it will be the time plus whitespace : "\d{2}:\d{2}.+".

I don't know much about regex at all! But I had *heard* of positive
lookbehind and it sounded about right for what I'll need to do, that
is do a positive lookbehind for the first regex on the basis the
second can  be matched as well.

I'm haven't finished "Mastering Regular Expressions" yet .. so if I'm
getting this all wrong please be gentle!

Thanks,

Stuart




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

Date: Thu, 17 Jul 2008 01:27:33 +0200
From: Leon Timmermans <fawaka@gmail.com>
Subject: Re: Regular Expression Problem
Message-Id: <bc7a$487e83e5$89e0e08f$2685@news1.tudelft.nl>

On Wed, 16 Jul 2008 16:01:43 -0700, Kryten wrote:
> 
> Actually I'm learning Powershell but had noticed that the denizens of
> this group seemed to really
> know their Regular Expressions so I thought I'd ask here as the concepts
> seem pretty similar.
> 

LOL. Yeah, since there is no regular expressions newsgroup this would 
probably be the one where you'll get most response on such a question.

> I want to find a way to carve off "tty01 17 07 08 15:45" into one
> variable.
> "sch0999" into another variable (this is the important one) and lastly
> "some more text here" into the last variable.
> 

The easiest regexp for that would be: /^(.*?) (\w{3}\d{4}) (.*)/ . No 
lookbehinds needed for that.

Leon Timmermans


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

Date: Wed, 16 Jul 2008 19:28:24 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Regular Expression Problem
Message-Id: <slrng7t4h8.624.tadmc@tadmc30.sbcglobal.net>

Leon Timmermans <fawaka@gmail.com> wrote:
> On Wed, 16 Jul 2008 16:01:43 -0700, Kryten wrote:
>> 
>> Actually I'm learning Powershell but had noticed that the denizens of
>> this group seemed to really
>> know their Regular Expressions so I thought I'd ask here as the concepts
>> seem pretty similar.
>> 
>
> LOL. Yeah, since there is no regular expressions newsgroup this would 
> probably be the one where you'll get most response on such a question.
>
>> I want to find a way to carve off "tty01 17 07 08 15:45" into one
>> variable.
>> "sch0999" into another variable (this is the important one) and lastly
>> "some more text here" into the last variable.
>> 
>
> The easiest regexp for that would be: /^(.*?) (\w{3}\d{4}) (.*)/ . No 
> lookbehinds needed for that.


But what if the pattern matches "too early", as with:

   tty0001 17 07 08 15:45 sch0999 other stuff

 ...then we _are_ back to needing look-around.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Thu, 17 Jul 2008 03:05:40 +0200
From: Leon Timmermans <fawaka@gmail.com>
Subject: Re: Regular Expression Problem
Message-Id: <37eb6$487e9ae4$89e0e08f$2685@news1.tudelft.nl>

On Wed, 16 Jul 2008 19:28:24 -0500, Tad J McClellan wrote:
> 
> 
> But what if the pattern matches "too early", as with:
> 
>    tty0001 17 07 08 15:45 sch0999 other stuff
> 
> ...then we _are_ back to needing look-around.

No, it doesn't. My regexp requires spaces around the main word ;-).

Leon Timmermans


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

Date: Thu, 17 Jul 2008 01:11:40 +0200
From: Hans Mulder <hansmu@xs4all.nl>
Subject: Re: String comparison operator trouble
Message-Id: <487e806c$0$14347$e4fe514c@news.xs4all.nl>

szr wrote:
> Jürgen Exner wrote:
>> Dave B <daveb@addr.invalid> wrote:

>>> $item == undef

> I get a different set of warnings (using both 5.10.0 and 5.8.8)
> 
>   $ perl5.8.8 -Mstrict -Mwarnings -we 'my $x = 1; print +($x == undef ? 
> "[undef]" : "[$x]"), "\n";'
>   Warning: Use of "undef" without parentheses is ambiguous at -e line 1.
>   Search pattern not terminated or ternary operator parsed as search 
> pattern at -e line 1.
> 
> I'm not sure where it's getting "Search pattern from, but I'm guessing 
> this has something to do with using  (if ? then : else)  instead of 
> if{}else{}  ?

The "undef" operator takes an argument if it can find one.
If the first non-whitespace character after "undef" is a "?",
then the parser assumes this is a ??-style pattern match.

In this case, there is no closing "?".  If there were one, then
you'd get a message that "undef" wants an lvalue argument and
pattern matches are not lvalues.

As the other warning points out, you can avoid this kind of mis-
parse by writing "undef()".

In theory you can leave out the parentheses if the next character
is a one that cannot be the first in an expression (such as ";").
This only works if you know about obscure kinds of expressions
(such as *globs and ??-patterns).

For example, you might think that "undef * 5" looks like multiplication,
but perl interprets this as undef(*5).  As it happens, *5 is an lvalue,
so this will "work" (for some definition of "work").

Don't try this at home, kids.

-- HansM



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

Date: Wed, 16 Jul 2008 19:18:43 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: use/require, and variables
Message-Id: <slrng7t3v3.624.tadmc@tadmc30.sbcglobal.net>

Nick Wedd <nick@maproom.co.uk> wrote:
> In message <slrng7qbl3.qdt.tadmc@tadmc30.sbcglobal.net>, Tad J McClellan 
><tadmc@seesig.invalid> writes
>>Nick Wedd <nick@maproom.co.uk> wrote:
>>
>>
>>> Thank you!  Using "our" works and is compatible with "use strict".  I
>>> must look up what "our" does,
>>
>>
>>Do that with:
>>
>>   perldoc -f our
>>
>>then you will be reading documentation that matches whatever
>>version of perl you have.
>
> Thanks.  I've now read it, I am trying to understand it ...
>
>>> it seems to be more recent than my
>>> reference books.
>>
>>
>>Then your reference books must be more than 8 years old...
>
> They are.  Publication dates are 1997, 1997, 1999.  Can you recommend a 
> single modern book on Perl, suitable for someone with general 
> programming knowledge, but little understanding of Perl?


I don't recommend any book as a primary reference to Perl.

I recommend(ed above) the documentation that ships with
the perl distribution as the primary Perl reference.  :-)

You can even use my primary reference to identify secondary references:

   perldoc -q book
   perldoc perlbook


For a reference book, I'd go with the Camel book ("Programming Perl").

If you're looking for a tutorial rather than a reference,
then "Learning Perl" seems to fit the bill.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

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 V11 Issue 1726
***************************************


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