[27969] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9333 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 21 14:05:54 2006

Date: Wed, 21 Jun 2006 11:05:09 -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           Wed, 21 Jun 2006     Volume: 10 Number: 9333

Today's topics:
        ANN: Spreadsheet::Read 0.15 <h.m.brand@xs4all.nl>
        extracting regular expressions  <nospam@home.com>
    Re: extracting regular expressions  <rvtol+news@isolution.nl>
    Re: extracting regular expressions <xicheng@gmail.com>
    Re: extracting regular expressions kenslaterpa@hotmail.com
    Re: extracting regular expressions <rvtol+news@isolution.nl>
    Re: File::Find - passing argument to &wanted <tzz@lifelogs.com>
    Re: Find repeating substring <xicheng@gmail.com>
    Re: Find repeating substring <David.Squire@no.spam.from.here.au>
    Re: Find repeating substring <xicheng@gmail.com>
    Re: How to pronounce $ <penryu@saiyix.ath.cx>
    Re: How to pronounce $ <penryu@saiyix.ath.cx>
    Re: How to pronounce $ <benmorrow@tiscali.co.uk>
    Re: how to replace this like <img width=100 ...> with < <xicheng@gmail.com>
    Re: How to select subroutine <glennj@ncf.ca>
    Re: Looping through Class::Accessor accessors <dbasch@yahoo.com>
    Re: problem in calling program in my perl script krakle@visto.com
    Re: Reading the first .jpg file from a .rar archive? <DJStunks@gmail.com>
    Re: Reading the first .jpg file from a .rar archive? lawrence@hummer.not-here.net
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 21 Jun 2006 16:40:28 GMT
From: "H.Merijn Brand" <h.m.brand@xs4all.nl>
Subject: ANN: Spreadsheet::Read 0.15
Message-Id: <J1804E.H8F@zorch.sf-bay.org>

The URL

     http://www.xs4all.nl/~hmbrand/Spreadsheet-Read-0.15.tgz

has entered CPAN as

   file: $CPAN/authors/id/H/HM/HMBRAND/Spreadsheet-Read-0.15.tgz
   size: 38966 bytes
    md5: 252e37edfe2cd2a46f9d34f30ad97d69

NAME
        Spreadsheet::Read $,1x2(B Meta$,1x2(BWrapper for reading spreadsheet data

SYNOPSYS
          use Spreadsheet::Read;
          my $ref = ReadData ("file.xls");

DESCRIPTION
        Spreadsheet::Read offers a uniformed wrapper to
Spreadsheet::ParseExcel
        and Spreadheet::ReadSXC to give the end$,1rp(Buser a single point of view  to
        various types of spreadsheets and deal with these in a transparent
way.

        See for more thorrough documentation the pod in the module, or

          $ man Spreadsheet::Read

        after installation

Revision history for Spreadsheet::Read

0.15    Wed 21 Jun 2006

     - Small doc change from AnnoCPAN
     - Sheets with undefined labels might cause havoc
     - Clip now skips empty xls sheets (TODO: sxc)
     - xlscat clips by default
     - xlscat new options -d and --noclip
     - xlscat usage () from -?/--help to STDOUT from fault to STDERR

0.14    Fri 20 Jan 2006

     - maxrow and maxcol were swapped in csv sheets
     - promoted internal debug flag to option
     - small doc changes

0.13    Thu 04 Nov 2005

     - Control attrib 'cells' was misinterpreted
     - New option: clip, default is true if {cell} is selected, false
otherwise
       Removes trailing lines and columns in each sheet that have no  visible
data
     - new test t/11_call.t for checking options. Not complete yet
     - Added test_cover target to Makefile.PL




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

Date: Wed, 21 Jun 2006 16:25:27 GMT
From: "Nospam" <nospam@home.com>
Subject: extracting regular expressions 
Message-Id: <Xpemg.53270$uP.36108@newsfe2-gui.ntli.net>

I am wondering say I had a string, en email address sample@example.com and I
wanted to ignore everything from the @ and place in a variable, would
something like this suffice:

#! usr/bin/perl
use warnings;
use strict;
my $var1= sample@example.com;

my $var2 = $var !=~ m/(\@*.$)(.*)/s;

however I am not making any progress and looking at perltut I am unable to
find a regular expression to do just this




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

Date: Wed, 21 Jun 2006 19:53:41 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: extracting regular expressions 
Message-Id: <e7c89s.1fk.1@news.isolution.nl>

Nospam schreef:

> say I had a string, en email address
> sample@example.com and I wanted to ignore everything from the @ and
> place in a variable

  perl -le '"sample\@example.com" =~ /^([^@]+)/ and print $1'

-- 
Affijn, Ruud

"Gewoon is een tijger."




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

Date: 21 Jun 2006 09:38:53 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: extracting regular expressions
Message-Id: <1150907933.364748.49710@i40g2000cwc.googlegroups.com>

Nospam wrote:
> I am wondering say I had a string, en email address sample@example.com and I
> wanted to ignore everything from the @ and place in a variable, would
> something like this suffice:
>
> #! usr/bin/perl
> use warnings;
> use strict;
> my $var1= sample@example.com;
>
> my $var2 = $var !=~ m/(\@*.$)(.*)/s;
>
> however I am not making any progress and looking at perltut I am unable to
> find a regular expression to do just this

(my $var2 = $var1) = ~s/\@.*//;

this will assign 'sample' to $var2

Xicheng



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

Date: 21 Jun 2006 10:11:32 -0700
From: kenslaterpa@hotmail.com
Subject: Re: extracting regular expressions
Message-Id: <1150909892.023970.50110@y41g2000cwy.googlegroups.com>


Nospam wrote:
> I am wondering say I had a string, en email address sample@example.com and I
> wanted to ignore everything from the @ and place in a variable, would
> something like this suffice:
>
> #! usr/bin/perl
> use warnings;
> use strict;
> my $var1= sample@example.com;
>
> my $var2 = $var !=~ m/(\@*.$)(.*)/s;
>
> however I am not making any progress and looking at perltut I am unable to
> find a regular expression to do just this

/(\@*.$)(.*)/  this appears to require 0 or more '@' characters, then
any single character,
the end of the line, then 0 or more characters of any type.
And I'm not sure what "!=~" is.

There are many ways to do what you want. Another way:

use strict;
use Warnings;

my ($var2,$var3);
my $var1= "sample\@example.com";
print ">>$var2<< >>$var3<<\n"
   if (($var2,$var3) = $var1 =~ m/\s*([^@]*)@(\S*)/);

OUTPUT: ">>sample<< >>example.com<<"

Ken



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

Date: Wed, 21 Jun 2006 19:51:04 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: extracting regular expressions
Message-Id: <e7c80f.1co.1@news.isolution.nl>

kenslaterpa@hotmail.com schreef:

> use Warnings;

YMM: use warnings ;

-- 
Affijn, Ruud

"Gewoon is een tijger."




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

Date: Wed, 21 Jun 2006 11:38:51 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: File::Find - passing argument to &wanted
Message-Id: <g69hd2ezfg4.fsf@CN1374059D0130.kendall.corp.akamai.com>

On 20 Jun 2006, David.Squire@no.spam.from.here.au wrote:

Ted Zlatanov wrote:
>
> [snip]
>
>>
>> This and other things you said are pretty unfair.  I know Perl, I've
>> used PHP, and they do different things well.  Disdain for an entire
>> community (PHP or others) is not productive.  Emacs Lisp doesn't have
>> namespaces, does that make it a kiddie language?  Assembler doesn't
>> have <insert feature here>, does that make it primitive?
>
> Yes. Almost by definition.
>
> That's not to say that there aren't times when it's the right
> choice. But it's primative as F**K.

Horses can't go as fast, as far, or as cheaply as cars, does that make
them primitive?

You are looking at words, not my line of reasoning.  By Uri's
reasoning Emacs Lisp would be a kiddie language because it has no
namespaces and many other Perl features.  I'm saying Assembler is
primitive when you just look at features, but that's not the point,
and concentrating on the features rather than the whole picture of a
language is bound to give a false image.  Derisive terms such as
"kiddie" or "primitive" are not technical, and I guess that's what
bothered me in Uri's original tirade, that it took a limited view and
turned it into derision for an entire community.

I hope that explains my thoughts better.

Ted


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

Date: 21 Jun 2006 09:33:51 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: Find repeating substring
Message-Id: <1150907631.896759.97000@u72g2000cwu.googlegroups.com>

Mike wrote:
> >
> > What makes you think that REs in one language will function like those
> > in another? [1]
> >
> > DS
> >
> > [1] Deliberatively provocative.
>
> I don't expect them to function 'exactly' alike, but I was kind of
> expecting similar.... Regular expressions are pretty much like
> everything else in my life -- I need to get better at them.

In fact, if you don't use embedded code in Perl, named captures,
balanced groupings in C#(C# may also have variable-length look behind),
and some other minor differences, the regex patterns for these two
tools are about the same.. (more importantly, they are using the same
Traditional NFA regex engin).

Xicheng



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

Date: Wed, 21 Jun 2006 17:57:58 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Find repeating substring
Message-Id: <e7btqm$5d5$1@news.ox.ac.uk>

Xicheng Jia wrote:
> Mike wrote:
>>> What makes you think that REs in one language will function like those
>>> in another? [1]
>>>
>>> DS
>>>
>>> [1] Deliberatively provocative.
>> I don't expect them to function 'exactly' alike, but I was kind of
>> expecting similar.... Regular expressions are pretty much like
>> everything else in my life -- I need to get better at them.
> 
> In fact, if you don't use embedded code in Perl, named captures,
> balanced groupings in C#(C# may also have variable-length look behind),
> and some other minor differences, the regex patterns for these two
> tools are about the same.. (more importantly, they are using the same
> Traditional NFA regex engin).

 ... and yet regexes in sed, vi, etc. are subtly different from those in 
Perl. It's never a good idea to assume equivalence. Those little 
differences can cause much puzzlement otherwise.

DS


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

Date: 21 Jun 2006 10:16:25 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: Find repeating substring
Message-Id: <1150910185.738210.266310@g10g2000cwb.googlegroups.com>

David Squire wrote:
> Xicheng Jia wrote:
> > Mike wrote:
> >>> What makes you think that REs in one language will function like those
> >>> in another? [1]
> >>>
> >>> DS
> >>>
> >>> [1] Deliberatively provocative.
> >> I don't expect them to function 'exactly' alike, but I was kind of
> >> expecting similar.... Regular expressions are pretty much like
> >> everything else in my life -- I need to get better at them.
> >
> > In fact, if you don't use embedded code in Perl, named captures,
> > balanced groupings in C#(C# may also have variable-length look behind),
> > and some other minor differences, the regex patterns for these two
> > tools are about the same.. (more importantly, they are using the same
> > Traditional NFA regex engin).
>
> ... and yet regexes in sed, vi, etc. are subtly different from those in
> Perl. It's never a good idea to assume equivalence. Those little
> differences can cause much puzzlement otherwise.

While I didnt say that the same engine must have exactly the same
implementations. the engine just tell how it works inside, right?.. If
you've read references about traditional NFA regexes like Perl, C#
 .NET, Java, Python, Javascript, and I do think switching patterns from
one flavor to another is not a huge deal.. :-)

BTW. vim? is using DFA engine. 

Xicheng



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

Date: Wed, 21 Jun 2006 15:34:08 GMT
From: Tim Hammerquist <penryu@saiyix.ath.cx>
Subject: Re: How to pronounce $
Message-Id: <slrne9ipng.1h2f.penryu@ruri.saiyix>

Dr.Ruud <rvtol+news@isolution.nl> wrote:
> Tim Hammerquist schreef:
>
>> AFAICT, the accepted standard, as mentioned elsewhere in this thread,
>> is "$tring" and "@rray".  Try that.
>
> ITYM: $calar and @rray

Did I do it again?!  $%#@&*!

Yes. "$calar" and "@rray".  Apologies.

Tim Hammerquist


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

Date: Wed, 21 Jun 2006 16:27:23 GMT
From: Tim Hammerquist <penryu@saiyix.ath.cx>
Subject: Re: How to pronounce $
Message-Id: <slrne9isrb.1h2f.penryu@ruri.saiyix>

Tim Hammerquist <penryu@saiyix.ath.cx> wrote:
> AFAICT, the accepted standard, as mentioned elsewhere in this thread,
> is "$tring" and "@rray".  Try that.
      ^^^^^^
>
> And as for the lingering BASIC contamination, I know a great
> therapist...

/me fires his therapist.

Tim Hammerquist


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

Date: Wed, 21 Jun 2006 17:52:56 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: How to pronounce $
Message-Id: <84aom3-sm2.ln1@osiris.mauzo.dyndns.org>


Quoth "Hobo Salesman" <hobosalesman@gmail.com>:
> Tim Hammerquist wrote:
> > I sympathize.  Due to my own unfortunate (read: catastrophic) TRS-80
> > BASIC incident years back, I too still find myself pronouncing '$' as
> > "string"... even in Perl.
> 
> Ha, thanks, now I don't feel so bad. It wouldn't be so bad if it were a
> throwback from a respectable language, but I feel like if I said it to
> someone they'd roll their eyes and expect my next question to be what
> Perl's equivalent of "goto" is...

Err... goto ?

Now, GOSUB is a different matter... (/me cringes in recollection)

Ben

-- 
   If you put all the prophets,   |   You'd have so much more reason
   Mystics and saints             |   Than ever was born
   In one room together,          |   Out of all of the conflicts of time.
benmorrow@tiscali.co.uk                             The Levellers, 'Believers'


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

Date: 21 Jun 2006 09:11:54 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: how to replace this like <img width=100 ...> with <img width="100" ...>
Message-Id: <1150906314.824220.207530@m73g2000cwd.googlegroups.com>

zhanye815@gmail.com wrote:
> i want to write a script to convert the html to xhtml,so i want to use
> the regular expression to solve some problem like <img width=100
> height=100...> converting into <img width="100" height="100"...>.how to
> do it?

Although it should be more reliable to handle your problem with some
CPAN modules. But trying it by yourself doesnt hurt. you can learn
something from either way. here is a trail solution for you:
#################
use strict;
use warnings;

local $/ = undef;
my $paren = qr/"[^"]*"|'[^']*'/;
while (my $line = <ARGV>) {
    $line =~ s{($paren)|(<(?:$paren|[^>"'])*>)}{$1 or func($2)}ge;
    print $line;
}

sub func {
    my $x = shift;
    $x =~ s/(\w+)\s*=\s*([^'"\s>]+)/$1="$2"/g;
    $x;
}
##################
if you need to consider the escaped bouble-quotes or apostrophes, like
"he say\"hello!\".", then you may want to change "[^"]" in $paren to
some more complex form, like:

    "[^"\\]*(?:\\.[^"\\]*)*"

similar to the other part.

Good luck
Xicheng



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

Date: 21 Jun 2006 16:20:45 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: How to select subroutine
Message-Id: <slrne9iset.ee4.glennj@smeagol.ncf.ca>

At 2006-06-20 08:17PM, James <hoosier45678@hotmail.com> wrote:
>  	my $output = handler{$function}->(@ARGUMENTS);
missing $ -----------^

-- 
Glenn Jackman
Ulterior Designer


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

Date: 21 Jun 2006 10:28:05 -0700
From: "Derek Basch" <dbasch@yahoo.com>
Subject: Re: Looping through Class::Accessor accessors
Message-Id: <1150910885.308194.286830@m73g2000cwd.googlegroups.com>

attn.steven.kuo@gmail.com wrote:
> Derek Basch wrote:
> > Hi Everyone,
> >
> > I began using Class::DBI and love it. However, there are situations
> > where I want to loop through the Class::Accessor accessors for an
> > object and also get the name of the accessor as I loop through.

Thanks for all the help Steven.

However, the solution suddenly occured to me last night. I was
declaring my accessors with the 'columns' function of the Class::DBI
module. Therefore, there must be a hash or something somewhere to loop
over. I found that Class::DBI objects have various column retrieval
functions. I used the 'all_columns' function that returns the column
names. Works great :).


sub test {
  my @gpsaccounts = Members::Gpsaccounts->search($user_id);
  foreach my $row (@gpsaccounts) {
    foreach my $column ($row->all_columns()) {
      print $column . "\n";
    }
  }

Derek Basch



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

Date: 21 Jun 2006 08:50:42 -0700
From: krakle@visto.com
Subject: Re: problem in calling program in my perl script
Message-Id: <1150905042.108646.311010@p79g2000cwp.googlegroups.com>


debbie523 wrote:
> krakle@visto.com wrote:
> >
> > Does p1.exe even exist to execute?
> yes, it does exist. But it looks like not called by my perl program.
> Because I can't see welcome printed in my op.txt file. But if I run it
> in windows, it works good.

<input type="text" name="president" value="George Bush">

The form inputs name is "president". To get the value (George Bush) in
a Perl CGI script you must fetch the parameter by name like so:

my $president = $query->param("president");

print $president; # Prints George Bush

Your script is attempting to fetch parameters by names that don't
exist. Your inputs should include the "name" attribute like the above
example..



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

Date: 21 Jun 2006 09:15:58 -0700
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Reading the first .jpg file from a .rar archive?
Message-Id: <1150906558.307538.123700@p79g2000cwp.googlegroups.com>


K P S wrote:
> Can someone please point me to a small script to read the first .jpg
> file from a .rar archive?  I would like to create thumbnails of an
> archive based on the first image file in the archive.

define "first"

-jp



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

Date: 21 Jun 2006 09:31:03 -0700
From: lawrence@hummer.not-here.net
Subject: Re: Reading the first .jpg file from a .rar archive?
Message-Id: <87wtbafp2w.fsf@hummer.i-did-not-set--mail-host-address--so-shoot-me>

"DJ Stunks" <DJStunks@gmail.com> writes:
> K P S wrote:
> > Can someone please point me to a small script to read the first .jpg
> > file from a .rar archive?  I would like to create thumbnails of an
> > archive based on the first image file in the archive.
> 
> define "first"

1. The ordinal number matching the number one in a series.
2. The one coming, occurring, or ranking before or above all others.

While I've never heard of a 'rar' archive, I'm guessing that like most
archive formats, it has a list of files in the header/trailer -- so
the 'first' would be that filename that matches .jpg$ before any
other. 

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
	Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.


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

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


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