[26042] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8250 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 14 11:05:41 2005

Date: Thu, 14 Jul 2005 08:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 14 Jul 2005     Volume: 10 Number: 8250

Today's topics:
    Re: *{$AUTOLOAD} vs *$AUTOLOAD <tassilo.von.parseval@rwth-aachen.de>
    Re: Are there any other GUI toolkits for perl than perl <zentara@highstream.net>
    Re: Checking If A Function Exists <tadmc@augustmail.com>
        filter input <""alexjaquet\"@[no spam]msn.com">
    Re: Problem regarding socket <vikrantREMOVE@DELETEsaysnetsoftDDDD.com>
    Re: Read stdout into perl <bart.lateur@pandora.be>
        Replacing Regex with part of itself <hal@thresholddigital.com>
    Re: Replacing Regex with part of itself (Anno Siegel)
        stat/mtime on Windows changes with daylight saving <obetz@despammed.com>
    Re: using passwd in a perl script <vek@station02.ohout.pharmapartners.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 14 Jul 2005 08:09:18 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: *{$AUTOLOAD} vs *$AUTOLOAD
Message-Id: <slrnddc0ce.sh.tassilo.von.parseval@localhost.localdomain>

Also sprach J Krugman:

> I frequently see statements like
>
>   *{$AUTOLOAD} = \&foobar;  # under no strict 'refs'
>
> but I don't understand the need for curly brackets in the LHS
> expression.  Why not simply
>
>   *$AUTOLOAD = \&foobar;
>
> ?

These two statements are equivalent. Note however that the canonical
syntax for a dereference operation is this:

    SIGIL := '$' | '%' | '@' | '*'
    DEREF := SIGIL '{' EXPRESSION '}'

The curlies can be omitted iff EXPRESSION is a simple scalar which is
the case in your example. If EXPRESSION is a not a scalar variable the
curlies are required. 

It's then up to an author's personal preference whether to use the
shortcut or not.

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);


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

Date: Thu, 14 Jul 2005 09:22:34 -0400
From: zentara <zentara@highstream.net>
Subject: Re: Are there any other GUI toolkits for perl than perl/Tk?
Message-Id: <hqocd1hcnvrcc11adlscj0lsmsv81cd1kc@4ax.com>

On Wed, 13 Jul 2005 16:13:05 +0200, ngoc <ngoc@yahoo.com> wrote:

>The reason I say perl/Tk have limitations are.
>I now maintain a package of software of nearly 100 apps that use Listbox 
>to display tabular data. It is ugly. I want to make better. Looking 
>around www.perltk.org, I see Columns, but it is not good in resizing of 
>column. Asking perlTk forum and web search, I learn about MListbox, 
>TableMatrix and TixGrid. Only MListbox is considered as good one for me. 
>It has 2 things I dislike. It does not resize after longest string .And 
>height and width is height and width of column(listbox), not pane. So 
>when data is not filled in MListbox, the size of widget is not as 
>defined. But this problem is fixed, I use 3 days to modify the original 
>MListbox.
>TableMatrix and TixGrid is a long history with bugs by installation, etc..
>That is why I say perl/Tk have limitations and looking for new package 
>of GUI.

Gtk2-perl has alot of discussion of it's Gtk2::SimpleList  on it's
maillist at 
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Search the archives, and see if the code is easier to use than your 
current Tk scripts.

When I need lists in Tk, I use Tk::HList.   It is very good, but more
complicated..... for instance you have to do your sorting manually,
and repopulate the list yourself.  I know that it will resize it's
column's width automatically.

If you want proof, check out
http://perlmonks.org?node_id=327499

Run the program, and change an entry's name to some long string.
The HList is in the left frame, and watch the 'id' column width
automatically expand to the string width.



-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

Date: Wed, 13 Jul 2005 23:13:44 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Checking If A Function Exists
Message-Id: <slrnddbpjo.2ha.tadmc@magna.augustmail.com>

Hal Vaughan <hal@thresholddigital.com> wrote:


> since in any instance of
> the program, I only use a few different filters,


   perldoc AutoLoader

       AutoLoader - load subroutines only on demand


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


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

Date: Thu, 14 Jul 2005 15:12:58 +0200
From: Alexandre Jaquet <""alexjaquet\"@[no spam]msn.com">
Subject: filter input
Message-Id: <42d664e0$0$1152$5402220f@news.sunrise.ch>

Hi,

I currently use :


my $index_start = $query->param ("min_index") ;
$index_start =~ /^([\w.])$/;

to filter any not alphanumeric char but when I got char like / it is

didn't deleted any idea ?

thanks


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

Date: Thu, 14 Jul 2005 15:38:56 +0530
From: Vikrant <vikrantREMOVE@DELETEsaysnetsoftDDDD.com>
Subject: Re: Problem regarding socket
Message-Id: <db5dm7$jml$1@domitilla.aioe.org>

hi

thanks for the information.i use the following code to solve the problem


######################################################
#!/usr/bin/perl -w

use IO::Socket::INET;
use IO::Select;
		
$socket = new IO::Socket::INET (LocalPort =>36545,
				Proto => "tcp",
				Listen => 4,
				Type => SOCK_STREAM)
		              or die &WriteLog("Error creating socket");

$obSelected_Socket = IO::Select->new($socket);

while( $obSelected_Socket->can_read(20)) #Waiting for 20 seconds
{
	sysread($socket,$sBuffer,1<<10);
	$sData_Recevied.=$sBuffer;
}


##########################################################

vikrant


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

Date: Thu, 14 Jul 2005 13:21:49 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Read stdout into perl
Message-Id: <dhpcd1dts9s4tutnebn4i5ba6p06hf7h7s@4ax.com>

Sean Berry wrote:

>I have the following...
>
>open (DATA, "|/usr/bin/gunzip -c $filename");
>while(<DATA>) {
>    ...
>}
>
>But this does not work.
>
>How do I read stdout into PERL?

By putting the "|" at the end of the line.

	open (DATA, "/usr/bin/gunzip -c $filename |");

If you want bidirectional piping, thus, both piping to and from your
app, check out IPC::Open2 (and IPC::Open3), both standard modules.

	<http://perldoc.perl.org/IPC/Open2.html>
	<http://perldoc.perl.org/IPC/Open3.html>


-- 
	Bart.


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

Date: Thu, 14 Jul 2005 03:30:43 -0400
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Replacing Regex with part of itself
Message-Id: <VvKdnfundqc5iUvfRVn-gw@comcast.com>

I know there's a way to do this, and I know it involves special uses of a
regex, but I can't remember the terms that apply, so I'm having trouble
searching for it.  I want to take a line in a malformed HTML page like:

<OPTION Value = '1' >Book_Title_1
<OPTION Value = '2' >Book_Title_2

so it'll look like:

<OPTION Value = '1' >Book_Title_1</OPTION>
<OPTION Value = '2' >Book_Title_2</OPTION>

I know I can find the pattern by looking for something like:

$htmlpage =~ /<OPTION.*?>.*?$/

I THINK I remember that I can capture the wildcard part of the regex like:

$htmlpage =~ /<OPTION(.*?)>(.*?)$/

But when I try a substitution:

$htmlpage =~ s/<OPTION(.*?)>(.*?)$/<OPTION.*?>.*?</OPTION>$/g;

how do I get the selected sections from the search part to be included in
the replace part?

Thanks for any help on this.  I'm not even sure what the name is for the
type of search/replace I'm trying to do is!

Hal


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

Date: 14 Jul 2005 08:55:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Replacing Regex with part of itself
Message-Id: <db59al$t7d$1@mamenchi.zrz.TU-Berlin.DE>

Hal Vaughan  <hal@thresholddigital.com> wrote in comp.lang.perl.misc:
> I know there's a way to do this, and I know it involves special uses of a
> regex, but I can't remember the terms that apply, so I'm having trouble
> searching for it.  I want to take a line in a malformed HTML page like:

"Capture" is the word you're looking for.

> 
> <OPTION Value = '1' >Book_Title_1
> <OPTION Value = '2' >Book_Title_2
> 
> so it'll look like:
> 
> <OPTION Value = '1' >Book_Title_1</OPTION>
> <OPTION Value = '2' >Book_Title_2</OPTION>
> 
> I know I can find the pattern by looking for something like:
> 
> $htmlpage =~ /<OPTION.*?>.*?$/
> 
> I THINK I remember that I can capture the wildcard part of the regex like:
> 
> $htmlpage =~ /<OPTION(.*?)>(.*?)$/

The () are capturing parentheses.  The "?" after each ".*" make the
match non-greedy.  Why do you think you need that?  The final "$" is
also unnecessary.

> But when I try a substitution:
> 
> $htmlpage =~ s/<OPTION(.*?)>(.*?)$/<OPTION.*?>.*?</OPTION>$/g;
                                                    ^
"/" is your delimiter.  You must quote it or use an alternative delimiter.

> how do I get the selected sections from the search part to be included in
> the replace part?

Use $1, $2, etc.  This is explained in "perldoc perlre".

    s{<OPTION(.*?)>(.*)} {<OPTION$1>$2</OPTION>};

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Thu, 14 Jul 2005 11:40:58 +0200
From: Oliver Betz <obetz@despammed.com>
Subject: stat/mtime on Windows changes with daylight saving
Message-Id: <l6bcd11920n1elo1acndbveoev0ipggg1l@z1.oliverbetz.de>

Hi,

is this a Windows or ActivePerl (I'm using 5.8.2) bug?

(stat())->mtime reports 3600 more or less if the file is in the other
daylight savings state than the system time.

For example, the stat->mtime results if Windows is in timezone UTC
without daylight savings (Casablanca...):

1970-01-01 10:00:00Z ->    36000 (as expected)
1970-07-01 10:00:00Z -> 15674400 (as expected)

In a Timezone with daylight savings, system date in winter, I get
36000 and 15670800 (one hour less) for the same files.

In a Timezone with daylight savings, system date in summer, I get
39600 (one hour more) and 15674400 for the same files.

All tests done on NTFS drives. No difference whether it's a local file
or via network. Same results with newer dates, but I liked the smaller
mtime numbers for the demonstration.

Who tweaks the file time, Perl or Windows?

mtime should be constant, shouldn't it?

Oliver
-- 
Oliver Betz, Munich


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

Date: 14 Jul 2005 07:42:42 GMT
From: Villy Kruse <vek@station02.ohout.pharmapartners.nl>
Subject: Re: using passwd in a perl script
Message-Id: <slrnddc5ri.2t7.vek@station02.ohout.pharmapartners.nl>

On Wed, 13 Jul 2005 12:27:50 -0400,
    yo <> wrote:


> I have the following perl script which works fine.
>
> #!/usr/bin/perl
>
> open(INFILE, "@ARGV[0]");
>         $infile = <INFILE>;
>         ($username,$password) = split(/\|/, $infile);
> close(INFILE);
>
> @calladduser = ("/usr/sbin/adduser $username -g 503 -d
> /home/mailusers/$username
>  -s /sbin/nologin -p $password","\n");
> system("@calladduser");
>
>
> my problem is im using shadow passwords and adduser -p doesn't use
> crypt on the password.
>

That is why you should use the standard perl crypt function to create the 
value for the -p argument.

Villy


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

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


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