[31376] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2628 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 9 14:09:27 2009

Date: Fri, 9 Oct 2009 11:09:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 9 Oct 2009     Volume: 11 Number: 2628

Today's topics:
    Re: Binary size differences between 5.8 and 5.10 <abc@def.com>
    Re: Binary size differences between 5.8 and 5.10 <jurgenex@hotmail.com>
    Re: Binary size differences between 5.8 and 5.10 <ben@morrow.me.uk>
    Re: Binary size differences between 5.8 and 5.10 <ben@morrow.me.uk>
    Re: Binary size differences between 5.8 and 5.10 <abc@def.com>
    Re: Binary size differences between 5.8 and 5.10 <abc@def.com>
        FAQ 5.13 How can I output my numbers with commas added? <brian@theperlreview.com>
        FAQ 7.7 Why do Perl operators have different precedence <brian@theperlreview.com>
        FAQ 8.24 Why can't I get the output of a command with s <brian@theperlreview.com>
    Re: How to parse section of html code? <netnews@invalid.com>
        Loop consuming my list <marc.girod@gmail.com>
    Re: Loop consuming my list <peter@makholm.net>
    Re: Loop consuming my list <marc.girod@gmail.com>
    Re: Loop consuming my list <devnull4711@web.de>
    Re: Loop consuming my list <marc.girod@gmail.com>
    Re: Perl Tk Grid QoS@invalid.net
    Re: Perl Tk Grid <f1crazed@gmail.com>
        Simple question about CGI response after form data has  <r.ted.byers@gmail.com>
    Re: Simple question about CGI response after form data  <smallpond@juno.com>
    Re: time format +1 hour <josef.moellers@ts.fujitsu.com>
    Re: time format +1 hour <josef.moellers@ts.fujitsu.com>
    Re: time format +1 hour <slick.users@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 09 Oct 2009 02:13:29 +0100
From: zaphod <abc@def.com>
Subject: Re: Binary size differences between 5.8 and 5.10
Message-Id: <xdqdnbyE37qkE1PXnZ2dnUVZ8mGdnZ2d@brightview.co.uk>

Ben Morrow wrote:
 
> Well... what are you trying to achieve? If you are trying to compile a
> perl suitable for use as your system perl, I would suggest you put the
> proper binary back where you found it :). You should probably restore
> the whole of /usr from backup, in fact, since the reinstall will have
> overwritted a whole lot of other important stuff.
> 
> Otherwise: what will you be using this perl for? -Duseshrplib is usefil
> if you will have several binaries linking the same libperl.so, so if you
> are going to be building e.g. Vim or mod_perl against this perl, you
> want it. If you aren't, it will make perl a little larger and a little
> slower for no benefit. I would recommend against -Duseithreads on a Unix
> system unless you know you need it, as it just makes perl slower and
> there is rarely any point using Perl threads on a system with a real
> fork(2). If you are building mod_perl and you omit ithreads you will
> need to add -Dusemultiplicity.
> 
> The other significant options (use64bit{int,all}, usemymalloc=n) are
> presumably the defaults on your system, since Apple didn't specify them.
> 
> Ben
> 

I wasn't looking to replace the system Perl. I thought 5.10 would sit alongside it and could be managed via symlinks. I want Perl 5.10 for obvious reasons, ie. new features and enhancements. This is a home office workstation for web development, not a server. Since most @INC directories are version-specific what exactly has been overwritten?

So, I need to completely restore /usr? How come?

zaphod


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

Date: Thu, 08 Oct 2009 18:14:01 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Binary size differences between 5.8 and 5.10
Message-Id: <713tc51o9c3oqpcoe2eskg9eohvlstq4cc@4ax.com>

zaphod <abc@def.com> wrote:
>Jürgen Exner wrote:
>> zaphod <abc@def.com> wrote:
>>> I've just installed Perl 5.10.1 on OS X Leopard after backing up the original system binary. When I looked at 3 different Perl binaries I was puzzled by the huge differences in size:
>>>
>>> - OS X 10.5 system Perl 5.8.8 = 48K
>>> - New Perl 5.10.1 = 2628K
>>> - MacPorts Perl 5.8.9 = 1192K
>>>
>>> What accounts for the differences?
>> 
>> Wild guess: staticly versus dynamically linked libraries
>
>The README.macosx suggests you're right. Any advantages in either of these options? I'm also recompiling without -arch i686 as this is a PPC Mac G5.

The same as with any other statically versus dynamically linked program.
Statically linked programs are much(!) larger, on the HD as well as in
RAM at runtime. And any update of the library requires at least a
re-link of the program.

On the other hand they keep working even if the library or the library
loader is corrupt or not accessible because they need neither.
That is why the bootstrap programs that are to run before the dyn libs
are mounted and up and running must be statically linked. As must be all
tools required by those bootstrap programs.
And the basic tool kit for the sys admin to recover from a bad system
crash should better be statically linked, too. Otherwise he may have
some difficulties running his tools to repair the mount table or the
dynamic link loader or the dynamic libraries.

jue


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

Date: Fri, 9 Oct 2009 02:44:40 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Binary size differences between 5.8 and 5.10
Message-Id: <85h2q6-1i92.ln1@osiris.mauzo.dyndns.org>


Quoth Jürgen Exner <jurgenex@hotmail.com>:
> zaphod <abc@def.com> wrote:
> >Jürgen Exner wrote:
> >> zaphod <abc@def.com> wrote:
> >>> I've just installed Perl 5.10.1 on OS X Leopard after backing up the
> original system binary. When I looked at 3 different Perl binaries I was
> puzzled by the huge differences in size:
> >>>
> >>> - OS X 10.5 system Perl 5.8.8 = 48K
> >>> - New Perl 5.10.1 = 2628K
> >>> - MacPorts Perl 5.8.9 = 1192K
> >>>
> >>> What accounts for the differences?
> >> 
> >> Wild guess: staticly versus dynamically linked libraries
> >
> >The README.macosx suggests you're right. Any advantages in either of
> these options? I'm also recompiling without -arch i686 as this is a PPC
> Mac G5.
> 
> The same as with any other statically versus dynamically linked program.
> Statically linked programs are much(!) larger, on the HD as well as in
> RAM at runtime. And any update of the library requires at least a
> re-link of the program.
> 
> On the other hand they keep working even if the library or the library
> loader is corrupt or not accessible because they need neither.

I strongly suspect that in this case it's only libperl.a which has been
linked statically, that is, the new perl has been built *without* the
-Duseshrplib option. It's very rare to statically link libc &c. into
perl; in fact, I'm not really sure how I would go about trying. AFAIK
Configure doesn't support it directly, but perhaps adding a '-static' in
some ldopts option would do the trick.

Ben



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

Date: Fri, 9 Oct 2009 02:58:52 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Binary size differences between 5.8 and 5.10
Message-Id: <svh2q6-1i92.ln1@osiris.mauzo.dyndns.org>


Quoth zaphod <abc@def.com>:
> Ben Morrow wrote:
>  
> > Well... what are you trying to achieve? If you are trying to compile a
> > perl suitable for use as your system perl, I would suggest you put the
> > proper binary back where you found it :). You should probably restore
> > the whole of /usr from backup, in fact, since the reinstall will have
> > overwritted a whole lot of other important stuff.
> 
> I wasn't looking to replace the system Perl. I thought 5.10 would sit
> alongside it and could be managed via symlinks.

If some system daemon runs a system-supplied perl program that starts

    #!/usr/bin/perl

and you currently have the symlink pointing to your 5.10, how well do
you think that's going to work? For one thing, I wouldn't be surprised
if Apple ship their perl with some assortment of Apple-specific modules
that your perl won't have installed.

Of course, Apple should really be doing what Sun has done for many
years: on Solaris systems, the system perl is actually installed into
/opt/perl5 (IIRC) and all the system scripts that require exactly that
perl to work refer to it there. This leaves the administrator free to
point /usr/bin/perl somewhere else as convenient.

> I want Perl 5.10 for
> obvious reasons, ie. new features and enhancements. This is a home
> office workstation for web development, not a server. Since most @INC
> directories are version-specific what exactly has been overwritten?
> 
> So, I need to completely restore /usr? How come?

I was exaggerating, a little. At the very least everything in /usr/bin
that ships with the perl core will have been overwritten; on my system,
that's some 40-odd scripts. If your new perl is a different version from
the old then everything else *should* be OK, but I wouldn't like to
count on it.

Ben



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

Date: Fri, 09 Oct 2009 03:30:58 +0100
From: zaphod <abc@def.com>
Subject: Re: Binary size differences between 5.8 and 5.10
Message-Id: <-L-dnQukGLb_PVPXnZ2dnUVZ8oqdnZ2d@brightview.co.uk>

Ben Morrow wrote:
> 
> I was exaggerating, a little. At the very least everything in /usr/bin
> that ships with the perl core will have been overwritten; on my system,
> that's some 40-odd scripts. If your new perl is a different version from
> the old then everything else *should* be OK, but I wouldn't like to
> count on it.
> 
> Ben
> 

So if I kdiff3 <backup>/usr/bin with /usr and swap over what's been altered I should be good to go? If you know of any other directories/files which may have been overwritten please let me know.

It all happened after 23.00 BST so I can do a 

find /usr/bin -mmin 270 -print 

 ... to double check.

zaphod


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

Date: Fri, 09 Oct 2009 03:53:57 +0100
From: zaphod <abc@def.com>
Subject: Re: Binary size differences between 5.8 and 5.10
Message-Id: <6oCdnfAZCpRYOFPXnZ2dnUVZ8hednZ2d@brightview.co.uk>

These were modified/created within the relevant time period:

 ./c2ph
 ./config_data
 ./corelist
 ./cpan
 ./cpan2dist
 ./cpanp
 ./cpanp-run-perl
 ./dprofpp
 ./enc2xs
 ./find2perl
 ./h2ph
 ./h2xs
 ./instmodsh
 ./libnetcfg
 ./piconv
 ./pl2pm
 ./pod2html
 ./pod2latex
 ./pod2man
 ./pod2text
 ./pod2usage
 ./podchecker
 ./podselect
 ./prove
 ./psed
 ./pstruct
 ./ptar
 ./ptardiff
 ./s2p
 ./shasum
 ./splain


Most are new entries in /usr/local/bin so I deleted the new ones. Many of these exist in /usr/bin and seem to be untouched as they are dated 24/Sep/2007. I restored the /usr/local/share/man/man1 and man3 directories from the backup. All should be well now.

zaphod


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

Date: Fri, 09 Oct 2009 10:00:03 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 5.13 How can I output my numbers with commas added?
Message-Id: <DQDzm.32466$lR3.9463@newsfe25.iad>

This is an excerpt from the latest version perlfaq5.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

5.13: How can I output my numbers with commas added?

    (contributed by brian d foy and Benjamin Goldberg)

    You can use Number::Format to separate places in a number. It handles
    locale information for those of you who want to insert full stops
    instead (or anything else that they want to use, really).

    This subroutine will add commas to your number:

            sub commify {
                    local $_  = shift;
                    1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
                    return $_;
                    }

    This regex from Benjamin Goldberg will add commas to numbers:

            s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g;

    It is easier to see with comments:

            s/(
                    ^[-+]?             # beginning of number.
                    \d+?               # first digits before first comma
                    (?=                # followed by, (but not included in the match) :
                            (?>(?:\d{3})+) # some positive multiple of three digits.
                            (?!\d)         # an *exact* multiple, not x * 3 + 1 or whatever.
                    )
                    |                  # or:
                    \G\d{3}            # after the last group, get three digits
                    (?=\d)             # but they have to have more digits after them.
            )/$1,/xg;



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Fri, 09 Oct 2009 16:00:04 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 7.7 Why do Perl operators have different precedence than C operators?
Message-Id: <86Jzm.475363$Ta5.337365@newsfe15.iad>

This is an excerpt from the latest version perlfaq7.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

7.7: Why do Perl operators have different precedence than C operators?

    Actually, they don't. All C operators that Perl copies have the same
    precedence in Perl as they do in C. The problem is with operators that C
    doesn't have, especially functions that give a list context to
    everything on their right, eg. print, chmod, exec, and so on. Such
    functions are called "list operators" and appear as such in the
    precedence table in perlop.

    A common mistake is to write:

            unlink $file || die "snafu";

    This gets interpreted as:

            unlink ($file || die "snafu");

    To avoid this problem, either put in extra parentheses or use the super
    low precedence "or" operator:

            (unlink $file) || die "snafu";
            unlink $file or die "snafu";

    The "English" operators ("and", "or", "xor", and "not") deliberately
    have precedence lower than that of list operators for just such
    situations as the one above.

    Another operator with surprising precedence is exponentiation. It binds
    more tightly even than unary minus, making "-2**2" produce a negative
    not a positive four. It is also right-associating, meaning that
    "2**3**2" is two raised to the ninth power, not eight squared.

    Although it has the same precedence as in C, Perl's "?:" operator
    produces an lvalue. This assigns $x to either $a or $b, depending on the
    trueness of $maybe:

            ($maybe ? $a : $b) = $x;



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Fri, 09 Oct 2009 04:00:05 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 8.24 Why can't I get the output of a command with system()?
Message-Id: <9zyzm.252458$0e4.178196@newsfe19.iad>

This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

8.24: Why can't I get the output of a command with system()?

    You're confusing the purpose of system() and backticks (``). system()
    runs a command and returns exit status information (as a 16 bit value:
    the low 7 bits are the signal the process died from, if any, and the
    high 8 bits are the actual exit value). Backticks (``) run a command and
    return what it sent to STDOUT.

            $exit_status   = system("mail-users");
            $output_string = `ls`;



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Thu, 08 Oct 2009 21:04:41 -0700
From: HASM <netnews@invalid.com>
Subject: Re: How to parse section of html code?
Message-Id: <m3skdtfc12.fsf@127.0.0.1>

Sherm Pendley <spamtrap@shermpendley.com> writes:

>> How can I parse this value from the html code?
> Use an HTML parser module, such as HTML::Parser.

Or HTML::TreeBuilder

-- HASM



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

Date: Fri, 9 Oct 2009 04:11:52 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Loop consuming my list
Message-Id: <9183e47a-d62c-4437-83c3-65cc16a4f1ea@e8g2000yqo.googlegroups.com>

Hello,

I was surprised to see in my own code, a difference between
the two lines (out of context...):

    $self->rmhlink($type, $_) for @pl;
and:
    for my $p (@pl) { $self->rmhlink($type, $p) }

The former consumed the contents of @pl.
The latter did not.

The rmhlink (member) function reads its arguments from @_,
and returns a value, often undef.

I tried to reproduce the case naively, but failed:

$ perl -wle '@s=qw(a b c);sub f{return};f($_)for@s;map{print $_}@s'
a
b
c

Is there thus an interaction from the package?

I cannot get this either...

$ perl -wle 'package Foo;@s=qw(a b c);sub new{$t=shift;$s={};bless $s,
$t}sub foo{return};$f=new Foo;$f->foo($_)for@s;map{print $_}@s'
a
b
c

I am afraid this is a symptom that I missed something fundamental...
Who is eating my list?

Thanks,
Marc


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

Date: Fri, 09 Oct 2009 13:29:59 +0200
From: Peter Makholm <peter@makholm.net>
Subject: Re: Loop consuming my list
Message-Id: <87k4z4kdoo.fsf@vps1.hacking.dk>

Marc Girod <marc.girod@gmail.com> writes:

> Hello,
>
> I was surprised to see in my own code, a difference between
> the two lines (out of context...):
>
>     $self->rmhlink($type, $_) for @pl;
> and:
>     for my $p (@pl) { $self->rmhlink($type, $p) }
>
> The former consumed the contents of @pl.
> The latter did not.

You probably have to defined what you mean by 'consumed the contents
of @pl'. I assume that you mean that the content of @pl has changed
somehow. The problme is that the first construction makes $_ an alias
to the elements in @pl and that $_ is a global variable.

In perl 5.10 you can make $_ a lexical variable by adding a 'my $_;'
somewhere in scope befor the loop:

  my $_;
  $self->rmhlink($type, $_) for @pl;

For older perls you have to localize $_ in your rmhlink method. I
would probably do both.

See also:
http://peter.makholm.net/2009/06/24/the-evil-of-a-global-_/

//Makholm


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

Date: Fri, 9 Oct 2009 05:38:05 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: Loop consuming my list
Message-Id: <2b009a33-5607-409f-829c-998c2ea47e78@h13g2000yqk.googlegroups.com>

Thank you Peter,

On Oct 9, 12:29=A0pm, Peter Makholm <pe...@makholm.net> wrote:

> You probably have to defined what you mean by 'consumed the contents
> of @pl'.

Indeed. In this case, the list was empty after running the loop.

> The problem is that the first construction makes $_ an alias
> to the elements in @pl and that $_ is a global variable.

That's what I didn't understand.
I thought it was lexical...

> In perl 5.10 you can make $_ a lexical variable by adding a 'my $_;'
> somewhere in scope befor the loop:

Thanks. I can now see that it is what I did, without the
side-effect of the name.

> See also:http://peter.makholm.net/2009/06/24/the-evil-of-a-global-_/

Excellent.
I *did* miss something important.

Marc


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

Date: Fri, 09 Oct 2009 14:50:26 +0200
From: Frank Seitz <devnull4711@web.de>
Subject: Re: Loop consuming my list
Message-Id: <7j8pr8F33mu7lU1@mid.individual.net>

Marc Girod wrote:
> On Oct 9, 12:29 pm, Peter Makholm <pe...@makholm.net> wrote:
> 
>> You probably have to defined what you mean by 'consumed the contents
>> of @pl'.
> 
> Indeed. In this case, the list was empty after running the loop.

It is not possible to change array size by manipulating $_.
The array size must be the same.

Frank
-- 
Dipl.-Inform. Frank Seitz
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel

Homepage:    http://www.fseitz.de/
XING-Profil: http://www.xing.com/profile/Frank_Seitz2


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

Date: Fri, 9 Oct 2009 06:32:06 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: Loop consuming my list
Message-Id: <bb0d7c4b-3d6f-496a-be5f-c550fdcd9077@k17g2000yqb.googlegroups.com>

On Oct 9, 1:50=A0pm, Frank Seitz <devnull4...@web.de> wrote:

> It is not possible to change array size by manipulating $_.

Sorry, you are correct. The items were set to ''.
I tried the advice on 5.8.8, and checked that I cannot
make $_ lexical there, but that local $_ within rmhlink
works.

I believe that I'll be happy with the insight, and with
lexicalizing by naming as I did.

Thanks,
Marc


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

Date: Fri, 9 Oct 2009 02:11:45 +0000 (UTC)
From: QoS@invalid.net
Subject: Re: Perl Tk Grid
Message-Id: <ham650$1llp$1@adenine.netfront.net>


f1crazed <f1crazed@gmail.com> wrote in message-id:  <8a5c2291-8a4d-46cb-af79-0ee7f7492e21@2g2000prl.googlegroups.com>

> 
> Hello,
> 
> I am new to using tk and perl. What I am trying to do below is just
> get the label and text boxes to line up on the left side and top of
> the mainwindow.  It seems that there is some kind of padding on the
> left side and top of the window that won't allow me to put widgets all
> the way on the left and top of the window.
> 
> Here is the code:
> 
> #!/usr/bin/perl -w
> use Tk;
> use strict;
> 
> my $mw = new MainWindow(); # Main Window
> $mw->geometry("400x200+500+400");
> $mw->title("Learning Grid");
> 
> $mw -> Label(-text=> "hello") -> grid(-row=>0, -column=>0, -sticky =>
> 'w', );
> my $txt = $mw-> Text(-width=>20, -height=>1)-> grid(-row=>2, -
> column=>0, -sticky => 'w') ;
> my $txt2 = $mw-> Text(-width=>20, -height=>1)-> grid(-row=>3, -
> column=>0, -sticky => 'w');
> 
> MainLoop;
> 
> Thanks for any help!
> -JD

You need to define 'weight' for your rows and columns.
See the gridRowconfigure and gridColumnconfigure statements below.

Also, it is a good idea to put your widgets into a frame rather
than directly into the MainWindow.

#!/usr/bin/perl -w
use Tk;
use strict;

my $mw = new MainWindow(); # Main Window
$mw->geometry("400x200+500+400");
$mw->title("Learning Grid");
$mw->gridRowconfigure(4, -weight => 1,);
$mw->gridColumnconfigure(1, -weight => 1,);

$mw -> Label(-text=> "hello") -> grid(-row=>0, -column=>0, -sticky =>
'w', );
my $txt = $mw-> Text(-width=>20, -height=>1)-> grid(-row=>2, -
column=>0, -sticky => 'w') ;
my $txt2 = $mw-> Text(-width=>20, -height=>1)-> grid(-row=>3, -
column=>0, -sticky => 'w');

MainLoop;





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

Date: Fri, 9 Oct 2009 09:33:00 -0700 (PDT)
From: f1crazed <f1crazed@gmail.com>
Subject: Re: Perl Tk Grid
Message-Id: <3a120d9f-93eb-4978-a161-e24a015f34c5@g1g2000pra.googlegroups.com>

On Oct 8, 7:11=A0pm, Q...@invalid.net wrote:
> f1crazed <f1cra...@gmail.com> wrote in message-id: =A0<8a5c2291-8a4d-46cb=
-af79-0ee7f7492...@2g2000prl.googlegroups.com>
>
> > Hello,
>
> > I am new to using tk and perl. What I am trying to do below is just
> > get the label and text boxes to line up on the left side and top of
> > the mainwindow. =A0It seems that there is some kind of padding on the
> > left side and top of the window that won't allow me to put widgets all
> > the way on the left and top of the window.
>
> > Here is the code:
>
> > #!/usr/bin/perl -w
> > use Tk;
> > use strict;
>
> > my $mw =3D new MainWindow(); # Main Window
> > $mw->geometry("400x200+500+400");
> > $mw->title("Learning Grid");
>
> > $mw -> Label(-text=3D> "hello") -> grid(-row=3D>0, -column=3D>0, -stick=
y =3D>
> > 'w', );
> > my $txt =3D $mw-> Text(-width=3D>20, -height=3D>1)-> grid(-row=3D>2, -
> > column=3D>0, -sticky =3D> 'w') ;
> > my $txt2 =3D $mw-> Text(-width=3D>20, -height=3D>1)-> grid(-row=3D>3, -
> > column=3D>0, -sticky =3D> 'w');
>
> > MainLoop;
>
> > Thanks for any help!
> > -JD
>
> You need to define 'weight' for your rows and columns.
> See the gridRowconfigure and gridColumnconfigure statements below.
>
> Also, it is a good idea to put your widgets into a frame rather
> than directly into the MainWindow.
>
> #!/usr/bin/perl -w
> use Tk;
> use strict;
>
> my $mw =3D new MainWindow(); # Main Window
> $mw->geometry("400x200+500+400");
> $mw->title("Learning Grid");
> $mw->gridRowconfigure(4, -weight =3D> 1,);
> $mw->gridColumnconfigure(1, -weight =3D> 1,);
>
> $mw -> Label(-text=3D> "hello") -> grid(-row=3D>0, -column=3D>0, -sticky =
=3D>
> 'w', );
> my $txt =3D $mw-> Text(-width=3D>20, -height=3D>1)-> grid(-row=3D>2, -
> column=3D>0, -sticky =3D> 'w') ;
> my $txt2 =3D $mw-> Text(-width=3D>20, -height=3D>1)-> grid(-row=3D>3, -
> column=3D>0, -sticky =3D> 'w');
>
> MainLoop;

Thanks q!  That did the trick.


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

Date: Fri, 9 Oct 2009 09:37:05 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Simple question about CGI response after form data has been  processed.
Message-Id: <7c96325e-85ec-4af9-891c-09925d1f289c@33g2000vbe.googlegroups.com>

I have searched through my books, the FAQs I could find, the CGI
documentation, and have not found the answer, probably just an
oversight in the documentation I have examined.

For the most part, I have found it extremely easy to use the CGI
packages.

My frustration is that, while it is trivially easy to get form
parameters in my CGI scripts, I have not found how to either forward
or redirect the user to the HTML form he had just used to submit the
data my script had just processed.  The script is just to move the
data into a DB, send an error page if there is a problem, and
otherwise return the user to the form ready to enter more data.  The
form itself is static, and so exists as a simple HTML file in htdocs
(I'm using Apache's httpd).

I found something about just printing "Location: some_uri", but unless
the sources I read are mistaken, that needs a full path, and, as the
code will be moved from my development machine to a final home, I can
only know the relative path.

I know I could have the contents of the HTML file in the cgi file too,
but that carries its own problems WRT maintenance, and having the
script read the file and then print it carries performance issues.

What is the best option here?

Thanks

Ted


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

Date: Fri, 09 Oct 2009 13:30:29 -0400
From: Steve C <smallpond@juno.com>
Subject: Re: Simple question about CGI response after form data has been  processed.
Message-Id: <hans03$cdc$1@news.eternal-september.org>

Ted Byers wrote:
> I have searched through my books, the FAQs I could find, the CGI
> documentation, and have not found the answer, probably just an
> oversight in the documentation I have examined.
> 
> For the most part, I have found it extremely easy to use the CGI
> packages.
> 
> My frustration is that, while it is trivially easy to get form
> parameters in my CGI scripts, I have not found how to either forward
> or redirect the user to the HTML form he had just used to submit the
> data my script had just processed.  The script is just to move the
> data into a DB, send an error page if there is a problem, and
> otherwise return the user to the form ready to enter more data.  The
> form itself is static, and so exists as a simple HTML file in htdocs
> (I'm using Apache's httpd).
> 
> I found something about just printing "Location: some_uri", but unless
> the sources I read are mistaken, that needs a full path, and, as the
> code will be moved from my development machine to a final home, I can
> only know the relative path.
> 
> I know I could have the contents of the HTML file in the cgi file too,
> but that carries its own problems WRT maintenance, and having the
> script read the file and then print it carries performance issues.
> 
> What is the best option here?
> 
> Thanks
> 
> Ted


The page that invoked your script is the referer.  However, you can't
trust any information in a request, so you need to consider
the case where the caller lies to you.  If you are just sending back
a redirect to that page, then you probably don't care.

If you generate a document with just a redirect header, then it suggests
to the browser that it go fetch that page, which it will do if it
feels cooperative.

Both are described in
perldoc CGI


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

Date: Fri, 09 Oct 2009 09:12:50 +0200
From: Josef Moellers <josef.moellers@ts.fujitsu.com>
Subject: Re: time format +1 hour
Message-Id: <hamnpi$nvf$1@nntp.fujitsu-siemens.com>

Slickuser wrote:
> I have this value:
> 20091008155222
> YYYY_MM_DD_HH_MM_SS
> 
> Is there any module out there if I add 1 hour to my current timestamp,
> it will also roll over to DD, MM, and year if possible.
> This might happen at 23 hours (0-23), 0-6 days, 0-12 months..

Have a look at Date::Calc.
There's a sub called "Add_Delta_DHMS" that will do what you need.

Josef
-- 
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html


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

Date: Fri, 09 Oct 2009 09:13:48 +0200
From: Josef Moellers <josef.moellers@ts.fujitsu.com>
Subject: Re: time format +1 hour
Message-Id: <hamnrc$nvf$2@nntp.fujitsu-siemens.com>

Jürgen Exner wrote:
> Slickuser <slick.users@gmail.com> wrote:
>> I have this value:
>> 20091008155222
>> YYYY_MM_DD_HH_MM_SS
>>
>> Is there any module out there if I add 1 hour to my current timestamp,
>> it will also roll over to DD, MM, and year if possible.
>> This might happen at 23 hours (0-23), 0-6 days, 0-12 months..
>>
>>    my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
>> localtime(time);
> 
> What's wrong with a simple 
> 
> 	my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)
> = localtime(time + 3600);

It will work in 99.99999% of all cases until you fall over one of these 
years where they add/subtract a leap second ;-)

Better use Date::Calc.

Josef
-- 
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html


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

Date: Fri, 9 Oct 2009 09:18:35 -0700 (PDT)
From: Slickuser <slick.users@gmail.com>
Subject: Re: time format +1 hour
Message-Id: <06bac854-2b51-4ce3-84ed-26de8ac4cef3@s21g2000prm.googlegroups.com>

Forgot to mention that original time is fixed and get modify to a new
one (not local time).

An example below.

	my $time_org =3D "20091009090832";
	my $time_mod =3D "20091009100832";


On Oct 9, 12:13=A0am, Josef Moellers <josef.moell...@ts.fujitsu.com>
wrote:
> J=FCrgen Exner wrote:
> > Slickuser <slick.us...@gmail.com> wrote:
> >> I have this value:
> >> 20091008155222
> >> YYYY_MM_DD_HH_MM_SS
>
> >> Is there any module out there if I add 1 hour to my current timestamp,
> >> it will also roll over to DD, MM, and year if possible.
> >> This might happen at 23 hours (0-23), 0-6 days, 0-12 months..
>
> >> =A0 =A0my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst=
) =3D
> >> localtime(time);
>
> > What's wrong with a simple
>
> > =A0 =A0my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)
> > =3D localtime(time + 3600);
>
> It will work in 99.99999% of all cases until you fall over one of these
> years where they add/subtract a leap second ;-)
>
> Better use Date::Calc.
>
> Josef
> --
> These are my personal views and not those of Fujitsu Technology Solutions=
!
> Josef M=F6llers (Pinguinpfleger bei FTS)
> =A0 =A0 =A0 =A0 If failure had no penalty success would not be a prize (T=
 . =A0Pratchett)
> Company Details:http://de.ts.fujitsu.com/imprint.html



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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 2628
***************************************


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