[25441] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7686 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 24 11:05:52 2005

Date: Mon, 24 Jan 2005 08:05:17 -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           Mon, 24 Jan 2005     Volume: 10 Number: 7686

Today's topics:
        ¤Ñ¤ô³ò¤Ñ´I­bA®y¤K¦Ê¤Ø³æ¦ì©Ð¶¡¤À¯²...................... noreplyemail@hotmail.com
    Re: "Can't modify non-lvalue subroutine call" furrows m <ebohlman@omsdev.com>
        [perl-python] 20050124 classes & objects <xah@xahlee.org>
        any similar program to webmin? <lie_huo@hotmail.com>
    Re: any similar program to webmin? <nospam@bigpond.com>
    Re: counting perl src when have nested requires? <nobull@mail.com>
    Re: counting perl src when have nested requires? <nobull@mail.com>
        How to include some files in the same project? francescomoi@europe.com
    Re: How to include some files in the same project? <news@chaos-net.de>
    Re: How to include some files in the same project? <noreply@gunnar.cc>
    Re: Perl Script Problems <nobull@mail.com>
    Re: Question? Alternative to loading modules!!! <cwilbur@mithril.chromatico.net>
    Re: Question? Alternative to loading modules!!! xhoster@gmail.com
    Re: Regex problem <xthua111@sohu.com>
    Re: Regex: Progressive matching and replace <vito_corleone@godfather.com>
    Re: Regex: Progressive matching and replace <tadmc@augustmail.com>
        Regular Expression Query <georgekinley@hotmail.com>
    Re: Regular Expression Query <nobull@mail.com>
    Re: Regular Expression Query <georgekinley@hotmail.com>
    Re: Regular Expression Query <tadmc@augustmail.com>
    Re: Regular Expression Query <noreply@gunnar.cc>
    Re: Sorting a hahs of hashes <toreau@gmail.com>
    Re: Sorting a hahs of hashes <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 24 Jan 2005 15:27:40 +0000 (UTC)
From: noreplyemail@hotmail.com
Subject: ¤Ñ¤ô³ò¤Ñ´I­bA®y¤K¦Ê¤Ø³æ¦ì©Ð¶¡¤À¯²..................................
Message-Id: <ct345c$1hod$34@news.hgc.com.hk>

¤Ñ¤ô³ò¤Ñ´I­b²Ä¤@®y³æ¦ì¤À¯²
´N¦b¹|´I°Ó³õ³ÄÃä
ªþªñ¥æ³qª½³q¦U­«­n¦a°Ï
»´ÅK¦èÅK¥þ³¡´N¸}

²{¥»¤H¤G¤Q¤C¼Ó¦³¤@³æ¦ì¤À¯²
®a­Ñ¹q¾¹¼p´ZÆU¦@¥Î
©Ð¶¡¦³§N®ð¾÷
¤è¦V¤@¬y
¥þ«Î­±¿n¬ù¤C¦Ê¤Ø,©Ð¶¡¬ù80¤Ø
¹q±èª½¨ì¤G¤Q¤C¼Ó

¥u­­³æ¨­¤H¥K,¥¿·í¤H®a,
¤£©â·Ï,¤£¶¼°s,µL¤£¨}”ܦnªÌ

¥»¤H³æ¨­,²{¥ô¹q¸£¾É®v¤Î¤¬Ápºô¤u§@....

¦³·N½Ð¹q¶l±zªº­Ó¤H¸ê®Æ¥]¬A ©Ê§O/¦~ÄÖ/¾·~
¨ì : 13556869217@163.com
¸ê®Æ¤£·|®¤¤£¦^ÂÐ.

»P¥»¤HÁpµ¸..
 .................................


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

Date: 24 Jan 2005 12:18:09 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: "Can't modify non-lvalue subroutine call" furrows my brow
Message-Id: <Xns95E8415BB98A9ebohlmanomsdevcom@130.133.1.4>

"rickcasey" <rick@rickcasey.net> wrote in news:1106340644.754144.73480
@c13g2000cwb.googlegroups.com:

> You are right; something else was going on.
> 
> I was fortunate enough to get a reply from one of the original
> programmers of this application, and he said just delete the line
> causing the error, i.e. 1159. I did that, and the code worked.

Sigh.  Deleting a line of code simply because it's causing an error 
message that you don't understand is voodoo programming.  It's like 
removing a warning light from your car's dashboard to make it stop coming 
on.  That programmer gave you some really bad advice.

> Why Perl was producing that error message is still a mystery, but a
> moot point now....

No, it isn't a mystery.  You had:

$dbh->errstr = $dbh->errstr . $sql;

and you got tripped up by the fact that Perl doesn't require parentheses 
after a subroutine or method call that doesn't take any arguments.  If 
that line had been written as:

$dbh->errstr() = $dbh->errstr() . $sql;

it would have been immediately obvious that something fishy was going on.


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

Date: 24 Jan 2005 06:54:16 -0800
From: "Xah Lee" <xah@xahlee.org>
Subject: [perl-python] 20050124 classes & objects
Message-Id: <1106578456.705117.74220@c13g2000cwb.googlegroups.com>

=A9 # -*- coding: utf-8 -*-
=A9 # Python
=A9
=A9 # in Python, one can define a boxed set
=A9 # of data and functions, which are
=A9 # traditionally known as "class".
=A9
=A9 # in the following, we define a set of data
=A9 # and functions as a class, and name it xxx
=A9 class xxx:
=A9     "a class extempore! (^_^)"
=A9     i=3D1 # i'm a piece of data
=A9     def okaydokey(self): return "okaydokey"
=A9     def square(self,a): return a**a
=A9
=A9 # in the following,
=A9 # we create an object, of the class xxx.
=A9 # also known as "instantiate a class".
=A9 x =3D xxx()
=A9
=A9 # data or functions defined in a class
=A9 # are called the class's attributes or
=A9 # methods.
=A9 # to use them, append a dot and
=A9 # their name after the object's name.
=A9 print 'value of attribute i is:', x.i
=A9 print "3 squared is:", x.square(3)
=A9 print "okaydokey called:", x.okaydokey()
=A9
=A9 # in the definition of function inside a
=A9 # class, the first parameter "self" is
=A9 # necessary. (you'll know why when you need to)
=A9
=A9 # the first line in the class definition
=A9 # is the class's documentation. It can
=A9 # be accessed thru the __doc__
=A9 # attribute.
=A9 print "xxx's doc string is:", x.__doc__
=A9
=A9 # one can change data inside the class
=A9 x.i =3D 400
=A9
=A9 # one can also add new data to the class
=A9 x.j=3D4
=A9 print x.j
=A9
=A9 # or even override a method
=A9 x.square =3D 333
=A9 # (the following line will no longer work)
=A9 # print "3 squared is:", x.square(3)
=A9
=A9 # in Python, one must be careful not to
=A9 # overwrite data or methods defined in a
=A9 # class.

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

for a obfuscated treatment with a few
extra info, see
http://python.org/doc/2.3.4/tut/node11.html

in Python terminal, type help() then
topic CLASSES to read about existing
datatypes as classes, and classes in
Python

try to write a class with one data of
integer and two functions, one
increases it by 1, one decreases it by
1=2E  note: inside a class definition,
to refer to data inside itself use
self. e.g. self.i

------------------------------------------
Perl does not support classes or
objects in the so-called "Object
Oriented" programing. However, a
complete set of emulations of OO
style of programing have been done,
resulting in modules and books and
many documentations and tutorials.

here is a quote from
perldoc perlobj

First you need to understand what
references are in Perl. See perlref for
that. Second, if you still find the
following reference work too
complicated, a tutorial on
object-oriented programming in Perl can
be found in perltoot and perltooc.

it goes on and sayz:

If you're still with us, then here are
three very simple definitions that you
should find reassuring.

1=2E  An object is simply a reference
that happens to know which class
it belongs to.

2=2E  A class is simply a package that
happens to provide methods to deal
with object references.

3=2E  A method is simply a subroutine
that expects an object reference
(or a package name, for class
methods) as the first argument.

Good luck.


Note: this post is from the Perl-Python a-day mailing list at
http://groups.yahoo.com/group/perl-python/
to subscribe, send an email to perl-python-subscribe @ yahoogroups.com
if you are reading it on a web page, program examples may not run
because html conversion often breaks the code.
Xah
 xah@xahlee.org
 http://xahlee.org/PageTwo_dir/more.html



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

Date: Mon, 24 Jan 2005 09:15:11 -0500
From: "Roll" <lie_huo@hotmail.com>
Subject: any similar program to webmin?
Message-Id: <41ec7dbbc7be1660c0a8ab54a679ae8b@localhost.talkaboutprogramming.com>

hi 
does anyone know of any program that is similar to webmin?? 



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

Date: Tue, 25 Jan 2005 00:58:58 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: any similar program to webmin?
Message-Id: <35kgpjF4irvl8U1@individual.net>

Roll wrote:

> hi
> does anyone know of any program that is similar to webmin??

CPanel, Plesk.

gtoomey


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

Date: Mon, 24 Jan 2005 12:01:52 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: counting perl src when have nested requires?
Message-Id: <ct2npj$7ch$1@sun3.bham.ac.uk>

Anno Siegel wrote:

> Sherm Pendley  <spamtrap@dot-app.org> wrote in comp.lang.perl.misc:
> 
>>
>>So, in the simplest case, it could be as simple as this:
>>
>>    system("wc -l " . join(' ', values(%INC)));
> 
> 
> A solid approach, but it will report all modules loaded anywhere in the
> program (up to the point where %INC is evaluated).  The OP seems to be
> interested in the modules loaded directly or indirectly by one specific
>  "use" statement.
> 
> To make it selective that way (and to add a little magic) I propose
> this:
> 
>     END {
>         my @report_these; # collect modules to report
>         sub report_loading {
>             push @report_these, $_[ 1];
>             return; # undef, so search continues
>         }
>         # Line counting left as an exercise
>         print "$_ => $INC{ $_}\n" for @report_these;
>     }
> 
>     use Some::Stuff;
> 
>     use lib \ &report_loading;
>     use Nested::Module;
>     no lib \ &report_loading;

Er, why not simply compare %INC before and after?



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

Date: Mon, 24 Jan 2005 12:06:24 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: counting perl src when have nested requires?
Message-Id: <ct2o24$7hj$1@sun3.bham.ac.uk>

Sherm Pendley wrote:

> Ted Johnson wrote:
> 
>>Is there any way to --->count the lines of perl src<---
 >
>     system("wc -l " . join(' ', values(%INC)));

That, of course counts the total number of lines, not just Perl source 
which could be significantly less where the file contains __DATA__ or 
__END__.  Also it's debatable if lines of POD before the __END__ should 
be considered "lines of perl source".



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

Date: 24 Jan 2005 03:27:11 -0800
From: francescomoi@europe.com
Subject: How to include some files in the same project?
Message-Id: <1106566031.513489.204260@f14g2000cwb.googlegroups.com>

Hi.

I want to write a Perl script, but want also --in order to have a
clearer
code-- to create some extra files.

In other languages, you can use "includes". Does this feature exist in
Perl?

Regards.



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

Date: 24 Jan 2005 11:31:21 GMT
From: Martin Kissner <news@chaos-net.de>
Subject: Re: How to include some files in the same project?
Message-Id: <slrncv9n4b.g94.news@maki.homeunix.net>

francescomoi@europe.com wrote :
> Hi.
>
> I want to write a Perl script, but want also --in order to have a
> clearer
> code-- to create some extra files.
>
> In other languages, you can use "includes". Does this feature exist in
> Perl?

perldoc -q require

HTH
Martin

-- 
Epur Si Muove (Gallileo Gallilei)


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

Date: Mon, 24 Jan 2005 12:26:03 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to include some files in the same project?
Message-Id: <35k4tuF4kf8uaU1@individual.net>

francescomoi@europe.com wrote:
> I want to write a Perl script, but want also --in order to have a
> clearer
> code-- to create some extra files.
> 
> In other languages, you can use "includes". Does this feature exist in
> Perl?

Yes.

     perldoc -f do
     perldoc -f require
     perldoc -f use
     perldoc perlmod

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Mon, 24 Jan 2005 12:20:10 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl Script Problems
Message-Id: <ct2os0$7un$1@sun3.bham.ac.uk>



grant.september@vodafone.com wrote:

 > Subject: Perl Script Problems

Please put the subject of your post in the Subject of your post.

> Hi All, I'm a total newbie to perl but I found a script form the web

The standard answer is that you should:

   Contact the author for help.
   Learn Perl.
   Hire someone who knows Perl.

The regulars here do not want this newsgroup to become a free "fix this 
3rd party script" service.  This newsgroup is for people who want to 
discuss or learn Perl.

Note: a quick look at that script indicates that it contains many things 
that would be severely criticised if it were posted here for code review.



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

Date: Mon, 24 Jan 2005 12:19:26 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: Question? Alternative to loading modules!!!
Message-Id: <87mzuz10sn.fsf@mithril.chromatico.net>

>>>>> "EB" == Eric Bohlman <ebohlman@omsdev.com> writes:

    EB> Charlton Wilbur <cwilbur@mithril.chromatico.net> wrote in
    EB> news:87brbjl2oy.fsf@mithril.chromatico.net:

    >> This is basic technical sales.  "You need to host this site at
    >> a host that allows Perl module installations.  They generally
    >> run $30 a month, which *is* more than the cut-rate web host you
    >> want to use.  However, if the host doesn't allow module
    >> installations, and the cut-rate web host you want to use
    >> doesn't, then I need to rewrite a lot of code instead of using
    >> standard well-tested modules, and that will add between 8 and
    >> 12 hours to the development time for this script.  I'm happy to
    >> go either way, but the requirement that I not use any external
    >> modules will add between $480 and $720 to the estimate I gave
    >> you, and will save only $240 a year.  The decision is up to
    >> you."  Doesn't seem like a tough sales job to me, especially as
    >> it's one I've made several times quite successfully.

    EB> That argument presumes that the decision of which host to use
    EB> is in the same hands as the decision to contract with a
    EB> programmer.  If it is, then there are no flaws to your
    EB> argument, but in even a fairly small company the two decisions
    EB> may be in different hands; in a larger company the two
    EB> decision-makers may even be under different VPs. 

In a company large enough to have two VPs, the sort of quibbling over
resources that you're positing will probably cost more than both sets
of resources combined.  This is not to say that the quibbling won't
happen, but that if it does, the difference between $10/month and
$30/month is not the point -- the comparative status of the people
doing the quibbling is, and the goal of the quibbling is not to save
$20/month but to establish the pecking order in the company.  And if
that's the case, making any sort of rational argument is pointless.

    EB> So it's not really a tough sales job *if* you're making the
    EB> sale to someone sufficiently high up in the client, but in
    EB> many cases you don't have access to someone that high up.

If you aren't making the pitch directly to someone who can say yes or
no without consulting his boss -- and thus having to pitch it to him
second-hand -- you're wasting your time.  (Another basic principple of
technical sales.)

    EB> Once again, this isn't to say that your economics don't make
    EB> sense; they do.  But businesses often act in particularly
    EB> irrational ways.

Yes, they do; but there's no reason to support that particular flavor
of idiocy, or to not point it out when it happens.

Charlton

-- 
cwilbur at chromatico dot net
cwilbur at mac dot com


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

Date: 24 Jan 2005 15:51:13 GMT
From: xhoster@gmail.com
Subject: Re: Question? Alternative to loading modules!!!
Message-Id: <20050124105113.314$tw@newsreader.com>

Charlton Wilbur <cwilbur@mithril.chromatico.net> wrote:

>     EB> So it's not really a tough sales job *if* you're making the
>     EB> sale to someone sufficiently high up in the client, but in
>     EB> many cases you don't have access to someone that high up.
>
> If you aren't making the pitch directly to someone who can say yes or
> no without consulting his boss -- and thus having to pitch it to him
> second-hand -- you're wasting your time.  (Another basic principple of
> technical sales.)

What if you are making a pitch to someone who can say "no" without
consulting the boss, but can't say "yes" without consulting the boss?

From where I sit, it seems like that is the most common scenario.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Mon, 24 Jan 2005 19:06:37 +0800
From: kenneth <xthua111@sohu.com>
Subject: Re: Regex problem
Message-Id: <ct2l3c$206$1@mail.cn99.com>

Vito Corleone wrote:
> Hi Kenneth,
> 
> 
>>>I tried:
>>>$html =~ s#<photo src=($d+):($d+):($d+)>#<img src=img/$1/$2/$3>#g;
>>>
>>>But there is a possibility that there is a newline in it. Is there
>>>any better way to change this?
>>
>>are you sure where did the newline would appear?
> 
> 
> No it could be anywhere. Actually I make this for online BBS, where user
> can choose an icon, click on it, and the javascript will put <photo
> src=12:13:14> on the text. I would be easier if I put <img
> src=img/12/13/14.gif> on the first place, but some user has different
> directories, so I have to get_user_id, and then change <photo src> to
> appropiate <img src>.
o,i'm not fimilar with html,and doubted the photo line will lost its 
value whether the newline appear everywhere. maybe.


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

Date: Mon, 24 Jan 2005 20:05:45 +0900
From: Vito Corleone <vito_corleone@godfather.com>
Subject: Re: Regex: Progressive matching and replace
Message-Id: <20050124200545.7f4f29b0.vito_corleone@godfather.com>

Sorry this is not clear enough. I give some more examples here.

> ##--- before ---##
> adfdf <photo src=12> dasfd Fdfdsfdf <photo 
> src=14> adsfdf dsf dsf dsf asdfdsa ds <phot
> o> dsafd adsf
> 
> to:
> 
> ##--- after ---##
> adfdf <img src=12.gif> dasfd Fdfdsfdf <img 
> src=14.gif> adsfdf dsf dsf dsf asdfdsa ds <phot
> o> dsafd adsf


Other:

##-- before --##
aaa aaaa <photo src=12> adfafdsfd <photo
 src=24> adfa dfdf 

##-- after --##
aaa aaaa <img src=12.gif> adfafdsfd 
 adfa dfdf 

This user doesn't have access to 24.gif, so we just delete it.


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

Date: Mon, 24 Jan 2005 07:09:32 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regex: Progressive matching and replace
Message-Id: <slrncv9ssc.ldi.tadmc@magna.augustmail.com>

Vito Corleone <vito_corleone@godfather.com> wrote:

> How can I do progressive progressive matching and replace?


By using the s/// operator.


> my $test =<< "BLOCK";  ## User input this from web interface, textarea
> adfdf <photo src=12> dasfd Fdfdsfdf <photo 
> src=14> adsfdf dsf dsf dsf asdfdsa ds <phot
> o> dsafd adsf
> BLOCK
> ;
> 
> $test =~ s/\n//g; 


Did you try print()ing $test at this point?

Did you see a part of the string that looked like "<photosrc=14>"?


> while ($test =~ /<photo src=(\d+)>/g) {


The substring above will not match that pattern, you'll miss it.


>     ## Here I don't know how to change 
>     ## from <photo src=XX> to <img src=XX.gif>


   s/<photo src=(\d+)>/<img src=$1.gif>/g;



> 2. Even if I can, I don't know how can I restore the newline that I
                                                   ^^^^^^^^^^^
> deleted.


"the newline" is singular, yet you deleted more than one newline.

Which newline did you want to undelete?

Why delete them in the first place if you don't want them deleted?


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


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

Date: Mon, 24 Jan 2005 12:21:49 GMT
From: "George" <georgekinley@hotmail.com>
Subject: Regular Expression Query
Message-Id: <xn0dxmzis8nmqn6000@news.europe.nokia.com>

Hi,
I have following lines in a file, below is example of one such line ,
yes it is long line


9) MediaRecorder-NewYork#xena:project:BBM#1            working xena
project MediaRecorder       BBM51#1    NewYork#541

What I need to get is 
MediaRecorder-NewYork#xena:project:BBM#1

What I have done so far is
my @prog=map (/[(.*?)A-Za-z](.*)(?=\s+ )/,@comfile); #where @comfile=
contents of file

Why does this regex fail to find the end of search= whitespace
if I use (?=working) it works but  I get blank lines till working which
I dont need


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

Date: Mon, 24 Jan 2005 12:29:50 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Regular Expression Query
Message-Id: <ct2pe4$87i$1@sun3.bham.ac.uk>



George wrote:
> I have following lines in a file, below is example of one such line ,
> yes it is long line
> 
> 
> 9) MediaRecorder-NewYork#xena:project:BBM#1            working xena
> project MediaRecorder       BBM51#1    NewYork#541
> 
> What I need to get is 
> MediaRecorder-NewYork#xena:project:BBM#1
> 
> What I have done so far is
> my @prog=map (/[(.*?)A-Za-z](.*)(?=\s+ )/,@comfile); #where @comfile=
> contents of file
> 
> Why does this regex fail to find the end of search= whitespace
> if I use (?=working) it works but  I get blank lines till working which
> I dont need

(?=\s+ )

Looks for one or more whitespace characters followed by an literal space 
character.  Perhaps all the whitespace in the file is tabs.

BTW [(.*?)A-Za-z] looks wrong to me.  The characters ( . * ? and ) are 
not special inside character classes.

Random shot in the dark you meant:

  my @prog=map (/(\S+)/,@comfile);

It may be more ideomatic to use split().



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

Date: Mon, 24 Jan 2005 13:06:57 GMT
From: "George" <georgekinley@hotmail.com>
Subject: Re: Regular Expression Query
Message-Id: <xn0dxn0qw8p9dwx001@news.europe.nokia.com>

Brian McCauley wrote:

> 
> 
> George wrote:
> > I have following lines in a file, below is example of one such line
> > , yes it is long line
> > 
> > 
> > 9) MediaRecorder-NewYork#xena:project:BBM#1            working xena
> > project MediaRecorder       BBM51#1    NewYork#541
> > 
> > What I need to get is 
> > MediaRecorder-NewYork#xena:project:BBM#1
> > 
> > What I have done so far is
> > my @prog=map (/[(.*?)A-Za-z](.*)(?=\s+ )/,@comfile); #where
> > @comfile= contents of file
> > 
> > Why does this regex fail to find the end of search= whitespace
> > if I use (?=working) it works but  I get blank lines till working
> > which I dont need
> 
> (?=\s+ )
> 
> Looks for one or more whitespace characters followed by an literal
> space character.  Perhaps all the whitespace in the file is tabs.
> 
> BTW [(.*?)A-Za-z] looks wrong to me.  The characters ( . * ? and )
> are not special inside character classes.
> 
> Random shot in the dark you meant:
> 
>   my @prog=map (/(\S+)/,@comfile);
> 
> It may be more ideomatic to use split().

My Idea of 
/[(.*?)A-Za-z](.*)(?=\s+ )/
 --W--|---X---|-Y-|--Z---
is
W=Anything from start	in my case it is 1) ...100)...
X=Anything Starts from A or a
Y=Anything in between
Z= stops where space found is true


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

Date: Mon, 24 Jan 2005 06:55:33 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regular Expression Query
Message-Id: <slrncv9s25.ldi.tadmc@magna.augustmail.com>

George <georgekinley@hotmail.com> wrote:

> I have following lines in a file, below is example of one such line ,
> yes it is long line
> 
> 
> 9) MediaRecorder-NewYork#xena:project:BBM#1            working xena
> project MediaRecorder       BBM51#1    NewYork#541
> 
> What I need to get is 
> MediaRecorder-NewYork#xena:project:BBM#1


If the line is in $_, then this will do it:

   my(undef, $to_get) = split;


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


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

Date: Mon, 24 Jan 2005 15:12:03 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regular Expression Query
Message-Id: <35kdv2F4npo84U1@individual.net>

George wrote:
>>George wrote:
>>>I have following lines in a file, below is example of one such line
>>>, yes it is long line
>>>
>>>9) MediaRecorder-NewYork#xena:project:BBM#1            working xena
>>>project MediaRecorder       BBM51#1    NewYork#541
>>>
>>>What I need to get is 
>>>MediaRecorder-NewYork#xena:project:BBM#1
>>>
>>>What I have done so far is
>>>my @prog=map (/[(.*?)A-Za-z](.*)(?=\s+ )/,@comfile); #where
>>>@comfile= contents of file
>>>
>>>Why does this regex fail to find the end of search= whitespace

Because the (.*) part is greedy.

<snip>

> My Idea of 
> /[(.*?)A-Za-z](.*)(?=\s+ )/
>  --W--|---X---|-Y-|--Z---
> is
> W=Anything from start	in my case it is 1) ...100)...
> X=Anything Starts from A or a
> Y=Anything in between
> Z= stops where space found is true

This would better fit your idea:

     /.*?\)\s+([A-Za-z].*?)(?=\s+)/

But please consider this idea instead:

     my @prog = map
       /
         \s      # last space char in the first group of space chars
         (\S+)   # non-space chars
       /x, @comfile;

Or this:

     my @prog = map { (split)[1] } @comfile;

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Mon, 24 Jan 2005 12:44:23 +0100
From: Tore Aursand <toreau@gmail.com>
Subject: Re: Sorting a hahs of hashes
Message-Id: <kc5Jd.5774$IW4.118172@news2.e.nsc.no>

Me wrote:
>  I have a hash (of a hashes) that has data like this
>    table1->table_name
>     ->table_size
>    table2->table_name
>     ->table_size
>    .
>    .
>    .
>    table_n->table_name
>       ->table_size

Please post the real code. If not, at least provide us with the output 
of the hash's structure as reported by the Data::Dumper module.


-- 
Tore Aursand <tore@aursand.no>
"Be nice to nerds. Chances are you'll end up working for one." (Bill
  Gates)


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

Date: Mon, 24 Jan 2005 14:09:04 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Sorting a hahs of hashes
Message-Id: <4k7Jd.18833$IP6.2972@trnddc05>

Me wrote:
[...]
> I need to sort the hash by table_size (numeric). How can I do this.

You don't. Hashes by their very nature don't have an order or sequence.
Therefore the term "sorting a hash" is about as meaningful as trying to sort
the lenght() function. You have to use a different data structure.

Having said that your Question is also Asked Frequently, please see
"perldoc -q sort" for several suggestion about what to do instead.

jue





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

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


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