[29199] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 443 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 17 21:09:50 2007

Date: Thu, 17 May 2007 18:09:08 -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 May 2007     Volume: 11 Number: 443

Today's topics:
    Re: Apache+Perl Net::SMTP Strange problem <glex_no-spam@qwest-spam-no.invalid>
        Mod_perl and Signals janedunnie@gmail.com
    Re: Mod_perl and Signals <glex_no-spam@qwest-spam-no.invalid>
    Re: Mod_perl and Signals xhoster@gmail.com
    Re: Mod_perl and Signals janedunnie@gmail.com
    Re: Mod_perl and Signals janedunnie@gmail.com
    Re: Modifying $_ in "map", with an array containing a g <wahab-mail@gmx.de>
    Re: Modifying $_ in "map", with an array containing a g <glennj@ncf.ca>
    Re: Modifying $_ in "map", with an array containing a g <wahab-mail@gmx.de>
    Re: Modifying $_ in "map", with an array containing a g <gypark@gmail.com>
    Re: Parsing a text file line-by-line: skipping badly-fo <joe@inwap.com>
    Re: Parsing a text file line-by-line: skipping badly-fo <joe@inwap.com>
    Re: regular expressions? <find.ivan@gmail.com>
        Setting up YaBB Perl forum - weird respond as plain tex van100j@gmail.com
    Re: Setting up YaBB Perl forum - weird respond as plain usenet@DavidFilmer.com
    Re: Simple Regular Expression Help <greg@lazymountain.com>
    Re: Sorting Hash by Value and Key vunet.us@gmail.com
    Re: Sorting Hash by Value and Key <wahab-mail@gmx.de>
    Re: Sorting Hash by Value and Key <wahab-mail@gmx.de>
    Re: Sorting Hash by Value and Key vunet.us@gmail.com
    Re: Sorting Hash by Value and Key <bik.mido@tiscalinet.it>
    Re: Sorting Hash by Value and Key <mgjv@tradingpost.com.au>
    Re: Store Object Class in DBM Hash <mgjv@tradingpost.com.au>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 17 May 2007 14:04:38 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Apache+Perl Net::SMTP Strange problem
Message-Id: <464ca746$0$506$815e3792@news.qwest.net>

zhaoningli@gmail.com wrote:

> On May 16, 2:07 pm, zhaonin...@gmail.com wrote:
>> I am setting up a web application using apache 2.2 + perl v5.8.8 on
>> FC5. The application needs to send out email using a SMTP server as
>> mail relay (MTA). I wrote a test perl script test.cgi. Run the script
>> as CGI, it always return with errors. The code fails at:
>>
>> my $smtp=new Net::SMTP($smtpserver, Timeout =>60) || die 'Cannot
>> connect to smtp server';
>>
>> The apache server is configured to run at apache:apache. The above
>> script works well if I use
>>
>> bash# sudo -u apache perl test.cgi.
>>
>> Please advise how to fix this. Thanks a lot.

First, can you send e-mail through $smtpserver directly?

Second, have die() show you why the method failed:

my $smtp=new Net::SMTP($smtpserver, Timeout =>60)
	or die "Error for $smtpserver: $!";

Third, try the Debug parameter.


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

Date: 17 May 2007 14:17:10 -0700
From: janedunnie@gmail.com
Subject: Mod_perl and Signals
Message-Id: <1179436630.178015.225250@y80g2000hsf.googlegroups.com>

Hi,

I'm in the process of transferring code to a new Linux machine, with a
newer version of Perl (Perl 5.8.5), and also cleaning up the code to
run under mod_perl. However, I'm having problems with some code that
I've previously used, which no longer appears to work under the new
config. I understand from scouring the web that signal handling
changed in 5.8+, but despite trying every method I could find, I still
can't get it to work under mod_perl. However, each method works
outside of mod_perl.

The original code was similar to this:

eval
{
local $SIG{ALRM} = sub {die "alarm\n"};
alarm 5;
system('some command');
alarm (0);
};


New code which I've tried under 5.8, and which works outside of
mod_perl, includes the following:

use POSIX qw(SIGALRM);
POSIX::sigaction(SIGALRM, POSIX::SigAction->new(sub{die "alarm"})) or
die "Error setting SIGALRM handler: $!\n";

eval{
alarm 5;
system('some command');
alarm (0);
};

POSIX::sigaction(SIGALRM, $oldaction);


Other new code which I've tried, and which also works outside of
mod_perl, is as follows:

use Sys::SigAction qw(timeout_call);

if (timeout_call(5, sub{my $retval=&test();}))
{
print "timed out\n";
};

sub test{
system('some command');
}


When I say that these methods "don't work" under mod_perl I mean that
the processes simply continue without waiting for the alarm. They
don't error ... they just don't wait for the specified command(s) to
finish.

So, I'm wondering what kind of work-around there may be, or what
alternative method of handling time-outs may exist in mod_perl under
5.8.x.

Any assistance much appreciated.

Thanks!
Jane



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

Date: Thu, 17 May 2007 16:41:55 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Mod_perl and Signals
Message-Id: <464ccc24$0$509$815e3792@news.qwest.net>

janedunnie@gmail.com wrote:
> Hi,
> 
> I'm in the process of transferring code to a new Linux machine, with a
> newer version of Perl (Perl 5.8.5), and also cleaning up the code to
> run under mod_perl. However, I'm having problems with some code that
> I've previously used, which no longer appears to work under the new
> config. I understand from scouring the web that signal handling
> changed in 5.8+, but despite trying every method I could find, I still
> can't get it to work under mod_perl. However, each method works
> outside of mod_perl.
> 
> The original code was similar to this:
> 
> eval
> {
> local $SIG{ALRM} = sub {die "alarm\n"};
> alarm 5;
> system('some command');
> alarm (0);
> };
[...]
> So, I'm wondering what kind of work-around there may be, or what
> alternative method of handling time-outs may exist in mod_perl under
> 5.8.x.
> 
> Any assistance much appreciated.

Doing a simple search on the Internet showed that this was discussed
extensively back in 2004.  It's Apache 2, not perl. In short,
using prefork MPM should work, or Apache 1.3.  No idea if this is
still the case with the latest version of Apache, however
looking through Apache 2 documentation on signals/threads
should cover it or asking on an Apache related newsgroup.

http://marc.info/?t=110175278300007&r=1&w=2


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

Date: 17 May 2007 21:55:24 GMT
From: xhoster@gmail.com
Subject: Re: Mod_perl and Signals
Message-Id: <20070517175526.839$Yo@newsreader.com>

janedunnie@gmail.com wrote:
> Hi,
>
> I'm in the process of transferring code to a new Linux machine, with a
> newer version of Perl (Perl 5.8.5), and also cleaning up the code to
> run under mod_perl. However, I'm having problems with some code that
> I've previously used, which no longer appears to work under the new
> config. I understand from scouring the web that signal handling
> changed in 5.8+, but despite trying every method I could find, I still
> can't get it to work under mod_perl. However, each method works
> outside of mod_perl.

What do you mean by each method?  Does the entire thing as a whole work
outside of mod_perl under 5.8.5?


>
> The original code was similar to this:
>
> eval
> {
> local $SIG{ALRM} = sub {die "alarm\n"};
> alarm 5;
> system('some command');
> alarm (0);
> };
>
> New code which I've tried under 5.8, and which works outside of
> mod_perl, includes the following:


What does the old code do under 5.8.5 outside of mod_perl?



>
> use POSIX qw(SIGALRM);
> POSIX::sigaction(SIGALRM, POSIX::SigAction->new(sub{die "alarm"})) or
> die "Error setting SIGALRM handler: $!\n";
>
> eval{
> alarm 5;
> system('some command');
> alarm (0);
> };
>
> POSIX::sigaction(SIGALRM, $oldaction);

Where does $oldaction get set?


>
> Other new code which I've tried, and which also works outside of
> mod_perl, is as follows:
>
> use Sys::SigAction qw(timeout_call);
>
> if (timeout_call(5, sub{my $retval=&test();}))
> {
> print "timed out\n";
> };
>
> sub test{
> system('some command');
> }
>
> When I say that these methods "don't work" under mod_perl I mean that
> the processes simply continue without waiting for the alarm.

They aren't supposed to wait for the alarm.  alarms are what happens when
you are waiting for something *else*.

> They
> don't error ... they just don't wait for the specified command(s) to
> finish.

What is the return value of Perl's system function?  How do you know
that it is not waiting?  Can you produce a runnable, self-diagnosing script
and show us the results you get from it, rather than your intepretation of
those results?  Replacing system('some command') with, for example:

print "before time is ", time(), "<br>";
print "system returned with ", system ("sleep 20"), "<br>";
print "after  time is ", time(), "<br>";

Xho

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


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

Date: 17 May 2007 15:10:03 -0700
From: janedunnie@gmail.com
Subject: Re: Mod_perl and Signals
Message-Id: <1179439802.953268.53140@u30g2000hsc.googlegroups.com>


> What do you mean by each method?  Does the entire thing as a whole work
> outside of mod_perl under 5.8.5?

"Each method" = each of the different ways that I've tried this. Yes,
the entire thing as a whole works outside of mod_perl under 5.8.5.


> What does the old code do under 5.8.5 outside of mod_perl?

Runs a couple of other jobs, which may or may not complete within the
alarm time. If one of them does not complete then the alarm will
"ring." ... which is fine, and I carry on my merry way without
worrying about the result. On the other hand they may both complete
within the time provided and in which case I'll get to the next part
of the script more quickly.


> Where does $oldaction get set?

Forget it ... I inadvertently pasted some code from another version of
my attempts. It's unrelated to the code directly above it.


> They aren't supposed to wait for the alarm.  alarms are what happens when you are waiting for something *else*.

Yes, exactly. I am waiting for "some command" to finish.


> How do you know that it is not waiting?  Can you produce a runnable, self-diagnosing script ...etc.

Having spent a day testing it, I can vouch for it not waiting. Yes,
I've done all the self-diagnosing scripts etc, with start-time, end-
time, etc, etc.


Thanks.



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

Date: 17 May 2007 16:59:52 -0700
From: janedunnie@gmail.com
Subject: Re: Mod_perl and Signals
Message-Id: <1179446391.689392.299720@p77g2000hsh.googlegroups.com>

Per' the comments from J. Gleixner, above, yes, I can see that it's an
Apache2 problem now, as opposed to Perl ... Thanks.

Re' my previous comments, then I should have clarified that when I
said I was running it out of mod_perl, and it worked, that I was
running it from the command line ... where Apache obviously isn't
involved at all ... and hence why it worked.

Thanks to all ... Will need to take a look at prefork MPM.

Jane




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

Date: Thu, 17 May 2007 20:20:23 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Modifying $_ in "map", with an array containing a gap...
Message-Id: <f2i6ok$obf$1@mlucom4.urz.uni-halle.de>

Brian McCauley wrote:
> The subtly is the difference between elements of an array that are
> undef and ones that are non-existent.

Very interesting, I wasn't even aware of it.

Lets see:
   my @array;
   $array[0] = 0;
   $array[9] = 9;

then elements 1..8 will be(Devel::Peek)
"NULL" SV's with Refcnt of 1

    SV = NULL(0x0) at 0x182d528
      REFCNT = 1
      FLAGS = ()


in 'for', these NULL SV's are replaced dynamically
by something strange:

    SV = PVLV(0x18b3164) at 0x182d510
      REFCNT = 2
      FLAGS = (GMG,SMG)
      IV = 0
      NV = 0
      PV = 0
      MAGIC = 0x18e3474
        MG_VIRTUAL = &PL_vtbl_defelem
        MG_TYPE = PERL_MAGIC_defelem(y)
      TYPE = y
      TARGOFF = 1
      TARGLEN = -1
      TARG = 0x1b8d8e4
      SV = PVAV(0x22b4c4) at 0x1b8d8e4
        REFCNT = 3
        FLAGS = (PADBUSY,PADMY)
        IV = 0
        NV = 0
        ARRAY = 0x20093bc
        FILL = 9
        MAX = 11
        ARYLEN = 0x0
        FLAGS = (REAL)
        Elt No. 0
        SV = IV(0x1823db8) at 0x1ffca94
          REFCNT = 1
          FLAGS = (IOK,pIOK)
          IV = 0
        Elt No. 1
        Elt No. 2
        Elt No. 3


==> Dump $_ for @array


in 'map', the same NULL SV's will keep NULL
and get Refcounts of  -2^31 plus the READONLY flag:

    SV = NULL(0x0) at 0x224b30
      REFCNT = 2147479514
      FLAGS = (READONLY)

==> map Dump($_), @array


Very interesting. Thanks for
giving some infos on the topic.

Regards

Mirco



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

Date: 17 May 2007 18:52:42 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: Modifying $_ in "map", with an array containing a gap...
Message-Id: <slrnf4p93r.gfv.glennj@smeagol.ncf.ca>

At 2007-05-17 11:16AM, "Mirco Wahab" wrote:
>  Glenn Jackman wrote:
> > At 2007-05-17 11:02AM, "ron.hartikka@gmail.com" wrote:
> >>  
> >>  $array2[0] = 0;
> >>  $array2[9] = 9;
> >>  print "@array2", "\n";   # 0 "" "" ... "" 9
> >>  map { defined $_ ? $_ *= 10 : 0 } @array2;
> >>  print "@array2", "\n";   # 0 "" "" ... "" 90
> > 
> > Of course, @array2 no longer contains undefined values at this point:
> > it contains zeroes instead.
>  
>  Wrong guess ;)
>  
>  Of course will @array2 keep the undefs.

F*** me.  You're correct, of course.

-- 
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry


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

Date: Thu, 17 May 2007 20:48:44 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Modifying $_ in "map", with an array containing a gap...
Message-Id: <f2i8do$orp$1@mlucom4.urz.uni-halle.de>

Brian McCauley wrote:
> Note: if you think what map() does is odd then consider what happens
> if you pass a gappy array to a subroutine! Here gap in the argument
> leave gaps in @_ but modifying the missing element in @_ gives no
> error but does not modify the missing element in the original array.
> 
> sub inc {
>     for my $i ( 0.. $#_ ) {
> 	$_[$i]++;
>     }
> }

More funny, *in* the sub, the NULL SV
*is* autovivicated, but *after* the sub,
the vivicated SV* isn't propagated back
to the original array (Devel::Peek 'Dump'):

    sub inc {
        $_[1]++;
        Dump($_[1]);
    }

   SV = IV(0x191f83c) at 0x1ffcc08
     REFCNT = 1
     FLAGS = (IOK,pIOK)
     IV = 1

  - - - - - - - - - - -

   inc @array;
   Dump($array[1]);

   SV = NULL(0x0) at 0x1b93ea8
     REFCNT = 1
     FLAGS = ()

Rergards

Mirco


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

Date: 17 May 2007 15:31:10 -0700
From: Raymundo <gypark@gmail.com>
Subject: Re: Modifying $_ in "map", with an array containing a gap...
Message-Id: <1179441070.351264.205240@q75g2000hsh.googlegroups.com>

On 5=BF=F918=C0=CF, =BF=C0=C0=FC2=BD=C328=BA=D0, Brian McCauley <nobul...@g=
mail.com> wrote:
> On May 17, 8:40 am, Raymundo <gyp...@gmail.com> wrote:
>
> > I'm sorry I'm not good at English. :-)
>
> Good enough.
>
>
>
>
>
> > foreach and map functions show the same result when an array has no
> > gap.
>
> > @array =3D (1, 2, 3, 4);
> > foreach (@array) {
> >     $_ *=3D 10}
>
> > # now, $array =3D (10, 20, 30, 40)
>
> > @array =3D (1, 2, 3, 4);
> > map { $_ *=3D 10 } @array;
> > # now, $array =3D (10, 20, 30, 40)
>
> > However, if an array contains a gap...
>
> >       1 $array1[0] =3D 0;
> >       2 $array1[9] =3D 9;          # now $array1 =3D (0, undef,
> > undef, ... , 9);
> >       3 print "@array1", "\n";   # 0 "" "" ... "" 9
> >       4 foreach (@array1) {
> >       5     $_ *=3D 10             # $array1 =3D (0, 0, 0, ... , 90)
> >       6 }
> >       7 print "@array1", "\n";   # 0 0 0 ... 0 90
> >       8
> >       9
> >      10 $array2[0] =3D 0;
> >      11 $array2[9] =3D 9;
> >      12 print "@array2", "\n";   # 0 "" "" ... "" 9
> >      13 map { $_ *=3D 10 } @array2; # ERROR!!!!!!
> >      14 print "@array2", "\n";
>
> > line 1-7 work well, but using map, line 13 reports an error:
>
> > Modification of a read-only value attempted at t2.pl line 13.
>
> > Before line 13, line 12 prints the intervening elements, treating
> > undef as null string. Then why does line 13 make such error? Is it a
> > bug? or...?
>
> Yes it's a bug.
>
> The subtly is the difference between elements of an array that are
> undef and ones that are non-existent.
>
> See "perldoc -f exsts".
>
> If I say..
>
> my @array2;
> $array2[0] =3D 0;
> $array2[9] =3D 9;
>
> ..then elements 1..8 of @array are not just undef but non-existent.
>
> In for() there is special magic to allow you to have a reference to a
> non-existent element of an array without it becoming autovivified.
>
> In map() there's evidently no such magic. In the LIST argument in
> map() any non-existent elements are replaced by the "one true undef"
> aka PL_sv_undef. (The one you get a reference to by saying \undef).
>
> IMNSHO this needs to be explained in "perldoc -f map" or changed.
>
> Note: if you think what map() does is odd then consider what happens
> if you pass a gappy array to a subroutine! Here gap in the argument
> leave gaps in @_ but modifying the missing element in @_ gives no
> error but does not modify the missing element in the original array.
>
> sub inc {
>     for my $i ( 0.. $#_ ) {
>         $_[$i]++;
>     }
>
> }
>
> my @array;
> $array[1]=3D666;
>
> inc @array;
>
> print join ',' =3D> @array; # ,667- =B5=FB=BF=C2 =C5=D8=BD=BA=C6=AE =BC=
=FB=B1=E2=B1=E2 -
>
> - =B5=FB=BF=C2 =C5=D8=BD=BA=C6=AE =BA=B8=B1=E2 -

Thank you, McCauley. Now I understand (I hope I do :-) the situation.

And I thank everyone who replied in this thread. I forgot to say in my
first post but... yes, I know that the main purpose of map() is making
a new list rather than modifying a existing array. However I thought
it had to be supported (as perldoc -f map says) and I had no idea why
for() and map() operate differently.

Raymundo at South Korea



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

Date: Thu, 17 May 2007 12:14:34 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Parsing a text file line-by-line: skipping badly-formed lines?
Message-Id: <K8GdnTRN1e4-NNHbnZ2dnUVZ_ragnZ2d@comcast.com>

denis.papathanasiou@gmail.com wrote:

> Yes, I'd tried that earlier, before using split, and here's what
> happened:
> 
> $ wc -l qte20070430
> wc: qte20070430: Input/output error
>   120781227 qte20070430

When using "wc qte20070430", is the character count either
2147483647 or 4294967295 ?

If not, try:
   cat qte20070430 >/dev/null          || echo "disk file error"
   sed 's/a/a/' qte20070430 >/dev/null || echo "disk file error"
   dd if=qte20070430 of=/dev/null      || echo "disk file error"
   dmesg | tail; tail /var/log/messages


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

Date: Thu, 17 May 2007 12:25:35 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Parsing a text file line-by-line: skipping badly-formed lines?
Message-Id: <xrmdne9xaqSlMdHbnZ2dnUVZ_uGknZ2d@comcast.com>

denis.papathanasiou@gmail.com wrote:

> The issue seems to be that perl's <> construct is that it stops (i.e.,
> "while (<$in>)" evaluates to false) in the event of an i/o error
> regardless of how $/ is defined.
> 
> And that's exactly what I *don't* want it to do.

What does eof($in) return after the while() stops?

If you attempt to read one more line from <$in>, does it
return undef, or a line from the file, or does it switch
to reading from STDIN?

	-Joe


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

Date: 17 May 2007 16:19:22 -0700
From: Ivan <find.ivan@gmail.com>
Subject: Re: regular expressions?
Message-Id: <1179443962.616288.291600@q75g2000hsh.googlegroups.com>

On May 17, 10:29 pm, Martijn Lievaart <m...@rtij.nl.invlalid> wrote:
> On Wed, 16 May 2007 18:53:45 -0700, Ivan wrote:
> > Hi all..
>
> > I'm in need of some help..
>
> > I'm looking after a subversion machine with many repositories and many
> > users in the passwd files for each..
>
> > Currently when I want to get rid of one of the users, I normally have to
> > go through each repository, look in the passwd file and delete the user
> > manually..
>
> > I'm assuming with perl I might be able to make up a quick script that
> > will look inside each repo, find the line with the user, delete it and
> > save the file.. It will save a lot of my time..
>
> > Either a perl script or a shell script might be suitable for this.. All
> > I got at the moment is the command line: grep -l "troppd" */conf/ passwd
> > So instead of going through hundreds of repositories, I only have to go
> > into the ones where "troppd" appears and I can delete it..
>
> Here's how I would do this. I assume these passwd files are regular
> passwd files, so I can assume the username starts at the beginning of the
> line followed by a colon. If this is assumption is not correct, slight
> modifications will be needed to the regexps.
>
> $TODELETE="troppd"
> perl -n -i.bak -e "/^$TODELETE:/ or print" \
>       $(grep -l "^$TODELETE:" */conf/ passwd)
>
> This can also be solved easily with sed or awk, but perl has a convenient
> in-place edit with the -i switch. See perldoc perlrun for a description
> of these switches.
>
> Also note that this only modifies the files that do contain the user,
> which you most probably will want. Otherwise leave out the grep part and
> operate on */conf/passwd directly.
>
> As the above is untested code, I would test thoroughly before running
> this in production!
>
> HTH,
> M4



Hi there..
Thank you kindly for your reply ..
I did in fact got it working (using sed, not awk) .. But it works just
fine ..
Not knowing much of perl, I will look at your script and try to make
most sense of it, as it looks a bit more robust than the single line
of sed coding .


Cheers,

Ivan.



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

Date: 17 May 2007 15:13:10 -0700
From: van100j@gmail.com
Subject: Setting up YaBB Perl forum - weird respond as plain text in browser, including headers
Message-Id: <1179439990.194155.103880@p77g2000hsh.googlegroups.com>

Hi everyone,

I'm a real beginner to perl, and tried to start messing around with
YaBB forum. It all went smooth on one server, but when I've tried to
install the forum on another one and run Setup.pl, I get a plain text
in my browser including header. Here is the respond I get in my
browser:

Status: 200 OK
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Content-Type: text/html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>YaBB 2 Setup</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
</head>
<body>

<!-- Main Content -->
<div style="height: 40px;">&nbsp;</div>

       <br /><br /><br /><form action="Setup.pl?action=adminlogin2"
method="post"><center>
       <table width="20%" border="0" bgcolor= "#000000"
cellspacing="1"
cellpadding="0">
       <tr><td>
       <table width="100%" border="0" bgcolor= "#FEFEFE"
cellspacing="1"
cellpadding="3">
       <tr>
               <td width="100%" align="center">
               <span style="font-family: Arial; font-size: 13px;
color: #000000;">
               Enter the password for user <b>admin</b><br />to gain
access to the
Setup Utility
               </span>
               </td>
       </tr>
       <tr>
               <td width="100%" align="center">
               <span style="font-family: Arial; font-size: 13px;
color: #000000;">
               <input type="password" size="30" name="password" />
               <input type="hidden" name="username" value="admin" />
               <input type="hidden" name="cookielength" value="1500" /
>
               </span>
               </td>
       </tr>
       <tr>
               <td width="100%" align="center">
               <span style="font-family: Arial; font-size: 13px;
color: #000000;">
               <input type="submit" value="Submit" />
               </span>
               </td>
       </tr>
       </table>
       </td></tr></table></center></form>
       <br />

</body>
</html>

Thanks



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

Date: 17 May 2007 16:21:54 -0700
From: usenet@DavidFilmer.com
Subject: Re: Setting up YaBB Perl forum - weird respond as plain text in browser, including headers
Message-Id: <1179443160.689565.161240@u30g2000hsc.googlegroups.com>

On May 17, 3:13 pm, van1...@gmail.com wrote:
[snip multipost]

Please don't multipost.


--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)




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

Date: Thu, 17 May 2007 10:10:34 -0800
From: Greg Jetter <greg@lazymountain.com>
Subject: Re: Simple Regular Expression Help
Message-Id: <134p6ldc5qf1r89@corp.supernews.com>

vunet.us@gmail.com wrote:

> How can I strip this line with regular expession to get 12345 number
> within brackets:
> 
> $line = "some text is here (12345 ms)";
> 
> This did not work:
> 
> $text = $line;
> $text =~ m/\((\d+)\)/;


this worked:

use strict;

my $line = "some text is here (12345 ms)";

$line=~ m/(\d\d\d\d\d)/;

print $1;

prints :12345

there are I'm sure a few other ways  , but this one is pretty simple , if
you know the pattern to look for ,in your case 5 consecutive digit's.

good luck

Greg Jetter
Alaska-Internet-Solutions.com



-- 
"You are what you is" - Frank Zappa


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

Date: 17 May 2007 11:20:38 -0700
From: vunet.us@gmail.com
Subject: Re: Sorting Hash by Value and Key
Message-Id: <1179426038.046390.76990@o5g2000hsb.googlegroups.com>

spoon-feeding did not work for me. this is my first perl file but i do
try hard anyway. Micro's solution did not sort right (for me) and
Michele's solution i cannot print.
anyway, my goal is (after your feedback) to sort all values and then
sort only thoses keys whose values are the same. example:

%grades = (
        0 => 1,
        7 => 2,
        6 => 3,
        5 => 4,
        8 => 5,
        9 => 6, _______<<
        1 => 7,
        2 => 7,
        3 => 7,
        4 => 7,
);

PS: YES, I need to print, not sort a hash itself.
Thanks



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

Date: Thu, 17 May 2007 20:36:41 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Sorting Hash by Value and Key
Message-Id: <f2i7n5$oi7$1@mlucom4.urz.uni-halle.de>

vunet.us@gmail.com wrote:
> spoon-feeding did not work for me. this is my first perl file but i do
> try hard anyway. Micro's solution did not sort right (for me) and
> Michele's solution i cannot print.
> anyway, my goal is (after your feedback) to sort all values and then
> sort only thoses keys whose values are the same. example:

OK, so you want a numerical sort on the values and
then (if equal) a numerical sort on the keys?

You need to employ an extra array of the keys combined
with a sort function, which does what you want, like

   ...

   my %grades = (
           0 => 1,
           9 => 6,
           1 => 7,
           2 => 7,
           3 => 7,
           7 => 2,
           6 => 3,
           5 => 4,
           8 => 5,
           4 => 7    );

   my @hsort =
          sort { $grades{$a} <=> $grades{$b} || $a <=> $b }
             map $_,
                keys %grades;

   print "$_ => $grades{$_}\n" for @hsort;

   ...


In Perl, you have to look hard if your comparison
compares strings (characters) or numeric values.

Regards

Mirco


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

Date: Thu, 17 May 2007 21:04:33 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Sorting Hash by Value and Key
Message-Id: <f2i9bd$p17$1@mlucom4.urz.uni-halle.de>

Mirco Wahab wrote:
>   my @hsort =
>          sort { $grades{$a} <=> $grades{$b} || $a <=> $b }
>             map $_,
>                keys %grades;

WTF did I smoke here :)

the line

 >             map $_,

is of course superfluous

Sorry,

M.


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

Date: 17 May 2007 12:51:37 -0700
From: vunet.us@gmail.com
Subject: Re: Sorting Hash by Value and Key
Message-Id: <1179431497.821867.127230@u30g2000hsc.googlegroups.com>

On May 17, 2:36 pm, Mirco Wahab <wahab-m...@gmx.de> wrote:
> vunet...@gmail.com wrote:
> > spoon-feeding did not work for me. this is my first perl file but i do
> > try hard anyway. Micro's solution did not sort right (for me) and
> > Michele's solution i cannot print.
> > anyway, my goal is (after your feedback) to sort all values and then
> > sort only thoses keys whose values are the same. example:
>
> OK, so you want a numerical sort on the values and
> then (if equal) a numerical sort on the keys?
>
> You need to employ an extra array of the keys combined
> with a sort function, which does what you want, like
>
>    ...
>
>    my %grades = (
>            0 => 1,
>            9 => 6,
>            1 => 7,
>            2 => 7,
>            3 => 7,
>            7 => 2,
>            6 => 3,
>            5 => 4,
>            8 => 5,
>            4 => 7    );
>
>    my @hsort =
>           sort { $grades{$a} <=> $grades{$b} || $a <=> $b }
>              map $_,
>                 keys %grades;
>
>    print "$_ => $grades{$_}\n" for @hsort;
>
>    ...
>
> In Perl, you have to look hard if your comparison
> compares strings (characters) or numeric values.
>
> Regards
>
> Mirco

Ideal, thanks



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

Date: Thu, 17 May 2007 22:49:47 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Sorting Hash by Value and Key
Message-Id: <1rfp43ls9smcn7vd2pclvm23ps1esn03vr@4ax.com>

On Thu, 17 May 2007 21:04:33 +0200, Mirco Wahab <wahab-mail@gmx.de>
wrote:

>WTF did I smoke here :)
>
>the line
>
> >             map $_,
>
>is of course superfluous

STS? (Schwartzian Transform Syndrome?)

Kinda reminds me of when I discovered the calculus of residues. I was
so fond of it that at some time I found myself applying it to an
integral which, after the work was done... I realized was a trivial
one!


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 18 May 2007 07:14:49 +1000
From: Martien verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Sorting Hash by Value and Key
Message-Id: <slrnf4phe8.3tr.mgjv@martien.heliotrope.home>

On 17 May 2007 06:57:20 -0700,
	vunet.us@gmail.com <vunet.us@gmail.com> wrote:
> Could someone show how to sort my hash by values (primary sorting) and
> then by key for the same values:

In addition to the answers you already have, you should probably also
have a look in the FAQ, section 4, as that answers your question:

How do I sort a hash (optionally by value instead of key)?

and also 

How do I sort an array by (anything)?

This FAQ also refers to the 'far more than you ever wanted to know'
document on sorting at http://www.perl.com/CPAN/doc/FMTEYEWTK/sort.html

Martien
-- 
                                        |
Martien Verbruggen                      | "In a world without fences,
                                        |  who needs Gates?"
                                        |


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

Date: Fri, 18 May 2007 07:20:57 +1000
From: Martien verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Store Object Class in DBM Hash
Message-Id: <slrnf4phpp.3tr.mgjv@martien.heliotrope.home>

On 16 May 2007 09:41:44 -0700,
	michael.shnitzer@gmail.com <michael.shnitzer@gmail.com> wrote:
> It was my understanding that once a DBM hash was tied to a file, it
> can be accessed using the same methods as a regular hash.  For
> simplicities sake I created a small perl program to demonstrate what I
> am trying to do:

[snip code trying to store a blessed reference in a dbm file]

At the end of the perltie doucmentation you'll find the information
you're probably looking for:

BUGS
       You cannot easily tie a multilevel data structure (such as a hash
       of hashes) to a dbm file.  The first problem is that all but GDBM
       and Berkeley DB have size limitations, but beyond that, you also
       have problems with how references are to be represented on
       disk.

You need to manually serialise your data before storing it, or use a
module that does it for you. MLDBM is one possibility.

Martien
-- 
                        | 
Martien Verbruggen      | There are only 10 types of people in the
                        | world; those who understand binary and those
                        | who don't.


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

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


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