[28962] in Perl-Users-Digest
Perl-Users Digest, Issue: 206 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 8 16:10:19 2007
Date: Thu, 8 Mar 2007 13:09:09 -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, 8 Mar 2007 Volume: 11 Number: 206
Today's topics:
Re: Create zombie intentionally? xhoster@gmail.com
Re: Create zombie intentionally? <ddunham@redwood.taos.com>
Re: Create zombie intentionally? <bart.lateur@pandora.be>
Entry Widget - Perl/Tk <doni.sekar@gmail.com>
Re: Entry Widget - Perl/Tk <mmundy1@gmail.com>
Re: Entry Widget - Perl/Tk <bik.mido@tiscalinet.it>
equivalence of variables question <junk@yahoo.com>
Re: equivalence of variables question <spamtrap@dot-app.org>
Re: equivalence of variables question <wahab-mail@gmx.de>
Re: equivalence of variables question <junk@yahoo.com>
Re: How can I access the variables in my script ($main: <greg.ferguson@icrossing.com>
Re: How can I access the variables in my script ($main: <edMbj@aes-intl.com>
Re: IPC::Open2 - Bad File Descriptor anno4000@radom.zrz.tu-berlin.de
Re: Killing threads in perl <zentara@highstream.net>
Posting guidelines work <1usa@llenroc.ude.invalid>
Re: Problem with pattern match <jurgenex@hotmail.com>
Re: Problem with pattern match <bik.mido@tiscalinet.it>
Re: Problem with pattern match <paduille.4060.mumia.w+nospam@earthlink.net>
Re: Splitting a filename <bik.mido@tiscalinet.it>
Re: Splitting a filename anno4000@radom.zrz.tu-berlin.de
Re: Splitting a filename <bik.mido@tiscalinet.it>
Re: Splitting a filename <bik.mido@tiscalinet.it>
Re: view images inside the windows xp shell <bik.mido@tiscalinet.it>
Re: view images inside the windows xp shell <brian.helterline@hp.com>
Re: What is abriviation for CHR(4) xhoster@gmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 08 Mar 2007 17:09:34 GMT
From: xhoster@gmail.com
Subject: Re: Create zombie intentionally?
Message-Id: <20070308121620.268$40@newsreader.com>
"Ishmael" <stahl.karl@gmail.com> wrote:
> Ok, this may sound odd, but I would like to create a zombie process
> intentionally. I've been reading the perldoc for perlipc and it seems
> like an unhappy marriage between 'alarm' and 'system' should do the
> trick, but I haven't been able to get it to work. Can someone give me
> a simple (!) example of how to create a zombie (using the alarm/
> system combo - or even better, using fork and exec)? Thanks for you
> help!
fork or exit; # no error checking done.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Thu, 08 Mar 2007 18:37:06 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Create zombie intentionally?
Message-Id: <mJYHh.5751$M65.3730@newssvr21.news.prodigy.net>
Ishmael <stahl.karl@gmail.com> wrote:
> Ok, this may sound odd, but I would like to create a zombie process
> intentionally. I've been reading the perldoc for perlipc and it seems
> like an unhappy marriage between 'alarm' and 'system' should do the
> trick, but I haven't been able to get it to work. Can someone give me
> a simple (!) example of how to create a zombie (using the alarm/
> system combo - or even better, using fork and exec)? Thanks for you
> help!
It seems to me like you're overthinking it. Do you understand what a
zombie is?
A zombie is a child that has exited, but the parent has not called
wait() for it.
So you simply need to fork a child, have the child exit, and have the
parent continue to live.
As soon as the parent exits or calls wait(), the child should be reaped.
> By the way, here's what I've been trying (unsuccessfully):
> eval {
> local $SIG{ALRM} = sub {die "system call killed by alarm"};
> alarm 1;
> my $cmd = 'perl -e \'while(1) { print "bla\n"; sleep(1); }\'';
> # my $cmd = "/bin/tcsh\nwhile 1\necho \"bla\\n\"\nend\n";
> print $cmd, "\n";
> system($cmd);
> alarm 0;
> };
system() will always wait for the child process to exit, so it will
never create a (long-term) zombie. You have to call fork() yourself for
that to happen.
--
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: Thu, 08 Mar 2007 19:33:09 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Create zombie intentionally?
Message-Id: <u4p0v2pome0bu2d3eppevl1m8e8tbcs7km@4ax.com>
xhoster@gmail.com wrote:
>fork or exit; # no error checking done.
Nah, both parent and child will immediately exit.
The idea of a zombie is that the child process quits, the parent goes
on, and doesn't "wait". So, I'd try this:
sleep 10 if fork;
--
Bart.
------------------------------
Date: 8 Mar 2007 10:41:32 -0800
From: "doni" <doni.sekar@gmail.com>
Subject: Entry Widget - Perl/Tk
Message-Id: <1173379291.892290.289910@s48g2000cws.googlegroups.com>
Hi,
I am trying to do some error checking on my Entry Widget in this Perl/
Tk test program. I would like to check if the user has entered some
text under Filename before he starts pressing the "Load" button. Will
"validate command" option under Entry Widget work for this. Can anyone
point me how should I go about this.
Here is the source code.
#!/usr/bin/perl
use Tk;
$mw = MainWindow->new;
$mw->configure(-title=>'Test',
-background=>'blue',
-width=>"700",
-height=>"500");
$info = "Start Loading Filename...";
# Create necessary widgets
$f = $mw->Frame->pack(-side => 'top',
-fill => 'x');
$f->Label(-text => "Filename:")->pack(-side => 'left',
-anchor =>
'center');
$f->Entry(-textvariable => \$filename)->pack(-side => 'left',
-
anchor => 'w',
-fill
=> 'x',
-
expand => 1);
$f->Button(-text => "Exit",
-activebackground => "red",
-underline => 1,
-command => sub {exit;})->pack(-side => 'right');
$f->Button(-text=>"Clear",
-command=> sub {$t->delete("0.0",'end')})->pack(-
side=>'right',
-anchor=>'s');
$f->Button(-text => "Save",
-command => \&save_file)->pack(-side => 'right',
-
anchor => 'e');
$f->Button(-text => "Load",
-command => \&load_file)->pack(-side => 'right',
-
anchor => 'e');
$mw->Label(-textvariable => \$info,
-relief => 'ridge')->pack(-side => 'bottom',
-fill => 'x');
$t = $mw->Scrolled("Text")->pack(-side => 'bottom',
-fill => 'both',
-expand => 1);
MainLoop;
# load_file checks to see what the filename is and loads it if
possible
sub load_file {
$info = "Loading file '$filename'...";
$t->delete("1.0", "end");
if (!open(FH, "/$filename")) {
$t->insert("end", "ERROR: Could not open $filename\n");
return;
}
while (<FH>) { $t->insert("end", $_); }
close (FH);
$info = "File '$filename' loaded";
}
# save_file saves the file using the filename in the Entry box.
sub save_file {
$info = "Saving '$filename'";
open (FH, ">$filename");
print FH $t->get("1.0", "end");
$info = "Saved.";
}
Thanks,
doni
------------------------------
Date: 8 Mar 2007 12:53:03 -0800
From: "Matthew Mundy" <mmundy1@gmail.com>
Subject: Re: Entry Widget - Perl/Tk
Message-Id: <1173387182.970536.54160@j27g2000cwj.googlegroups.com>
I do not know if validate would work. My solution was to have the
button disabled until the "<<Modified>>" virtual event, then change
its state to active.
Hope that helps. There might be a better way. I am at best an
experienced novice.
On Mar 8, 1:41 pm, "doni" <doni.se...@gmail.com> wrote:
> Hi,
>
> I am trying to do some error checking on my Entry Widget in this Perl/
> Tk test program. I would like to check if the user has entered some
> text under Filename before he starts pressing the "Load" button. Will
> "validate command" option under Entry Widget work for this. Can anyone
> point me how should I go about this.
>
> Here is the source code.
> #!/usr/bin/perl
>
> use Tk;
>
> $mw = MainWindow->new;
> $mw->configure(-title=>'Test',
> -background=>'blue',
> -width=>"700",
> -height=>"500");
>
> $info = "Start Loading Filename...";
>
> # Create necessary widgets
> $f = $mw->Frame->pack(-side => 'top',
> -fill => 'x');
> $f->Label(-text => "Filename:")->pack(-side => 'left',
> -anchor =>
> 'center');
> $f->Entry(-textvariable => \$filename)->pack(-side => 'left',
> -
> anchor => 'w',
> -fill
> => 'x',
> -
> expand => 1);
> $f->Button(-text => "Exit",
> -activebackground => "red",
> -underline => 1,
> -command => sub {exit;})->pack(-side => 'right');
> $f->Button(-text=>"Clear",
> -command=> sub {$t->delete("0.0",'end')})->pack(-
> side=>'right',
>
> -anchor=>'s');
> $f->Button(-text => "Save",
> -command => \&save_file)->pack(-side => 'right',
> -
> anchor => 'e');
> $f->Button(-text => "Load",
> -command => \&load_file)->pack(-side => 'right',
> -
> anchor => 'e');
> $mw->Label(-textvariable => \$info,
> -relief => 'ridge')->pack(-side => 'bottom',
> -fill => 'x');
> $t = $mw->Scrolled("Text")->pack(-side => 'bottom',
> -fill => 'both',
> -expand => 1);
> MainLoop;
>
> # load_file checks to see what the filename is and loads it if
> possible
> sub load_file {
> $info = "Loading file '$filename'...";
> $t->delete("1.0", "end");
> if (!open(FH, "/$filename")) {
> $t->insert("end", "ERROR: Could not open $filename\n");
> return;
> }
> while (<FH>) { $t->insert("end", $_); }
> close (FH);
> $info = "File '$filename' loaded";
>
> }
>
> # save_file saves the file using the filename in the Entry box.
> sub save_file {
> $info = "Saving '$filename'";
> open (FH, ">$filename");
> print FH $t->get("1.0", "end");
> $info = "Saved.";
>
> }
>
> Thanks,
> doni
------------------------------
Date: Thu, 08 Mar 2007 21:55:11 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Entry Widget - Perl/Tk
Message-Id: <sut0v296p2s5ddplbv6pcad03ra13h694m@4ax.com>
On 8 Mar 2007 10:41:32 -0800, "doni" <doni.sekar@gmail.com> wrote:
>I am trying to do some error checking on my Entry Widget in this Perl/
>Tk test program. I would like to check if the user has entered some
Well, here there may well be people able to help you on Tk, but as I
wrote in my other post to you (well, maybe you didn't receive it) you
may want to check comp.lang.perl.tk!
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: Thu, 08 Mar 2007 14:04:47 -0500
From: nun <junk@yahoo.com>
Subject: equivalence of variables question
Message-Id: <zoednUgBoarSw23YnZ2dnUVZ_tWhnZ2d@megapath.net>
I have the following hunk of perl:
###############################
# load image names into array
my $image_names_file="image_list.txt";
open(DAT, $image_names_file) || die("Could not open file!");
my @image_names=<DAT>;
close(DAT);
for my $this_image_name (@image_names) {
my $AA = $SKU;
my $BB = $this_image_name;
if($AA eq $BB){
print "YAY! AA,BB is $AA,$BB";
}
else {
print "BOO! AA,BB is $AA,$BB";
}
}
#################################################
The $SKU variable is defined elsewhere in the script. The script runs,
but the if($AA eq $BB) seems never to be true.... the relevant line out
output is puzzling to me:
BOO! AA,BB is EL-0001468271,EL-0001468271
They sure look equal to me. Can anyone tell me what I'm not
comprehending here ?
DB
------------------------------
Date: Thu, 08 Mar 2007 14:12:08 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: equivalence of variables question
Message-Id: <m2wt1ro8hj.fsf@local.wv-www.com>
nun <junk@yahoo.com> writes:
> I have the following hunk of perl:
>
> ###############################
> # load image names into array
> my $image_names_file="image_list.txt";
> open(DAT, $image_names_file) || die("Could not open file!");
> my @image_names=<DAT>;
> close(DAT);
>
> for my $this_image_name (@image_names) {
> my $AA = $SKU;
> my $BB = $this_image_name;
>
> if($AA eq $BB){
> print "YAY! AA,BB is $AA,$BB";
> }
> else {
> print "BOO! AA,BB is $AA,$BB";
Change this to:
print "BOO! AA,BB is '$AA', '$BB'";
> }
>
> }
> #################################################
>
> The $SKU variable is defined elsewhere in the script. The script runs,
> but the if($AA eq $BB) seems never to be true.... the relevant line out
> output is puzzling to me:
>
> BOO! AA,BB is EL-0001468271,EL-0001468271
>
> They sure look equal to me. Can anyone tell me what I'm not
> comprehending here ?
The lines in @image_names each have a newline at the end, but $SKU does not.
Adding the quotes around the output will make that more apparent. Although,
it's made somewhat obvious already, by the fact that you didn't need to add
a "\n" to your print.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Thu, 08 Mar 2007 20:13:24 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: equivalence of variables question
Message-Id: <espnk0$gsg$1@mlucom4.urz.uni-halle.de>
nun wrote:
> ...
> for my $this_image_name (@image_names) {
> my $AA = $SKU;
> my $BB = $this_image_name;
>
> if($AA eq $BB){
> print "YAY! AA,BB is $AA,$BB";
> }
> else {
> print "BOO! AA,BB is $AA,$BB";
> }
> ...
> BOO! AA,BB is EL-0001468271,EL-0001468271
>
> They sure look equal to me. Can anyone tell me what I'm not
> comprehending here ?
1) Try to reverse the output:
...
if($AA eq $BB){
print "YAY! BB,BB is $BB,$AA";
}
else {
print "BOO! BB,AA is $BB,$AA";
}
...
2) Find the "missing link"
(perldoc -f chomp)
3) retry the example with pattern matching,
eg.
if( $BB =~ /$AA/ ){
...
Regards
M.
------------------------------
Date: Thu, 08 Mar 2007 14:45:41 -0500
From: nun <junk@yahoo.com>
Subject: Re: equivalence of variables question
Message-Id: <kZCdnezGIPF5-m3YnZ2dnUVZ_oTinZ2d@megapath.net>
Thanks! That of course did the trick.
DB
------------------------------
Date: 8 Mar 2007 10:03:13 -0800
From: "gf" <greg.ferguson@icrossing.com>
Subject: Re: How can I access the variables in my script ($main::var)
Message-Id: <1173376993.700790.220870@n33g2000cwc.googlegroups.com>
On Mar 7, 2:46 pm, "Sean" <imfeaw5...@pacbell.net> wrote:
> Hi Folks,
>
> I need to access some of the variables in my script. These variables are
> used by methods called in packages that might be nested.
> I have used $main::var. This does not seem to do job. Any sugestions?
Sounds like a really good recipe for a really bad idea.
When I need to be able to write to variables in the main code block, I
pass them into the modules' subroutines as references. If a nested
routine needs access then pass the reference on to it via its
parameters.
I never attempt to refer to them directly because then it's another
spin on abusing globals and that's not good maintenance-wise.
------------------------------
Date: Thu, 08 Mar 2007 11:53:49 -0800
From: Ed Jay <edMbj@aes-intl.com>
Subject: Re: How can I access the variables in my script ($main::var)
Message-Id: <edq0v29jjnd57i14q50ecm9ojbot78jo6b@4ax.com>
Tad McClellan scribed:
>Delivering a diagnosis without being told any of the symptoms
>is futile.
>
It didn't stop Frist. :-)
--
Ed Jay (remove 'M' to respond by email)
------------------------------
Date: 8 Mar 2007 18:50:11 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: IPC::Open2 - Bad File Descriptor
Message-Id: <55b473F2376qiU1@mid.dfncis.de>
Ben Morrow <ben@morrow.me.uk> wrote in comp.lang.perl.misc:
> Quoth Bernard Chan <cbkihong@hotmail.com>:
[...]
> You may find IPC::Run easier to work with, not least because open2 seems
> to require you to use bareword filehandles, which are not considered
> good practice nowadays.
That's no problem:
use IPC::Open2;
my $pid = open2( my( $read, $write), 'sort');
print $write "$_\n" for qw( ccc bbb aaa);
close $write;
print while <$read>;
Anno
------------------------------
Date: Thu, 08 Mar 2007 18:00:38 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Killing threads in perl
Message-Id: <40i0v2h6iv179c6h6aheb03b1upsdhlbju@4ax.com>
On 7 Mar 2007 06:44:56 -0800, joergwenzel@gmx.de wrote:
>who can help me, to kill the threads in this script.
>I create lot of thread with a tar. If the tar canceled with errors, i
>have to kill the rest of
>the threads with tar. I dont now what is the best way. I tested with
>kill Hup, but doesn't work.
In order for a Perl thread to be killed individually, you need
to make it go to the end of it's code block, or do a return.
So, you need a shared variable in the thread
code, to tell it to return.
Like:
my $die:shared;
$die =0;
#in thread code check for it:
if($die){return}
If you don't detach, you still need to return from the thread
block, before a join can happen.
Joining is preferred over detaching, because you can reuse
the thread, or it's space, and that will avoid gaining memory as
you constantly spawn threads.
In c, threads work alot cleaner, but in Perl, you need to watch
for memory accumulating, and that means reusing threads.
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: Thu, 8 Mar 2007 21:00:24 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Posting guidelines work
Message-Id: <Xns98EDA2D41AC0Basu1cornelledu@132.236.56.8>
Hi all:
I just spent fifteen minutes trying to put together a post. It was taking
me too long to describe it so I really tried to narrow down the part of the
code where the problem was occurring.
Guess what?
The posting guidelines work. Problem solved. 1 Gb data file parsed and
reformatted.
If it weren't for the discipline of group regulars here, I would have been
tempted to just post what I had which was a total mish mash after various
false discoveries of where the problem was.
Thanks everyone!
Sinan
------------------------------
Date: Thu, 08 Mar 2007 16:14:44 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Problem with pattern match
Message-Id: <UDWHh.13207$Tf.12642@trndny03>
neilsolent wrote:
> I need to do a pattern match like:
>
> $a =~ /(.*)\/$pattern/;
>
> Trouble is, the variable $pattern contains a string of weird and
> wonderful characters like "+" which seem to get treated as special in
> the regular expression, so I get an error. Is there some way I can
> match using $pattern literally (i.e. ignore the special meaning of any
> characters)?
It seems to me that you want to check if $pattern is a literal substring of
$a, not a RE pattern. If so then why are you cranking the big RE engine
instead of simply checking if it is a substring?
perldoc -f index
jue
------------------------------
Date: Thu, 08 Mar 2007 18:55:38 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Problem with pattern match
Message-Id: <e0j0v29obp27ifs17nhfqo1mcsrdeefe9m@4ax.com>
On Thu, 08 Mar 2007 16:14:44 GMT, "Jürgen Exner"
<jurgenex@hotmail.com> wrote:
>> $a =~ /(.*)\/$pattern/;
[snip]
>It seems to me that you want to check if $pattern is a literal substring of
>$a, not a RE pattern. If so then why are you cranking the big RE engine
>instead of simply checking if it is a substring?
>
> perldoc -f index
But IIRC the regex engine optimizes those cases away anyway. And he
seems to want to capture what's before "/\Q$pattern". (Not that I'd do
it that way...)
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: Thu, 08 Mar 2007 20:09:37 GMT
From: "Mumia W." <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: Problem with pattern match
Message-Id: <54_Hh.10572$tD2.8109@newsread1.news.pas.earthlink.net>
On 03/08/2007 09:07 AM, neilsolent wrote:
> Hi
>
> I need to do a pattern match like:
>
> $a =~ /(.*)\/$pattern/;
>
> Trouble is, the variable $pattern contains a string of weird and
> wonderful characters like "+" which seem to get treated as special in
> the regular expression, so I get an error. Is there some way I can
> match using $pattern literally (i.e. ignore the special meaning of any
> characters)? Needless to day, $pattern is not predetermined, so I
> cannot simpy type out a valid regular expression manually.
>
> many thanks,
> Neil
>
$a =~ /(.*)\/\Q$pattern\E/;
Read about the quotemeta function: "perldoc -f quotemeta"
------------------------------
Date: Thu, 08 Mar 2007 18:30:12 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Splitting a filename
Message-Id: <dbh0v2lrjjnellfnemhi7bqgh3njhnl36e@4ax.com>
On Thu, 8 Mar 2007 01:19:54 +0100, "Petr Vileta"
<stoupa@practisoft.cz> wrote:
>sub parsename {
>my $filename = shift;
>my ($name, $ext) = ('') x2;
No need to initialize, and most ugly initialization.
>if($filename =~ m/\./) {$filename =~ s/^(.*)(\..*)$/$1$2/; $name = $1; $ext
Why in the world a s/// where a match would suffice? (And could
directly return the wanted values instead of relying on $1 and $2.)
>= $2; }
Terrible indenting, BTW.
>else {$name = $filename;}
How 'bout an early return() instead?
>return ($name, $ext);
>}
Just a rewrite of your code with the same semantics but a saner
syntax:
sub parsename {
local $_ = shift;
return($_, '') unless /\./;
/^(.*)(\..*)$/;
}
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: 8 Mar 2007 17:42:11 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Splitting a filename
Message-Id: <55b07jF23trs3U1@mid.dfncis.de>
Michele Dondi <bik.mido@tiscalinet.it> wrote in comp.lang.perl.misc:
> On Thu, 8 Mar 2007 01:19:54 +0100, "Petr Vileta"
> <stoupa@practisoft.cz> wrote:
[...]
> Just a rewrite of your code with the same semantics but a saner
> syntax:
>
> sub parsename {
> local $_ = shift;
> return($_, '') unless /\./;
> /^(.*)(\..*)$/;
> }
As a side note, I'd avoid localizing $_ if possible. There's a bug
lurking that bites when $_ is aliased to a value in a tied hash (or
something exotic like that). Ask Brian McCauley about it, he's
the resident expert on that bug :)
Sometimes a one-shot "for" can do the trick:
sub parsename {
for ( shift ) {
return($_, '') unless /\./;
return /^(.*)(\..*)$/;
}
}
Anno
------------------------------
Date: Thu, 08 Mar 2007 21:46:42 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Splitting a filename
Message-Id: <5bt0v2tqio8fco598lsjqimhaumlcqop2f@4ax.com>
On 8 Mar 2007 17:42:11 GMT, anno4000@radom.zrz.tu-berlin.de wrote:
>Sometimes a one-shot "for" can do the trick:
>
> sub parsename {
> for ( shift ) {
> return($_, '') unless /\./;
> return /^(.*)(\..*)$/;
> }
> }
Oh, I'm a big fan of one shot C<for>s. But then I heard about lexical
C<$_> in blead, how is it supposed to work? Just
my $_ = shift; # ?
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: Thu, 08 Mar 2007 21:51:54 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Splitting a filename
Message-Id: <rnt0v25el8hvbcg1052uj58p6ive5ov7rh@4ax.com>
On Thu, 08 Mar 2007 21:46:42 +0100, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
>> sub parsename {
>> for ( shift ) {
>> return($_, '') unless /\./;
>> return /^(.*)(\..*)$/;
>> }
>> }
>
>Oh, I'm a big fan of one shot C<for>s. But then I heard about lexical
And of course that could even be cast in the form of a single
statement:
sub parsename { return /\./ ? /^(.*)(\..*)$/ : $_, '' for shift }
Although just as obviously I would call that an *abuse*.
:-)
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: Thu, 08 Mar 2007 18:41:45 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: view images inside the windows xp shell
Message-Id: <s3i0v2dcc9k9pqg4hqfbidhukqoo3c030j@4ax.com>
On 8 Mar 2007 00:39:19 -0800, francyve74@gmail.com wrote:
>Hi, I've done a lot of googling but I couldn't find a way to view
>images inside the windows xp shell, I don't want an external window to
Huh?!? If the image extension has an association, the
start image.ext
will open it in the viewer of choice, the Windows' one if it's the
default.
>appear, so may be that tk-perl is not a choice; I've tried also image-
I don't understand what you really mean. Tk creates GUIs, a program
with a GUI has its own window(s). If you want to open an image in "the
windows xp shell" -whatever it is, I hope *not* the DOS console- you
*do* want an external window.
>magick (with the display command) but it needs an x-server. Can you
>please suggest me any alternative to image-magick?
Not that I know. I have ImageMagick installed under Windows and it
doesn't need an X server.
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: Thu, 08 Mar 2007 21:47:34 GMT
From: Brian Helterline <brian.helterline@hp.com>
Subject: Re: view images inside the windows xp shell
Message-Id: <Wv%Hh.1001$gB4.819@news.cpqcorp.net>
francyve74@gmail.com wrote:
> Hi, I've done a lot of googling but I couldn't find a way to view
> images inside the windows xp shell, I don't want an external window to
> appear, so may be that tk-perl is not a choice; I've tried also image-
> magick (with the display command) but it needs an x-server. Can you
> please suggest me any alternative to image-magick?
> Thanks
>
try running your perl tk program with wperl.exe. It does not create the
DOS box.
--
brian
------------------------------
Date: 08 Mar 2007 18:37:45 GMT
From: xhoster@gmail.com
Subject: Re: What is abriviation for CHR(4)
Message-Id: <20070308134432.813$DB@newsreader.com>
"max" <max@xxx.tovle.ct> wrote:
> Problem with making Replacement CHR(4) in something.
> CHR(9) is "\t"
> I use tr///.
> What is abbreviation for CHR(4)
$ perl -le 'use Data::Dumper; $Data::Dumper::Useqq=1; \
print Dumper [chr(4), chr(9)];'
$VAR1 = [
"\4",
"\t"
];
It looks like "\4" is a good abbreviation, but I imagine it wouldn't
work if followed by a digit (in which case Dumper uses "\004" instead).
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
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 206
**************************************