[28659] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 10023 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 30 18:05:52 2006

Date: Thu, 30 Nov 2006 15:05:08 -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           Thu, 30 Nov 2006     Volume: 10 Number: 10023

Today's topics:
    Re: Compare UNIX file time with time in a variable <m@remove.this.part.rtij.nl>
    Re: Compare UNIX file time with time in a variable <m@remove.this.part.rtij.nl>
    Re: Dynamic object creation <b.mahdi@gmail.com>
    Re: Dynamic object creation <b.mahdi@gmail.com>
    Re: Dynamic object creation <mritty@gmail.com>
        How can I change color font in GTK2? <robertospara@gmail.com>
    Re: How can I change color font in GTK2? <robertospara@gmail.com>
        I need to read web pages without LWP <dont@like.spammers>
    Re: I need to read web pages without LWP <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: I need to read web pages without LWP <antispam@randometry.com>
    Re: I need to read web pages without LWP <noreply@gunnar.cc>
        it just wouldn't compile <tamir.yehuda@gmail.com>
    Re: it just wouldn't compile <mritty@gmail.com>
    Re: Masking/Hiding a password in Perl Source (J.D. Baldwin)
    Re: Masking/Hiding a password in Perl Source <antispam@randometry.com>
    Re: Masking/Hiding a password in Perl Source (J.D. Baldwin)
        Normalize Unihan Z-variants <jidanni@jidanni.org>
    Re: p-values from tprob differ from those in excel or R xhoster@gmail.com
    Re: Regex failed to replace utf8 character <mccownf@yahoo.com>
    Re: Regex failed to replace utf8 character <rvtol+news@isolution.nl>
    Re: RTF::Writer work <glex_no-spam@qwest-spam-no.invalid>
    Re: sharing a  variable across two scripts. <ddunham@redwood.taos.com>
        sort array <shirazk@gmail.com>
    Re: sort array <tbmoore9@verizon.net>
    Re: using DateTime object <clifton_francis@hotmail.com>
    Re: using DateTime object <rvtol+news@isolution.nl>
    Re: using DateTime object <clifton_francis@hotmail.com>
    Re: using DateTime object <rvtol+news@isolution.nl>
    Re: What is a glob variable? <brian.d.foy@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 30 Nov 2006 15:51:23 +0100
From: Martijn Lievaart <m@remove.this.part.rtij.nl>
Subject: Re: Compare UNIX file time with time in a variable
Message-Id: <pan.2006.11.30.14.51.23.327814@remove.this.part.rtij.nl>

[ Please don't toppost ]

On Wed, 29 Nov 2006 19:01:16 -0800, phynkel@gmail.com wrote:

> Big and Blue wrote:
>
>>     And if you still decide to use command line find, use GNU find,
>>     which
>> has  -amin, -cmin, -mmin options which allows you to find files
>> accessed, (inode-)changed or modified before (+n), after (-n) or
>> exactly at (n) n minutes ago.
>>
> That's neat. Will Red Hat Linux, by default use GNU find? Now if only

Yes, it is called GNULinux, becuase it's the Linux kernel with the GNU
tools. This holds for any distro I know of.

M4
-- 
Redundancy is a great way to introduce more single points of failure.



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

Date: Thu, 30 Nov 2006 23:41:36 +0100
From: Martijn Lievaart <m@remove.this.part.rtij.nl>
Subject: Re: Compare UNIX file time with time in a variable
Message-Id: <pan.2006.11.30.22.41.36.199839@remove.this.part.rtij.nl>

On Thu, 30 Nov 2006 15:51:23 +0100, Martijn Lievaart wrote:

> Yes, it is called GNULinux, becuase it's the Linux kernel with the GNU
> tools. This holds for any distro I know of.

s.GNULINUX.GNU/Linux.;
s.becuase.because.;

Damn.

M4
-- 
Redundancy is a great way to introduce more single points of failure.



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

Date: 30 Nov 2006 11:12:14 -0800
From: "bingo" <b.mahdi@gmail.com>
Subject: Re: Dynamic object creation
Message-Id: <1164913934.803573.45820@h54g2000cwb.googlegroups.com>

Works like a charm,
It is the  "X::$class" that i was missing.  I was evaluating the call
this way:
"X::"."$class"->new

This dosent work, but "X::$class" works.

I still cannot understand why the first construct gets the job done and
not the second.

Thx Sinan Unur,

Mahdi


A. Sinan Unur wrote:
> "bingo" <b.mahdi@gmail.com> wrote in news:1164862286.461321.38250
> @n67g2000cwd.googlegroups.com:
>
> > Hi all,
> > I was wondering if anyone could help me with this one. I need to
> create
> > objects in Perl at runtime ...
> > Users enter the type of class ex.: (ClassA classB classC) which are
> all
> > children of classX
> > When i need to create an object i do
> >
> > $handler = ClassX::ClassA->new();
> >
> > Any hints on how i can create objects at runtime ?
>
> First off, you need to make sure that you are not accepting arbitrary
> user input which you then evaluate blindly.
>
> #!/usr/bin/perl
>
> package X;
>
> use strict;
> use warnings;
>
> sub whoami { ref shift }
>
> package X::A;
>
> use strict;
> use warnings;
>
> use base 'X';
> sub new { bless { } => shift }
>
> package X::B;
>
> use strict;
> use warnings;
>
> use base 'X';
> sub new { bless { } => shift }
>
> package main;
>
> use strict;
> use warnings;
>
> my %ok = map { $_ => 1 } qw( A B );
>
> while ( my $class = <STDIN> ) {
>     chomp $class;
>     next unless exists $ok{$class};
>     eval {
>         print "X::$class"->new->whoami, "\n";
>     };
>     warn $@ if $@;
> }
> 
> __END__



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

Date: 30 Nov 2006 11:37:25 -0800
From: "bingo" <b.mahdi@gmail.com>
Subject: Re: Dynamic object creation
Message-Id: <1164915445.903992.299830@l12g2000cwl.googlegroups.com>

Anno,

That also works very well. Thanks for the clarification....

M
anno4000@radom.zrz.tu-berlin.de wrote:
> bingo <b.mahdi@gmail.com> wrote in comp.lang.perl.misc:
> > Hi all,
> > I was wondering if anyone could help me with this one. I need to create
> > objects in Perl at runtime ...
> > Users enter the type of class ex.: (ClassA classB classC) which are all
> > children of classX
> > When i need to create an object i do
> >
> > $handler = ClassX::ClassA->new();
> >
> > Any hints on how i can create objects at runtime ?
>
> Object creation usually happens at run time.  Usually, the class an
> object will be created in is determined at compile time, being specified
> as a bareword.  However, the class can also be specified as a simple
> variable.  So (untested)
>
>     my $class_this_time = 'ClassX::' . $user_input;
>     my $handler = $class_this_time->new( ...);
> 
> Anno



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

Date: 30 Nov 2006 12:45:00 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Dynamic object creation
Message-Id: <1164919500.073378.11920@80g2000cwy.googlegroups.com>

bingo wrote:
> Works like a charm,
> It is the  "X::$class" that i was missing.  I was evaluating the call
> this way:
> "X::"."$class"->new
>
> This dosent work, but "X::$class" works.
>
> I still cannot understand why the first construct gets the job done and
> not the second.

Does this make it clearer?

$ perl -MO=Deparse,-p -e'"X::"."$class"->new '
('X::' . "$class"->new);
-e syntax OK
$ perl -MO=Deparse,-p -e'("X::"."$class")->new '
('X::' . "$class")->new;
-e syntax OK
$ perl -MO=Deparse,-p -e'"X::".("$class"->new) '
('X::' . "$class"->new);

Or how about this, from `perldoc perlop`?
     Perl operators have the following associativity and
     precedence, listed from highest precedence to lowest.
     <snip>
         left        terms and list operators (leftward)
         left        ->
         nonassoc    ++ --
         right       **
         right       ! ~ \ and unary + and -
         left        =~ !~
         left        * / % x
         left        + - .
     <snip>

Paul Lalli



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

Date: 30 Nov 2006 13:04:04 -0800
From: "robertospara" <robertospara@gmail.com>
Subject: How can I change color font in GTK2?
Message-Id: <1164920644.921527.131830@79g2000cws.googlegroups.com>

I don't mean Label object but font in Entry or TextView object?
Please for help and thanks from the mountains :)



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

Date: 30 Nov 2006 14:51:05 -0800
From: "robertospara" <robertospara@gmail.com>
Subject: Re: How can I change color font in GTK2?
Message-Id: <1164927065.262461.36760@16g2000cwy.googlegroups.com>

I am in good direction becouse in C this code would look like this:

gtk_widget_modify_base ( GTK_WIDGET (entry), GTK_STATE_NORMAL,
backgroud);

where background it's a structure of type GdkColor*.

Greetings folks:)

robertospara napisal(a):
> I don't mean Label object but font in Entry or TextView object?
> Please for help and thanks from the mountains :)



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

Date: Thu, 30 Nov 2006 19:11:22 GMT
From: Mark Healey <dont@like.spammers>
Subject: I need to read web pages without LWP
Message-Id: <pan.2006.11.30.19.11.19.597925@like.spammers>

For years I was running a web host out of my living room to parse and
digest some web pages for display on my Palm Pilot.  It got hacked and I
got tired of doing all that maintenance so I bought a hosting account.

The problem is that they only have the modules that came with Apache
installed.

The modules I used are CGI, LWP::UserAgent, HTTP::Request, HTTP::Response,
URI::Escape.

So what I need to do is have a script that takes form data and passes that
to another sites form submission, takes the response, parses it for the
data I want and responds with a page formatted for a really small screen.

Can I do this without any modules and how hard would it be?

-- 
Mark Healey
marnkews ãt healeyonline döt com



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

Date: Thu, 30 Nov 2006 11:48:07 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: I need to read web pages without LWP
Message-Id: <n4p344x9n2.ln2@goaway.wombat.san-francisco.ca.us>

On 2006-11-30, Mark Healey <dont@like.spammers> wrote:
> For years I was running a web host out of my living room to parse and
> digest some web pages for display on my Palm Pilot.  It got hacked and I
> got tired of doing all that maintenance so I bought a hosting account.
>
> The problem is that they only have the modules that came with Apache
> installed.
>
> The modules I used are CGI, LWP::UserAgent, HTTP::Request, HTTP::Response,
> URI::Escape.

You should read perldoc -q library, then maintain your own library
directory, rather than try to rewrite all that functionality yourself.

--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



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

Date: Thu, 30 Nov 2006 21:31:06 +0100
From: Ric <antispam@randometry.com>
Subject: Re: I need to read web pages without LWP
Message-Id: <eknf5g$k00$1@online.de>

Mark Healey schrieb:
> For years I was running a web host out of my living room to parse and
> digest some web pages for display on my Palm Pilot.  It got hacked and I
> got tired of doing all that maintenance so I bought a hosting account.
> 
> The problem is that they only have the modules that came with Apache
> installed.
> 
> The modules I used are CGI, LWP::UserAgent, HTTP::Request, HTTP::Response,
> URI::Escape.
> 
> So what I need to do is have a script that takes form data and passes that
> to another sites form submission, takes the response, parses it for the
> data I want and responds with a page formatted for a really small screen.
> 
> Can I do this without any modules and how hard would it be?
> 

You can do it with Sockets, pretty easy if you have some experience with
HTTP Protocol. But why not use HTTP::Request etc. upload them along with
your script all you need to do is to put them into INC


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

Date: Thu, 30 Nov 2006 21:33:20 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: I need to read web pages without LWP
Message-Id: <4t8tgiF134nm5U1@mid.individual.net>

Keith Keller wrote:
> On 2006-11-30, Mark Healey <dont@like.spammers> wrote:
>>I bought a hosting account.
>>
>>The problem is that they only have the modules that came with Apache
>>installed.
>>
>>The modules I used are CGI, LWP::UserAgent, HTTP::Request, HTTP::Response,
>>URI::Escape.
> 
> You should read perldoc -q library, then maintain your own library
> directory, rather than try to rewrite all that functionality yourself.

That's one way. But even better, IMO, would be to have your web host 
install those modules. Or, if they refuse to do so, leave them and get a 
hosting account with a decent Perl installation available.

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


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

Date: 30 Nov 2006 10:09:57 -0800
From: "tamiry" <tamir.yehuda@gmail.com>
Subject: it just wouldn't compile
Message-Id: <1164910197.159994.277470@j44g2000cwa.googlegroups.com>

Hi,
I had some code in a module that won't compile. i narrowed down the
code to the miimu that won't compile. It looks like the division sign
confuses the switch statement. I'll be happy if someone could point the
problem(s).
i also noted that some minor changes make the problem disappear (i
wrote that at the bottom).

--------> my file:


#!/usr/bin/perl -w

use strict;
use warnings;
use Switch;

sub Function
{
	my $self = shift;
	my $num = $self->{ratio}/188;

	while(1)
	{
		switch($self->{status})
		{
			case (0)
			{
				print "stt = 0\n";
			}
		}
	}
}

sub Junction
{
	my $self = shift;
	my $num = $self->{ratio}/188;
}

------> end of my file

"fixes"
1. remove the entire switch statement.
2. remove the first division operation
3. remove the second division operation
4. add the "#/" (without the quotes) at the end of the line with the
first division
(replace
	my $num = $self->{ratio}/188;
with
	my $num = $self->{ratio}/188;#/
)

the error i get is:

syntax error at C:\Work\Perl\tst.pl line 17, near ")
                {"
syntax error at C:\Work\Perl\tst.pl line 23, near "}"
Execution of C:\Work\Perl\tst.pl aborted due to compilation errors.


please help :)
thanks.



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

Date: 30 Nov 2006 10:14:47 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: it just wouldn't compile
Message-Id: <1164910487.301298.4160@j72g2000cwa.googlegroups.com>

tamiry wrote:
> I had some code in a module that won't compile. i narrowed down the
> code to the miimu that won't compile. It looks like the division sign
> confuses the switch statement. I'll be happy if someone could point the
> problem(s).

Switch.pm is probably the buggiest standard module out there.  It uses
Source Filtering to rearrange your code, and it pretty frequently
doesn't get it right.  I've encountered similar problems to yours in
the past.  I have no advice to offer you other than "get rid of Switch,
and write the if/elsif's yourself".

Sorry,
Paul Lalli



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

Date: Thu, 30 Nov 2006 16:21:20 +0000 (UTC)
From: INVALID_SEE_SIG@example.com.invalid (J.D. Baldwin)
Subject: Re: Masking/Hiding a password in Perl Source
Message-Id: <ekn0e0$sq4$1@reader2.panix.com>


In the previous article, Eric Schwartz <emschwar@pobox.com> wrote:
> > Set the file read permissions on the above file such that only
> > authorized users (e.g., group members, ACL-designated users,
> > whatever) can read it.
> 
> If you're going to to that, then why not just use the unencrypted
> password in the separate file?  Anybody who can read your encrypted
> file can easily decrypt it,

"Anybody"?  You don't work with the same crew I do.  I doubt more than
one of the fifty people with read access to that file would know what
to do with it.  Of course, that isn't the point ....

> and anyone who can't read it doesn't care whether or not the file
> they can't read is encrypted or in plaintext.

 ... with the understanding, stated several times over, that this is
nothing more than security-through-obscurity, which is in fact no real
security at all, the point is not to keep access to the password from
authorized persons, the point is to keep it from being casually or
"accidentally" viewed.

I much prefer ssh keys and (when appropriate) agents for caching same,
but some of the technologies I need automated access to don't support
that because the vendors STILL don't take ssh (or any other security
features of their products) seriously.  *koff*Cisco*koff*
-- 
  _+_ From the catapult of |If anyone disagrees with any statement I make, I
_|70|___:)=}- J.D. Baldwin |am quite prepared not only to retract it, but also
\      /  baldwin@panix.com|to deny under oath that I ever made it. -T. Lehrer
***~~~~-----------------------------------------------------------------------


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

Date: Thu, 30 Nov 2006 21:21:57 +0100
From: Ric <antispam@randometry.com>
Subject: Re: Masking/Hiding a password in Perl Source
Message-Id: <eknekc$j62$1@online.de>

J.D. Baldwin schrieb:
> In the previous article, Eric Schwartz <emschwar@pobox.com> wrote:
>>> Set the file read permissions on the above file such that only
>>> authorized users (e.g., group members, ACL-designated users,
>>> whatever) can read it.
>> If you're going to to that, then why not just use the unencrypted
>> password in the separate file?  Anybody who can read your encrypted
>> file can easily decrypt it,
> 
> "Anybody"?  You don't work with the same crew I do.  I doubt more than
> one of the fifty people with read access to that file would know what
> to do with it.  Of course, that isn't the point ....
> 
>> and anyone who can't read it doesn't care whether or not the file
>> they can't read is encrypted or in plaintext.
> 
> ... with the understanding, stated several times over, that this is
> nothing more than security-through-obscurity, which is in fact no real
> security at all, the point is not to keep access to the password from
> authorized persons, the point is to keep it from being casually or
> "accidentally" viewed.

Then just build the password through some functions inside your perl app .
This way you don't have it store in single variable. If you now compile
it with perl2exe it will be more difficult to grab the password then
using your decrypt function with acces to the file that holds your pass.

> 
> I much prefer ssh keys and (when appropriate) agents for caching same,
> but some of the technologies I need automated access to don't support
> that because the vendors STILL don't take ssh (or any other security
> features of their products) seriously.  *koff*Cisco*koff*


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

Date: Thu, 30 Nov 2006 20:31:13 +0000 (UTC)
From: INVALID_SEE_SIG@example.com.invalid (J.D. Baldwin)
Subject: Re: Masking/Hiding a password in Perl Source
Message-Id: <eknf2h$db7$1@reader2.panix.com>


In the previous article, Ric <antispam@randometry.com> wrote:
> Then just build the password through some functions inside your perl
> app .

Yeah, I liked the pack/unpack solution someone else mentioned.  My own
situation kind of requires I do it in a separate file with strong
encryption, for purely political reasons.  I am aware of how silly
this is, but I am also positive that my situation is not unique.
-- 
  _+_ From the catapult of |If anyone disagrees with any statement I make, I
_|70|___:)=}- J.D. Baldwin |am quite prepared not only to retract it, but also
\      /  baldwin@panix.com|to deny under oath that I ever made it. -T. Lehrer
***~~~~-----------------------------------------------------------------------


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

Date: Fri, 01 Dec 2006 01:11:46 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: Normalize Unihan Z-variants
Message-Id: <87irgwuael.fsf@jidanni.org>

How am I to "normalize" a document full of the latter into the former?
U+4E32 kZVariant U+F905
U+4E86 kZVariant U+F9BA
U+516D kZVariant U+F9D1
U+5317 kZVariant U+F963
U+53C3 kZVariant U+F96B...

Unicode::Normalize apparently is talking about a different kind of
normalization, not these CJK compatibility ideographs.

From reading {perluniintro perlunicode perlre Encode::Unicode
Unicode::UCD} one would think one needs to make a regular expression to
replace any character in the CJK compatibility ideographs block with a
lookup of its kZVariant base character.

Certainly there is some Debian package I can just download?



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

Date: 30 Nov 2006 16:12:59 GMT
From: xhoster@gmail.com
Subject: Re: p-values from tprob differ from those in excel or R
Message-Id: <20061130111456.376$mt@newsreader.com>

"rahulthathoo" <rahul.thathoo@gmail.com> wrote:
> Hi.
>
> I used Statistics:Distribution:tprob to calculate the p-values in perl.
> But the values that i got were exactly half the values i got for the
> same parameters in Excel and R. How come? Any clues?

It would help if you showed the exact syntax of all concerned.  Excel has
several functions that deal with t distributions and they have different
behavior regarding cumulative/density and 1-tailed/2-tailed.

Statistics:Distribution:tprob gives the upper probability, which if t is >
0 is the same thing as a one-tailed probability.  You are probably asking
Excel for a two-tailed probability, which is double the one tail
probability.

Xho

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


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

Date: 30 Nov 2006 09:38:26 -0800
From: "Frank" <mccownf@yahoo.com>
Subject: Re: Regex failed to replace utf8 character
Message-Id: <1164908306.927573.27470@f1g2000cwa.googlegroups.com>

Ben,

Thanks for your help. I was able to locate 3 problems with what I was
doing:

1) Reading the file into Perl using

  open(F, "<:utf8", $fn);

was the first problem.  Reading it in normally was what I should have
been doing and was   doing originally, but I had added this later when
trying to figure out what was going on.

2) I should have replaced the copyright like you did:

  my $copy =3D "\xa9";
  $html =3D~ s/$copy/C/g

3) This still ran in an infinite loop:

  my $special =3D utf8::encode("=C2");
  print "sub\n" while ($html =3D~ s/$special / /g);

but when I corrected it to the following, the substitution worked fine:

  my $special =3D "\xa0";
  print "sub\n" while ($html =3D~ s/$special/ /g);
=20

Thanks again,
Frank



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

Date: Thu, 30 Nov 2006 21:50:06 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Regex failed to replace utf8 character
Message-Id: <eknjqo.1cc.1@news.isolution.nl>

Frank schreef:

> 3) This still ran in an infinite loop:
>
>   my $special = utf8::encode("Â");
>   print "sub\n" while ($html =~ s/$special / /g);
>
> but when I corrected it to the following, the substitution worked
> fine:
>
>   my $special = "\xa0";
>   print "sub\n" while ($html =~ s/$special/ /g);

Do you have anything special like "use utf8;" in your source?

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Thu, 30 Nov 2006 11:04:22 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: RTF::Writer work
Message-Id: <456f0f72$0$508$815e3792@news.qwest.net>

Sparky wrote:
> Hi all
> 
> Are there any RTF::Writer black belts out there that are able to do some
> coding for cash?
[...]
> Apologies if I'm posting this in the wrong group.  If so maybe someone can
> point me in the right direction.

http://jobs.perl.org/


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

Date: Thu, 30 Nov 2006 21:00:44 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: sharing a  variable across two scripts.
Message-Id: <0EHbh.6480$wc5.500@newssvr25.news.prodigy.net>

rajendra <rajendra.prasad@in.bosch.com> wrote:
> Hello All,

> I have two scripts A and B .Script A  calls script B for getting data. This
> data is used by script A for processing. Is there a concept of shared
> variable so that data stored in this shared variable can be accessed by
> script A.

In general, no.  Threads share memory visibility easily, but separate
processes do not.  There are several different methods of moving data
between processes.  Interprocess communication (IPC).  

Write data to a file, read from the other process.
Open a network socket between the processes.
Use SYSV shared memory if supported by the OS.

See also perlipc.

-- 
Darren Dunham                                           ddunham@taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


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

Date: 30 Nov 2006 14:49:56 -0800
From: "Shiraz" <shirazk@gmail.com>
Subject: sort array
Message-Id: <1164926996.910454.160050@80g2000cwy.googlegroups.com>

I need take a delimited line and convert it into a new line with the
fields in the required order.

eg: $data = 'e1;e2;e3';  and the new order is 3,1,2 then the new line
need to be 'e3;e1;e2'.

i have used the code below to do this. are there any more effecient
ways to accomplish this?



_BEGIN_
use strict;
use warnings;

my $data = 'q;a;b;c;d;e;f;g;h;i';
my @NewOrder = (9,2,5,1,6,3,4,7,8,0);
my $delimiter = ';';
my @Record = split($delimiter, $data);
my @NewRecord = ();

foreach (@NewOrder)
{
   push(@NewRecord, $Record[$NewOrder[$_]]);
}

@NewRecord = reverse(@NewRecord);

print join(";", @NewRecord);

_END_

thanks in advance;
GD



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

Date: Thu, 30 Nov 2006 23:04:19 GMT
From: boyd <tbmoore9@verizon.net>
Subject: Re: sort array
Message-Id: <tbmoore9-D2783F.18041930112006@news.verizon.net>

In article <1164926996.910454.160050@80g2000cwy.googlegroups.com>,
 "Shiraz" <shirazk@gmail.com> wrote:

> I need take a delimited line and convert it into a new line with the
> fields in the required order.
> 
> eg: $data = 'e1;e2;e3';  and the new order is 3,1,2 then the new line
> need to be 'e3;e1;e2'.
> 
> i have used the code below to do this. are there any more effecient
> ways to accomplish this?
> 
> 
> 
> _BEGIN_
> use strict;
> use warnings;
> 
> my $data = 'q;a;b;c;d;e;f;g;h;i';
> my @NewOrder = (9,2,5,1,6,3,4,7,8,0);
> my $delimiter = ';';
> my @Record = split($delimiter, $data);
> my @NewRecord = ();
> 
> foreach (@NewOrder)
> {
>    push(@NewRecord, $Record[$NewOrder[$_]]);
> }
> 
> @NewRecord = reverse(@NewRecord);
> 
> print join(";", @NewRecord);
> 
> _END_
> 
> thanks in advance;
> GD

I believe you can do this:
@NewRecord = @Record[@NewOrder];  # an array slice

Boyd


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

Date: 30 Nov 2006 07:41:01 -0800
From: "aswad" <clifton_francis@hotmail.com>
Subject: Re: using DateTime object
Message-Id: <1164901261.878559.108500@n67g2000cwd.googlegroups.com>


Dr.Ruud wrote:
> Ben Morrow schreef:
> > aswad:
>
> >> When I ran ppm, I got this error
> >> ppm install failed: Can't find any package that provide DateTime
> >
> > Then install it using CPAN.pm, in the usual way:
>
> That is not the usual way when you have AS-Perl on Windows. :)
>
> First you add repositories and try on from there.
>
> C:\> ppm repo list
>   +----+------+--------------------------------+
>   | id | pkgs | name                           |
>   +----+------+--------------------------------+
>   |  1 | 6404 | ActiveState Package Repository |
>   |  2 |  597 | Winnipeg                       |
>   |  3 |    7 | RothConsulting                 |
>   +----+------+--------------------------------+
>    (3 enabled repositories)
>
> C:\Perl\Projects\misc>ppm repo desc 1
> Id: 1
> Name: ActiveState Package Repository
> URL: http://ppm4.activestate.com/MSWin32-x86/5.8/819/package.xml
> Enabled: yes
> Last-Status: 200 OK
> Last-Access: 13 minutes ago
> Refresh-In: 37 minutes
> Last-Modified: 2 days and 14 hours ago
>
> C:\Perl\Projects\misc>ppm repo desc 2
> Id: 2
> Name: Winnipeg
> URL: http://theoryx5.uwinnipeg.ca/ppms/package.xml
> Enabled: yes
> Last-Status: 200 OK
> Last-Access: 13 minutes ago
> Refresh-In: 14 minutes
> Last-Modified: 5 hours ago
>
> C:\Perl\Projects\misc>ppm repo desc 3
> Id: 3
> Name: RothConsulting
> URL: http://www.roth.net/perl/packages
> Enabled: yes
> Last-Status: 200 OK
> Last-Access: 13 minutes ago
> Refresh-In: 47 minutes
>
> --
> Affijn, Ruud
>
> "Gewoon is een tijger."


Hello, thanks for all the suggestions. But i'm getting a lot of
different approaches. This is what i've done. I've downloaded the
nmake15.exe file and installed it into the c:\perl\bin directory. Then
i downloaded datetime0.35 from CPAN. And installed it into
C:\perl\DateTime-0.35 directory. When i run perl makefile i get the
following:

C:\Perl\DateTime-0.35>perl Makefile.PL
Testing if you have a C compiler
'cl' is not recognized as an internal or external command,
operable program or batch file.

 I cannot find a C compiler so I will install a perl-only
 implementation

 You can force installation of the XS version with

    perl Makefile.PL --xs

Checking if your kit is complete...
Looks good
Warning: prerequisite DateTime::Locale 0.31 not found.
Warning: prerequisite DateTime::TimeZone 0.38 not found.
Warning: prerequisite Params::Validate 0.76 not found.
Writing Makefile for DateTime

nmake ran ok. But when i ran  nmake test i got a lot of errors, here is
the last line of the output:
1 test and 1 subtest skipped.
Failed 39/41 test scripts, 4.88% okay. 3112/3114 subtests failed, 0.06%
okay.
NMAKE : fatal error U1077: 'C:\WINNT\system32\cmd.exe' : return code
'0xff'
Stop.



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

Date: Thu, 30 Nov 2006 17:58:27 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: using DateTime object
Message-Id: <ekn668.1h8.1@news.isolution.nl>

aswad schreef:
> Dr.Ruud wrote:
>> Ben Morrow:
>>> aswad:

>>>> When I ran ppm, I got this error
>>>> ppm install failed: Can't find any package that provide DateTime
>>>
>>> Then install it using CPAN.pm, in the usual way:
>>
>> That is not the usual way when you have AS-Perl on Windows. :)
>> First you add repositories and try on from there.
>
> Hello, thanks for all the suggestions. But i'm getting a lot of
> different approaches.

For ActivePerl on Windows, see the make-route as the last resort.
Just add the Winnipeg (and maybe the Roth) repositories to your ppm and
go from there.
Very convenient.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: 30 Nov 2006 09:33:49 -0800
From: "aswad" <clifton_francis@hotmail.com>
Subject: Re: using DateTime object
Message-Id: <1164908028.952884.276820@h54g2000cwb.googlegroups.com>


Dr.Ruud wrote:
> aswad schreef:
> > Dr.Ruud wrote:
> >> Ben Morrow:
> >>> aswad:
>
> >>>> When I ran ppm, I got this error
> >>>> ppm install failed: Can't find any package that provide DateTime
> >>>
> >>> Then install it using CPAN.pm, in the usual way:
> >>
> >> That is not the usual way when you have AS-Perl on Windows. :)
> >> First you add repositories and try on from there.
> >
> > Hello, thanks for all the suggestions. But i'm getting a lot of
> > different approaches.
>
> For ActivePerl on Windows, see the make-route as the last resort.
> Just add the Winnipeg (and maybe the Roth) repositories to your ppm and
> go from there.
> Very convenient.
>
> --
> Affijn, Ruud
>
> "Gewoon is een tijger."

This is the only package i have:
C:\> ppm repo list
+--------------------------------------------+
=A6 id =A6 pkgs =A6 name                           =A6
+----+------+--------------------------------=A6
=A6  1 =A6 6404 =A6 ActiveState Package Repository =A6
+--------------------------------------------+
 (1 enabled repository)

C:\>ppm repo desc 1
Id: 1
Name: ActiveState Package Repository
URL: http://ppm4.activestate.com/MSWin32-x86/5.8/819/package.xml
Enabled: yes
Last-Status: 304 Not Modified
Last-Access: 2 hours and 35 minutes ago
Refresh-In: overdue
Last-Modified: 3 days ago

When i run the program, this is what i get:
C:\SendMail>tt.pl
Can't locate Params/Validate.pm in @INC (@INC contains:
C:/Perl/site/lib C:/Perl/lib .) at C
:/Perl/site/lib/DateTime/Duration.pm line 7.
BEGIN failed--compilation aborted at
C:/Perl/site/lib/DateTime/Duration.pm line 7.
Compilation failed in require at C:/Perl/site/lib/DateTime.pm line 51.
BEGIN failed--compilation aborted at C:/Perl/site/lib/DateTime.pm line
51.
Compilation failed in require at C:\SendMail\TT.pl line 2.
BEGIN failed--compilation aborted at C:\SendMail\TT.pl line 2.



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

Date: Thu, 30 Nov 2006 21:44:08 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: using DateTime object
Message-Id: <eknjkl.1bg.1@news.isolution.nl>

aswad schreef:
> Dr.Ruud:

>> For ActivePerl on Windows, see the make-route as the last resort.
>> Just add the Winnipeg (and maybe the Roth) repositories to your ppm
>> and go from there.
>> Very convenient.
>
> This is the only package i have:
> C:\> ppm repo list
> +--------------------------------------------+
> ¦ id ¦ pkgs ¦ name                           ¦
> +----+------+--------------------------------¦
> ¦  1 ¦ 6404 ¦ ActiveState Package Repository ¦
> +--------------------------------------------+
>  (1 enabled repository)

That is not a package but a repository.

Like I said two times before now, add more repositories. See "perldoc
ppm" for how to do that, or use the new GUI-ppm, which has a form under
Edit/Preferences for adding repositories. For the details of the
repositories to add, see an earlier posting.

(Please only quote relevant text, so no signatures or any other text
from previous postings that is no longer relevant, so certainly remove
this text and the following sig if you need to reply.)

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Thu, 30 Nov 2006 12:22:25 -0600
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: What is a glob variable?
Message-Id: <301120061222259922%brian.d.foy@gmail.com>

In article <slrnemr2qk.ons.perlster@phenix.rootshell.be>, perlster
<perlster@phenix.rootshell.be> wrote:

> 
> sub my_sub(*some_var);
> 
> Where in perldoc would I find documentation
> on this *some_var? TIA....

There's a chapter in Advanced Perl Programming (First Edition) that
explains typeglobs, and I've recreated most of that for _Mastering
Perl_:

http://www252.pair.com/comdog/mastering_perl/Chapters/08.symbol_tables.h
tml

-- 
Posted via a free Usenet account from http://www.teranews.com



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

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


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