[28830] in Perl-Users-Digest
Perl-Users Digest, Issue: 74 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 25 18:06:36 2007
Date: Thu, 25 Jan 2007 15:05:12 -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, 25 Jan 2007 Volume: 11 Number: 74
Today's topics:
Re: Call another program using system <nobull67@gmail.com>
Re: Call another program using system <bik.mido@tiscalinet.it>
Hash of Hashes <doni.sekar@gmail.com>
Re: Hash of Hashes <kenslaterpa@hotmail.com>
Re: Hash of Hashes <bik.mido@tiscalinet.it>
Re: Hash of Hashes <doni.sekar@gmail.com>
Re: Is there a delete operator in Perl? xhoster@gmail.com
loop won't run, for ( my $i = 10 ; $i == 1 ; etc <justin.0511@purestblue.com>
Re: loop won't run, for ( my $i = 10 ; $i == 1 ; etc <mritty@gmail.com>
Re: loop won't run, for ( my $i = 10 ; $i == 1 ; etc <cliff.martin@gmail.com>
MacPerl, OS 9, move file to Trash <please@nospam.net>
Re: MacPerl, OS 9, move file to Trash <spamtrap@dot-app.org>
Re: Net::FTPSSL problem (or how to do FTP over SSL anot <dsiomtw@gmail.com>
Re: Net::FTPSSL problem (or how to do FTP over SSL anot <dsiomtw@gmail.com>
problems regexp <john.swilting@wanadoo.fr>
Re: problems regexp <john.swilting@wanadoo.fr>
Re: problems regexp <mritty@gmail.com>
Re: reverse-function with regex <pieter.online@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Jan 2007 11:00:41 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Call another program using system
Message-Id: <1169751641.344451.239480@k78g2000cwa.googlegroups.com>
On Jan 25, 12:16 pm, "sonet" <sonet....@msa.hinet.net> wrote:
> I need to call a command_line(CM1.EXE) from another program(APP1.pl).
> in APP.pl (PERL)
>
> #!perl.exe
> system('/path/CM1.EXE 1234>file.txt');
>
> But the CM1.exe will show the console window.
> How to avoid the CM1.exe show the console window?
>From the .EXE suffix I'm guessing you may be using a rather odd
operating system known as Windows (often referred to as Win32).
I believe this means that CM1.exe was compiled as a console
application. When you execute a console app exe on Windows (other than
from an existing console) Windows will open a console. (I'm guesssing
you are using wperl.exe).
You can get low-level control over how processes are launched on
Windows using the Win32::Process module. I suspect there's some
combination of these that will cause console apps to run without a
console (or more accurately (IIRC) with a hidden one).
use strict;
use warnings;
use Win32::Process;
Win32::Process::Create
( my ($ProcessObj),
'C:\windows\system32\cmd.exe',
'/C "\path\CM1.EXE 1234>file.txt"',
0,
NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW,
"."
) or die "$^E";
Note that this is messy because you call cmd.exe to parse the shell
redirection characters.
There ought to be a way to do the redirection in Perl without the need
for the extra level of process but when I try it seems not to play
nicely with CREATE_NO_WINDOW.
This however has (almost) nothing to do with Perl and a lot to do with
the pain of using the Windows API (whatever your chosen language).
------------------------------
Date: Thu, 25 Jan 2007 20:45:32 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Call another program using system
Message-Id: <jv1ir2hk59akf2pj0ieigr8635ea7e9ibb@4ax.com>
On 25 Jan 2007 11:00:41 -0800, "Brian McCauley" <nobull67@gmail.com>
wrote:
>I believe this means that CM1.exe was compiled as a console
>application. When you execute a console app exe on Windows (other than
>from an existing console) Windows will open a console. (I'm guesssing
>you are using wperl.exe).
BTW: not everybody knows that AS's ActivePerl ships with a program
(which is a perl script itself) called exetype[*] which will change
the type of executable. For those who have it,
perldoc exetype
will explain the whole of it in more details.
[*] IIRC wperl.exe is just perl.exe passed through it...
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: 25 Jan 2007 14:07:59 -0800
From: "doni" <doni.sekar@gmail.com>
Subject: Hash of Hashes
Message-Id: <1169762879.189651.94900@m58g2000cwm.googlegroups.com>
Hi,
I am having some problems in printing the Hash of Hashes.
MAC, PHY and Network stats gets generated every 30 minutes and are
copied to a file.
I want to extract all the stats information that is copied to a file
into an hash of hashes and print them.
The file has multiple MAC, PHY and Network Statistics in it and I am
extracting the MAC data in a MAC hash of hashes, PHY data in a PHY hash
of hashes and Network data in a Network hash of hashes.
Here is how the data that is represented in a file. There will be
multiple MAC, PHY and Network Statistics in the file but I am showing
only one of them in here as an example.
MAC statistics:
0 frames with invalid header
546 confirmed frames sent succesfully
1693 confirmed frames sent unsuccesfully
542 confirmed frames received
4597 total frames received
851 data packets received
549 packets sent successfully
152 packets sent unsuccessfully
763 packets queued by network layer
61 packet transmissions timed out
0 packets with invalid length
0 out of order fragments received
87 duplicate fragments received
0 partial packets received
4 packet reassemblies timed out
0 no buffers
PHY statistics:
3404 frames transmitted
105 transmits aborted due to rx
0 transmit errors
0 late transmits
11 tx buffer loads interrupted
0 tx buffer load failures
4598 receive interrupts
4598 frames received
0 received frames lost
0 zero length frames received
0 receive cmd errors
Network statistics:
851 total packets received
0 bad packet length
0 bad version number
0 outgoing packets with no route
0 input packets with bad destination address
0 input packets from wrong channel
0 packets dropped for exceeding TTL
0 packets dropped due to full socket buffers
0 packets dropped due to no receiver
0 packets dropped due to running out of memory
762 total packets sent
549 packets succesfully transmitted
213 packets sent unsuccessfully
For example, if there were 10 MAC Statistics in the file, this is how I
want the data from the "frames with invalid header" stats message to be
copied to a hash.
$mac{'frames with invalid header'}{1} = 0
$mac{'frames with invalid header'}{2} = 0
....... $mac{'frames with invalid header'}{10} = 0
Here is the program I wrote to do the above operation but its not
working as expected. Can anyone let me know where I went wrong.
Thanks,
doni
### Open the netstat file copied to this location ###
my $ex_data = 'netstat.log';
open (NETSTAT,$ex_data) || die("Cannot Open File: $!");
my %mac = (); # Will be the HOH for MAC Statistics
my %phy = (); # Will be the HoH for PHY Statistics
my %bbu = (); # Will be the HoH for BBU Statistics
my %dli = (); # Will be the HoH for DLI Statistics
my $stats; # State Variable
my $i = 0; # Count variable for MAC
my $j = 0; # Count Variable for PHY
my $a = 0; # Count Variable for Network
my $x = 0; # Count Varialbe for Hash
while (<NETSTAT>) {
chomp;
if (/^(\S+)\s+statistics:/) {
$stats = $1;
if ($stats =~ /mac/i)
{ $i++; }
elsif ($stats =~ /phy/i)
{ $j++; }
else
{ $a++; }
}
elsif (/^\s+(\d+)\s+(\S.*)/)
{
($value, $key) = ($1, $2);
if ($stats =~ /mac/i) {
next unless defined $stats;
$mac{$key}{$i} = $value;
}
if ($stats =~ /phy/i) {
next unless defined $stats;
$phy{$key}{$j} = $value;
}
if ($stats =~ /network/i) {
next unless defined $stats;
$network{$key}{$a} = $value;
}
}
else { }
}
foreach $key (keys (%mac)) {
foreach $x (keys %{$mac{$key} })
{
while ($x <= $i) {
print "Message Value is: $mac{$key}{$i}\n";
$x++;
}
}
}
close(NETSTAT) || die("Cannot close $ex_data: $!");
------------------------------
Date: 25 Jan 2007 14:36:38 -0800
From: "kens" <kenslaterpa@hotmail.com>
Subject: Re: Hash of Hashes
Message-Id: <1169764598.447244.94710@a75g2000cwd.googlegroups.com>
On Jan 25, 5:07 pm, "doni" <doni.se...@gmail.com> wrote:
> Hi,
>
> I am having some problems in printing the Hash of Hashes.
> MAC, PHY and Network stats gets generated every 30 minutes and are
> copied to a file.
You do not say what the problem is?
> I want to extract all the stats information that is copied to a file
> into an hash of hashes and print them.
> The file has multiple MAC, PHY and Network Statistics in it and I am
> extracting the MAC data in a MAC hash of hashes, PHY data in a PHY hash
> of hashes and Network data in a Network hash of hashes.
> Here is how the data that is represented in a file. There will be
> multiple MAC, PHY and Network Statistics in the file but I am showing
> only one of them in here as an example.
>
> MAC statistics:
> 0 frames with invalid header
> 546 confirmed frames sent succesfully
> 1693 confirmed frames sent unsuccesfully
> 542 confirmed frames received
> 4597 total frames received
> 851 data packets received
> 549 packets sent successfully
> 152 packets sent unsuccessfully
> 763 packets queued by network layer
> 61 packet transmissions timed out
> 0 packets with invalid length
> 0 out of order fragments received
> 87 duplicate fragments received
> 0 partial packets received
> 4 packet reassemblies timed out
> 0 no buffers
> PHY statistics:
> 3404 frames transmitted
> 105 transmits aborted due to rx
> 0 transmit errors
> 0 late transmits
> 11 tx buffer loads interrupted
> 0 tx buffer load failures
> 4598 receive interrupts
> 4598 frames received
> 0 received frames lost
> 0 zero length frames received
> 0 receive cmd errors
> Network statistics:
> 851 total packets received
> 0 bad packet length
> 0 bad version number
> 0 outgoing packets with no route
> 0 input packets with bad destination address
> 0 input packets from wrong channel
> 0 packets dropped for exceeding TTL
> 0 packets dropped due to full socket buffers
> 0 packets dropped due to no receiver
> 0 packets dropped due to running out of memory
> 762 total packets sent
> 549 packets succesfully transmitted
> 213 packets sent unsuccessfully
>
> For example, if there were 10 MAC Statistics in the file, this is how I
> want the data from the "frames with invalid header" stats message to be
> copied to a hash.
> $mac{'frames with invalid header'}{1} = 0
> $mac{'frames with invalid header'}{2} = 0
> ....... $mac{'frames with invalid header'}{10} = 0
>
> Here is the program I wrote to do the above operation but its not
> working as expected. Can anyone let me know where I went wrong.
What is it doing that you did not expect?
>
> Thanks,
> doni
Always begin with the following two lines:
use strict;
use warnings;
>
> ### Open the netstat file copied to this location ###
> my $ex_data = 'netstat.log';
> open (NETSTAT,$ex_data) || die("Cannot Open File: $!");
>
> my %mac = (); # Will be the HOH for MAC Statistics
> my %phy = (); # Will be the HoH for PHY Statistics
> my %bbu = (); # Will be the HoH for BBU Statistics
> my %dli = (); # Will be the HoH for DLI Statistics
> my $stats; # State Variable
> my $i = 0; # Count variable for MAC
> my $j = 0; # Count Variable for PHY
> my $a = 0; # Count Variable for Network
> my $x = 0; # Count Varialbe for Hash
>
> while (<NETSTAT>) {
> chomp;
> if (/^(\S+)\s+statistics:/) {
> $stats = $1;
> if ($stats =~ /mac/i)
> { $i++; }
> elsif ($stats =~ /phy/i)
> { $j++; }
> else
> { $a++; }
> }
>
> elsif (/^\s+(\d+)\s+(\S.*)/)
> {
> ($value, $key) = ($1, $2);
> if ($stats =~ /mac/i) {
> next unless defined $stats;
> $mac{$key}{$i} = $value;
> }
> if ($stats =~ /phy/i) {
> next unless defined $stats;
> $phy{$key}{$j} = $value;
> }
> if ($stats =~ /network/i) {
> next unless defined $stats;
> $network{$key}{$a} = $value;
> }
> }
> else { }
>
> }foreach $key (keys (%mac)) {
Why do you have this 'foreach' loop?
Set $x = 1 and just use the 'while' loop'.
> foreach $x (keys %{$mac{$key} })
> {
> while ($x <= $i) {
Note that $i never changes, I believe you want $x.
> print "Message Value is: $mac{$key}{$i}\n";
> $x++;
> }
>
> }
>
> }close(NETSTAT) || die("Cannot close $ex_data: $!");
HTH,
Ken
------------------------------
Date: Thu, 25 Jan 2007 23:42:43 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Hash of Hashes
Message-Id: <qgcir21v90prokke7pb8bv7ans2fgehh5s@4ax.com>
On 25 Jan 2007 14:07:59 -0800, "doni" <doni.sekar@gmail.com> wrote:
>I am having some problems in printing the Hash of Hashes.
Try Data::Dumper;
print Dumper \%HoH;
>MAC, PHY and Network stats gets generated every 30 minutes and are
>copied to a file.
>I want to extract all the stats information that is copied to a file
>into an hash of hashes and print them.
>The file has multiple MAC, PHY and Network Statistics in it and I am
>extracting the MAC data in a MAC hash of hashes, PHY data in a PHY hash
>of hashes and Network data in a Network hash of hashes.
>Here is how the data that is represented in a file. There will be
You asked this in another article already. No need to repost the very
same question. This is not going to help you.
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: 25 Jan 2007 14:47:35 -0800
From: "doni" <doni.sekar@gmail.com>
Subject: Re: Hash of Hashes
Message-Id: <1169765255.743074.210430@q2g2000cwa.googlegroups.com>
On Jan 25, 2:36 pm, "kens" <kenslate...@hotmail.com> wrote:
> You do not say what the problem is?
When I am trying to print %mac HoH, I am not getting the desired
result. I was expecting that all the stats under MAC will be printed 10
times starting with (x=1) if there were 10 repeats of MAC Statistics in
the file.
> > }foreach $key (keys (%mac)) {Why do you have this 'foreach' loop?
I was using this loop so that I know what particular stats under
MAC is coming out...
Thanks,
doni
------------------------------
Date: 25 Jan 2007 16:32:22 GMT
From: xhoster@gmail.com
Subject: Re: Is there a delete operator in Perl?
Message-Id: <20070125113318.087$pC@newsreader.com>
Ted Zlatanov <tzz@lifelogs.com> wrote:
> On 24 Jan 2007, trashman.horlicks@btinternet.com wrote:
>
> > Yes, I know theres one for hashes, but I was wondering if there was
> > one for elements in a linked list? I have such a list, and it is
> > being read sequentially, with new items being placed either at the
> > end, or the middle of the list. Now, I know how to do this in C++,
> > but I was wondering if there was a way of deleting used/old list
> > elements? And is there a way to add an array element to the middle
> > of a list?
>
> Look at perldoc -f splice to make modifications to a list in any
> place.
>
> push/pop and shift/unshift (again, use perldoc -f to look them up)
> deal with adding and deleting elements at the beginning or end of a
> list.
>
> bugbear suggested these operations may be slow for large lists.
Not push/pop and shift/unshift so much as splice. (And splice near one
end or the other is pretty fast, too).
> I'd
> say instead you should write your code to work correctly first, then
> worry about optimizing for speed.
While that is generally true, it sounds to me like he is implementing some
kind of fancy LRU cache. If that is the case, I'd say he is already in
the "optimizing for speed" stage.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Thu, 25 Jan 2007 16:45:37 -0000
From: Justin C <justin.0511@purestblue.com>
Subject: loop won't run, for ( my $i = 10 ; $i == 1 ; etc
Message-Id: <slrnerhnlh.5fj.justin.0511@stigmata.purestblue.com>
I can't see why this won't run, I've the Learning Perl book here and,
though I'm not using $i as per the example, I've followed it (AFAICT)
exactly. Here's the code:
#!/usr/bin/perl
use warnings ;
use strict ;
my @data = qw/ john paul george ringo / ;
thumbs(@data) ;
sub thumbs {
my $row_count = 5 ;
for ( my $pg_count = 15 ; $pg_count == 0 ; $pg_count-- ) {
print "$pg_count PC" ;
$row_count-- ;
$pg_count-- ;
}
}
This obviously isn't all my code but it's the shortest example that
demonstrates the problem.
I bet it's something really simple, but I can't see it... I'm tensed
and ready for the "stoopid noob" slap :)
What I've done to test this is litter the entire code with print
statements, the sub is called but the 'for' loop just appears to be
skipped.
Perl 5.8.4, Debian amd64 (Sarge, unofficial port).
I'm looking and looking at the loop:
The first part is an assignement, the second part is a test, the third
part is the increment (or whatever). Nope, I cannot see what it is.
Thank you for your time.
Justin.
--
Justin C by the sea.
------------------------------
Date: 25 Jan 2007 11:27:09 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: loop won't run, for ( my $i = 10 ; $i == 1 ; etc
Message-Id: <1169753228.917229.11160@k78g2000cwa.googlegroups.com>
On Jan 25, 11:45 am, Justin C <justin.0...@purestblue.com> wrote:
> I can't see why this won't run, I've the Learning Perl book here and,
> though I'm not using $i as per the example, I've followed it (AFAICT)
> exactly. Here's the code:
>
> for ( my $pg_count = 15 ; $pg_count == 0 ; $pg_count-- ) {
> print "$pg_count PC" ;
> $row_count-- ;
> $pg_count-- ;
> }
>
> }This obviously isn't all my code but it's the shortest example that
> demonstrates the problem.
>
> I bet it's something really simple, but I can't see it... I'm tensed
> and ready for the "stoopid noob" slap :)
Consider yourself slapped. :-P
A for loop's three parts are INIT, TEST, INCR. The initialization is
my $pgcount = 15;
That's fine. Then as soon as that initialization is done, the TEST is
checked. If and only if the TEST is true, does the loop execute. Your
test is:
$pgcount == 0
This is obviously false, so the TEST fails and the loop ends. Your
confusion seems to be in thinking that the loop executes *until* the
test is true. Not so - it executes *while* the test is true. Change
your test to:
$pgcount > 0
and all will be well. Except for the fact that you're decrementing
your variable twice - once in the loop header and once in the loop
body. Maybe that's what you meant to do, maybe it's not. That depends
on your program logic.
Paul Lalli
------------------------------
Date: 25 Jan 2007 11:32:34 -0800
From: "Cliff Martin" <cliff.martin@gmail.com>
Subject: Re: loop won't run, for ( my $i = 10 ; $i == 1 ; etc
Message-Id: <1169753554.788229.45860@v45g2000cwv.googlegroups.com>
On Jan 25, 11:45 am, Justin C <justin.0...@purestblue.com> wrote:
> I can't see why this won't run, I've the Learning Perl book here and,
> though I'm not using $i as per the example, I've followed it (AFAICT)
> exactly. Here's the code:
>
> #!/usr/bin/perl
>
> use warnings ;
> use strict ;
>
> my @data = qw/ john paul george ringo / ;
>
> thumbs(@data) ;
>
> sub thumbs {
> my $row_count = 5 ;
> for ( my $pg_count = 15 ; $pg_count == 0 ; $pg_count-- ) {
> print "$pg_count PC" ;
> $row_count-- ;
> $pg_count-- ;
> }
>
> }This obviously isn't all my code but it's the shortest example that
> demonstrates the problem.
>
> I bet it's something really simple, but I can't see it... I'm tensed
> and ready for the "stoopid noob" slap :)
>
> What I've done to test this is litter the entire code with print
> statements, the sub is called but the 'for' loop just appears to be
> skipped.
>
> Perl 5.8.4, Debian amd64 (Sarge, unofficial port).
>
> I'm looking and looking at the loop:
>
> The first part is an assignement, the second part is a test, the third
> part is the increment (or whatever). Nope, I cannot see what it is.
>
> Thank you for your time.
>
> Justin.
>
> --
> Justin C by the sea.
your test in your for loop will always fail. Try:
for ( my $pg_count = 15 ; $pg_count >= 0 ; $pg_count-- ) {
Cliff
------------------------------
Date: Thu, 25 Jan 2007 13:37:43 -0800
From: Xiong Changnian <please@nospam.net>
Subject: MacPerl, OS 9, move file to Trash
Message-Id: <please-22AEED.13374325012007@free.teranews.com>
My little utility-in-the-making will scan a folder full of backups and
move the oldest ones to the Trash. So I'd like to hope.
I'm doing fine right up to the point where I wish to make the actual
move. That is, I've identified the files I wish to Trash -- I have the
full path in the form preferred under Mac OS 9.
So, what next? The usual Perl resources are no help, of course; this
issue is all about the Mac way of doing things. I dug through the
specialized-for-Mac modules included in the MacPerl distro; none seem to
fit the bill -- I can't imagine why, I think I must be overlooking
something. I'm pretty much a Perl novice.
It seems risky to go shoving files around directly; that's not the Mac
way. Hey, what about AppleScript? And indeed, I've got a little gimmick
working, sort of:
my $script;
$script = <<END;
tell application "Finder"
move file ("$deadfile") to trash
end tell
END
MacPerl::DoAppleScript($script) #do the trash script
or die ("AppleScript failed: $! \n");
This really does work -- very slowly and only once. If I call it twice
in a row (with two different path/filenames for $deadfile), MacPerl
stalls, stalls, stalls and if I start randomly clicking the mouse, I
hear the little "ding" of a file hitting the Trash. Then, nothing, no
matter what I do -- until I force-quit MacPerl. Then I get the second
"ding". Sure enough, both files are Trashed. I never die.
It seems that MacPerl is hogging time. It tells the Finder and the
Finder gets the command; but then MacPerl doesn't give it any time in
which to act. Not clear why clicking around sometimes helps; perhaps
it's just enough to burp a handler and the Finder gets a little time on
the way out -- something like that.
But basically -- I think -- Finder is waiting to be given time, while
MacPerl is waiting for a return from MacPerl::DoAppleScript(). Does that
seem right?
For the record, it's Mac OS 9.2.2, MacPerl 5.6.1r2 and yes, I have other
Perl scripts working fine.
* * *
So, let's speak frankly. I expect a number of responses and I'd like to
pre-reply to some of them.
* I realize this looks a little off-topic for this newsgroup and I'm
sorry about that. I don't have the first idea where to go for help; I
see no "*.macperl" NG.
* I did RTFM. I R all TFM I could lay my hands on. I've searched high
and wide on the infobahn. A pointer to a resource that actually contains
a solution to my problem is probably *better* than the solution itself,
yes, thank you. I'll look there first, next time.
* It's probably better not to adapt solutions intended for other
platforms, such as direct deletion. We Mac folks expect files to be
moved to the Trash, not deleted instanter. Sometimes we poke around in
the Trash before emptying it.
* It's my Mac. Yes, it is old and wheezy and small children throw stones
at my car when I drive to the corner store. Sorry, but all solutions
that include buying a new Mac and/or installing OS X are out, for today.
Same for those that require me to buy a real computer.
Many thanks await my White Knight.
--
Xiong Changnian
xiong103ATxuefangDOTcom
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Thu, 25 Jan 2007 17:23:20 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: MacPerl, OS 9, move file to Trash
Message-Id: <m2veiuu4o7.fsf@Sherm-Pendleys-Computer.local>
Xiong Changnian <please@nospam.net> writes:
> My little utility-in-the-making will scan a folder full of backups and
> move the oldest ones to the Trash. So I'd like to hope.
>
> I'm doing fine right up to the point where I wish to make the actual
> move. That is, I've identified the files I wish to Trash -- I have the
> full path in the form preferred under Mac OS 9.
>
> So, what next? The usual Perl resources are no help, of course; this
> issue is all about the Mac way of doing things. I dug through the
> specialized-for-Mac modules included in the MacPerl distro; none seem to
> fit the bill -- I can't imagine why, I think I must be overlooking
> something. I'm pretty much a Perl novice.
Just renaming them should work. Try this:
#!/usr/bin/perl
use warnings;
use strict;
rename 'drivename:path:to:file', 'drivename:Trash:file';
> * I realize this looks a little off-topic for this newsgroup and I'm
> sorry about that. I don't have the first idea where to go for help; I
> see no "*.macperl" NG.
Try lists.perl.org - there are a number of macperl mailing lists there, and
the current MacPerl maintainer (Chris Nandor) seems quite active on them.
> * I did RTFM. I R all TFM I could lay my hands on. I've searched high
> and wide on the infobahn. A pointer to a resource that actually contains
> a solution to my problem is probably *better* than the solution itself,
> yes, thank you. I'll look there first, next time.
I googled for "MacPerl trash file", and that led me to this discussion:
<http://bumppo.net/lists/macperl/1997/04/msg00079.html>
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: 25 Jan 2007 10:33:51 -0800
From: "DSIOMTW" <dsiomtw@gmail.com>
Subject: Re: Net::FTPSSL problem (or how to do FTP over SSL another way?)
Message-Id: <1169750031.035639.144480@k78g2000cwa.googlegroups.com>
Unfortunately the service I need to access only supports ftps...
It's definitely a problem when switching to PASV mode, but Net::FTPSSL
seems to do that automatically and there doesn't appear to be any way
to switch that off (although I think it's required).
When using my desktop FTP client I get this ...
\par\cf1 PASV
\par\cf1 227 Entering Passive Mode (67,137,159,254,4,0).
With the perl script using Net::FTPSSL I get all those errors
immediately after PASV is requested.
I've also emailed the author of Net::FTPSSL and have not received a
reply.
------------------------------
Date: 25 Jan 2007 14:40:27 -0800
From: "DSIOMTW" <dsiomtw@gmail.com>
Subject: Re: Net::FTPSSL problem (or how to do FTP over SSL another way?)
Message-Id: <1169764826.945945.39280@s48g2000cws.googlegroups.com>
Here's the relavent code from FTPSSL.pm:
Here's the relavent code:
136: unless ( substr( $msg, 0, 1 ) == CMD_OK ) { return 0; }
137:
138: $msg =~ m/(\d+)\s(.*)\(((\d+,?)+)\)\.?/
139: ; # [227] [Entering Passive Mode] ([h1,h2,h3,h4,p1,p2]).
140:
141: my @address = split( /,/, $3 );
So it seems like it's not getting a proper response back after issuing
the PASV command. But if it's not getting a proper response it should
return 0 it seems and not even get to line 141 where it runs into the
first problem...
------------------------------
Date: Thu, 25 Jan 2007 17:45:12 +0100
From: "john.swilting" <john.swilting@wanadoo.fr>
Subject: problems regexp
Message-Id: <45b8de87$0$27415$ba4acef3@news.orange.fr>
I try to test a scalar which ends by a .gif
With any OS
try
if($data{attachement} = ~m/$`\.gif/){
MAIL($data{attachement});
}else{
AFFICHAGE_ERREUR_ATTACHEMENT($data{attachement});
}
It does not walk(work)
please help me
serge
------------------------------
Date: Thu, 25 Jan 2007 18:10:38 +0100
From: "john.swilting" <john.swilting@wanadoo.fr>
Subject: Re: problems regexp
Message-Id: <45b8e47d$0$27368$ba4acef3@news.orange.fr>
john.swilting wrote:
> I try to test a scalar which ends by a .gif
> With any OS
>
> try
> if($data{attachement} = ~m/$`\.gif/){
> MAIL($data{attachement});
> }else{
> AFFICHAGE_ERREUR_ATTACHEMENT($data{attachement});
> }
>
> It does not walk(work)
> please help me
>
> serge
iseek a scalar which ens in .gif
------------------------------
Date: 25 Jan 2007 09:38:03 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: problems regexp
Message-Id: <1169746683.626204.254560@k78g2000cwa.googlegroups.com>
On Jan 25, 11:45 am, "john.swilting" <john.swilt...@wanadoo.fr> wrote:
> I try to test a scalar which ends by a .gif
You have to define what you mean by "test" a scalar.
> With any OS
>
> try
> if($data{attachement} = ~m/$`\.gif/){
If you'd enabled strict and warnings, Perl would tell you you'd done a
few things wrong here.
First, the operator is =~. Those two characters, right next to each
other. You can not put a space in betwene them. Second, the $`
variable is used *after* a successful pattern match, not within it.
Third, you are only testing if the scalar *contains* .gif, not if it
ends in .gif - you have to anchor the pattern.
if ($data{attachment} =~ m/\.gif$/) {
> It does not walk(work)
"work" is the correct English word here. "walk" makes no sense.
Paul Lalli
------------------------------
Date: 25 Jan 2007 08:16:38 -0800
From: "Pieter Online" <pieter.online@gmail.com>
Subject: Re: reverse-function with regex
Message-Id: <1169741798.629872.53400@j27g2000cwj.googlegroups.com>
Thank you guys,
you're amazing!!!
The recursive function was great and you're explanation really helped
me to improve my regex juggling skillz.
Best regards,
Pieter
On Jan 25, 4:48 pm, Ted Zlatanov <t...@lifelogs.com> wrote:
> On 25 Jan 2007, pieter.onl...@gmail.com wrote:
>
> > I'm trying to write a reverse-function with regex,
>
> > The following code gives: fedcba
> > $message = "abcdef";
> > $message =~ s/(.)(.)(.)(.)(.)(.)/$6$5$4$3$2$1/;
> > print $message;
>
> > But I like to use something like:
> > $message =~ s/(.){6}/$6$5$4$3$2$1/;
> > or even
> > $message =~ s/(.)*/$6$5$4$3$2$1/;
>
> > But that does not work, and all I can do is hope one of you can help me
> > out..Regular expressions can't reverse arbitrary strings, it's not part of
> their functionality. The only way is to do s/(.*)/reverse($1)/e which
> of course is better written as $message = reverse $message;
>
> Ted
------------------------------
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 74
*************************************