[28832] in Perl-Users-Digest
Perl-Users Digest, Issue: 76 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 25 21:06:10 2007
Date: Thu, 25 Jan 2007 18:05:05 -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: 76
Today's topics:
appending to a global filehandle <mark.leeds@morganstanley.com>
Re: Hash of Hashes <someone@example.com>
Re: 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 <DJStunks@gmail.com>
Re: 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 <sisyphus1@nomail.afraid.com>
Re: Statistics Extraction <emschwar@pobox.com>
String Substitution question <LtCommander@gmail.com>
Re: String Substitution question <wahab-mail@gmx.de>
Re: String Substitution question <wahab-mail@gmx.de>
Re: String Substitution question <mritty@gmail.com>
Re: String Substitution question <yankeeinexile@gmail.com>
Re: Style questions usenet@DavidFilmer.com
Re: Style questions <abigail@abigail.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Jan 2007 17:39:40 -0800
From: "markpark" <mark.leeds@morganstanley.com>
Subject: appending to a global filehandle
Message-Id: <1169775580.255085.276330@a75g2000cwd.googlegroups.com>
i have a function called writedata and, inside the function, some
things
get calculated ( details not important ) and then a file gets opened
and written to. but this function
is called over and over and what i want to do is keep appending to the
same file.
but, it seems like using the >> doesn't help because the files becomes
empty
once the routine is exited ?
is there some way to deal with this ? I am very much a novice in perl
and
much of the code below was cut and pasted form other people's programs.
i definitely don't want to
give the false impression that i know what i am doing.
i guess that i need to make the filehandle global somehow but i'm not
clear on how to do that ?
or maybe send it in as a parameter ? thank you very much for any help
that can be provided.
# MAIN PROGRAM ( not quite but this gives the idea )
foreach (my $bin=$exchMap->{$Exch}{s2}; $bin<=$exchMap->{$Exch}{e2};
$bin++) {
my $cMap={};
writedata($date,$cnt,$Exch,$bin,$cMap,$bMap,$prevMap,$ewmaMap,$cnddir);
$cnt++;
}
# END OF MAIN PROGRAM
sub writedata {
my $date = shift;
my $cnt = shift;
my $exch = shift;
my $bin = shift;
my $cMap = shift;
my $bMap = shift;
my $prevMap = shift;
my $ewmaMap = shift;
my $cnddir = shift;
my $outf = $cnddir . "/$exch" . "." . "dailyfile.txt";
open (OUTF,">> $outf") || die "could not open $outf";
foreach my $xid (keys %{$cMap}) {
if (! exists($bMap->{$xid})) { next; }
my ($te,$code) = getPrimary($xid,$date);
my $ca = $cMap->{$xid}{ca};
my $cb = $cMap->{$xid}{cb};
my $cmid = ($ca+$cb)/2;
if ($ca<=0 or $cb<=0 or $cb > $ca) { next; }
my $ccp = $cMap->{$xid}{ccp};
my $totvs = $cMap->{$xid}{totvs};
my $hp = $cMap->{$xid}{hp};
my $lp = $cMap->{$xid}{lp};
my $ba = $bMap->{$xid}{ca};
my $bb = $bMap->{$xid}{cb};
my $bmid = ($ba+$bb)/2;
if ($ba<=0 or $bb<=0 or $bb > $ba) { next; }
my $pr = 0;
my $pvs = 0;
if (exists($prevMap->{$xid})) {
$pr = $prevMap->{$xid}{ret};
$pvs = $prevMap->{$xid}{totvs};
}
my $r = sprintf("%.6f",log($cmid/$bmid));
my $deltar=sprintf("%.6f",$r-$pr);
my $deltavs=sprintf("%.0f",$totvs-$pvs);
my $ewma2 = sprintf("%.6f",fetchEWMA($xid,$deltar,2,$ewmaMap));
my $ewma5 = sprintf("%.6f",fetchEWMA($xid,$deltar,5,$ewmaMap));
my $ewma10 = sprintf("%.6f",fetchEWMA($xid,$deltar,10,$ewmaMap));
my $ewma20 = sprintf("%.6f",fetchEWMA($xid,$deltar,20,$ewmaMap));
my $ewma30 = sprintf("%.6f",fetchEWMA($xid,$deltar,30,$ewmaMap));
my $ewma40 = sprintf("%.6f",fetchEWMA($xid,$deltar,40,$ewmaMap));
my $ewma50 = sprintf("%.6f",fetchEWMA($xid,$deltar,50,$ewmaMap));
my $ewma60 = sprintf("%.6f",fetchEWMA($xid,$deltar,60,$ewmaMap));
my $ewma90 = sprintf("%.6f",fetchEWMA($xid,$deltar,90,$ewmaMap));
my $ewma120 = sprintf("%.6f",fetchEWMA($xid,$deltar,120,$ewmaMap));
print OUTF
"$xid,$te,$code,$ca,$cb,$ccp,$hp,$lp,$totvs,$r,$deltar,$deltavs,$ewma2,$ewma5,$ewma10,$ewma20,$ewma30,$ewma40,$ewma50,$ewma60,$ewma90,$ewma120\n";
$prevMap->{$xid}{ret}=$r;
$prevMap->{$xid}{totvs}=$totvs;
}
close(OUTF);
}
------------------------------
Date: Thu, 25 Jan 2007 23:14:08 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Hash of Hashes
Message-Id: <4Rauh.189578$YV4.69940@edtnps89>
doni wrote:
>
> 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
[ snip ]
> 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.
>
>
> ### Open the netstat file copied to this location ###
> my $ex_data = 'netstat.log';
> open (NETSTAT,$ex_data) || die("Cannot Open File: $!");
[ snip code ]
Perhaps you need something like this:
use warnings;
use strict;
### Open the netstat file copied to this location ###
my $ex_data = 'netstat.log';
open NETSTAT, $ex_data or die "Cannot Open $ex_data: $!";
my $state; # State Variable
my %stats = ( mac => undef, phy => undef, network => undef );
while ( <NETSTAT> ) {
if ( /^(\S+)\s+statistics:/ ) {
$state = lc $1;
}
if ( exists $stats{ $state } && /^\s+(\d+)\s+(.+)/ ) {
$stats{ $state }{ $2 } += $1;
}
}
close NETSTAT or die "Cannot close $ex_data: $!";
for my $key ( keys %stats ) {
print "$key statistics:\n";
for my $msg ( keys %{ $stats{ $key } } ) {
print "\t$stats{$key}{$msg} $msg\n";
}
}
__END__
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: Thu, 25 Jan 2007 23:38:33 -0000
From: Justin C <justin.0511@purestblue.com>
Subject: Re: loop won't run, for ( my $i = 10 ; $i == 1 ; etc
Message-Id: <slrnerifrp.98s.justin.0511@stigmata.purestblue.com>
On 2007-01-25, Paul Lalli <mritty@gmail.com> wrote:
> On Jan 25, 11:45 am, Justin C <justin.0...@purestblue.com> wrote:
>>
>> for ( my $pg_count = 15 ; $pg_count == 0 ; $pg_count-- ) {
>
> 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
Thank you Paul, and Cliff, for clear, concise answers. You're both,
obviously, spot on. I don't use this type of loop very often (whaddya
mean you can tell?) and I'm sure it'll come back and bite me again next
time.
Feel a bit of a fool!
Anyway, thanks again.
Justin.
--
Justin C by the sea.
------------------------------
Date: 25 Jan 2007 16:00:41 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: loop won't run, for ( my $i = 10 ; $i == 1 ; etc
Message-Id: <1169769641.585774.14550@a75g2000cwd.googlegroups.com>
On Jan 25, 4:38 pm, Justin C <justin.0...@purestblue.com> wrote:
> On 2007-01-25, Paul Lalli <mri...@gmail.com> wrote:
>
> > On Jan 25, 11:45 am, Justin C <justin.0...@purestblue.com> wrote:
>
> >> for ( my $pg_count = 15 ; $pg_count == 0 ; $pg_count-- ) {
>
> > 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
>
> Thank you Paul, and Cliff, for clear, concise answers.
> I don't use this type of loop very often
Nobody does, because it's very rare you can't use a Perl for:
C:\>perl -e "print qq[$_,] for reverse 0..15"
15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,
-jp
------------------------------
Date: Thu, 25 Jan 2007 17:12:29 -0800
From: Xiong Changnian <please@nospam.net>
Subject: Re: MacPerl, OS 9, move file to Trash
Message-Id: <please-E3D4B0.17122925012007@free.teranews.com>
In article <m2veiuu4o7.fsf@Sherm-Pendleys-Computer.local>,
Sherm Pendley <spamtrap@dot-app.org> wrote:
> Just renaming them should work.
It might. I'd really rather *move* files to Trash, rather that jigger
the system. Mac plays nice if you play nice with Mac.
> <http://bumppo.net/lists/macperl/1997/04/msg00079.html>
Yes, I read that post and its reply, too. It's about renaming to
faux-move. I've also read 2 or 3 discussions in other places reporting
problems with this approach.
I'd really prefer to get AppleScript calls working. Who knows, I may be
able to do something else with them.
> lists.perl.org
It's lists.cpan.org now. I've been subscribed to the original MacPerl
mailing list since 2004; it's dead, nobody ever posts, not even spam.
Almost all forum discussion -- no matter where it's held -- revolves
around MacPerl for OS X. This is a whole different animal, of course,
since OS X is just a wrapper around a unix-ish box.
I suppose I should subcribe to a half-dozen MacPerl OS X forums and
troll for solutions there. I'm still hoping somebody in this group has
some experience with OS 9.
--
Xiong Changnian
xiong102ATxuefangDOTcom
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Thu, 25 Jan 2007 20:54:27 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: MacPerl, OS 9, move file to Trash
Message-Id: <m2mz46tuwc.fsf@Sherm-Pendleys-Computer.local>
Xiong Changnian <please@nospam.net> writes:
> I suppose I should subcribe to a half-dozen MacPerl OS X forums and
> troll for solutions there. I'm still hoping somebody in this group has
> some experience with OS 9.
You *did* find someone in this group who has experience with MacOS 9, and
I gave you a good solution I've used myself quite often. It sounds like what
you were *really* hoping to find was someone who dislikes Mac OS X as much
as you do.
But whatever - if you'd prefer to ignore good advice simply because it's
from someone who's made a switch you won't make, that's your loss.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Fri, 26 Jan 2007 12:30:18 +1100
From: "Sisyphus" <sisyphus1@nomail.afraid.com>
Subject: Re: Net::FTPSSL problem (or how to do FTP over SSL another way?)
Message-Id: <45b959b9$0$5745$afc38c87@news.optusnet.com.au>
"DSIOMTW" <dsiomtw@gmail.com> wrote in message
news: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.
>
If you haven't already done so, turn on debugging in your script (by
specifying 'Debug => 1' in the constructor).
Also try applying the change provided at
http://rt.cpan.org/Public/Bug/Display.html?id=24136 .
And check the other bug reports at
http://rt.cpan.org/Public/Dist/Display.html?Name=Net-FTPSSL in case they
contain something relevant.
Sorry, I don't have access to an sftp server - so that's about the best I
can come up with.
Cheers,
Rob
------------------------------
Date: 25 Jan 2007 15:42:29 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Statistics Extraction
Message-Id: <87ireu3ezu.fsf@aragorn.emschwar>
"doni" <doni.sekar@gmail.com> writes:
> 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
It's not clear from this example what the second-level key is. Is it
the MAC address itself, or simply the index in which it occurred in
the file? If the former, then it makes sense to keep it as a hash,
but if the latter, why not:
$mac{'frames with invalid header'} = [ 1, 13, 28, ... 9 ];
That is, the hash points to an arrayref, where the value of the array
at any position is the number of frames for the MAC at that position.
In your example, it would be the equivalent of doing:
$mac{'frames with invalid header'}{1} = 1
$mac{'frames with invalid header'}{2} = 13
....... $mac{'frames with invalid header'}{10} = 9
> 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.
It would help if you could include some data in the example, using the
__DATA__ keyword. And you could please let us know what it did, what
you expected, and how they differ-- almost nobody is interested in
figuring all that out for you.
But:
you start off missing:
#!/usr/bin/perl
use warnings;
use strict;
> ### Open the netstat file copied to this location ###
> my $ex_data = 'netstat.log';
> open (NETSTAT,$ex_data) || die("Cannot Open File: $!");
Excellent! In particular, congrats for putting the 'die' in there,
and for putting the $! variable in its argument. You might consider
using the more idiomatic 'or die ....', and the three-arg form of
open, but those are style issues, and not relevant to the program's
functionality:
open my $netstat, '<', $ex_data or 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
Why not a single top-level hash %stats that you can treat like so:
$stats{mac}{'frames with invalid header'}[0];
or
$stats{phy}{'retransmitted frames'}[7];
? It is not a big deal, just a thought.
> my $stats; # State Variable
This is a bit of a confusing variable name. Maybe you could name it
$stat_type or something a bit more clear?
> 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
When I see all those different one-letter count variables, it hurts my
brain. Especially when after I read your code, they're completely
unnecessary. Instead, I recomment you use an array, and simply append
to it.
> while (<NETSTAT>) {
> chomp;
> if (/^(\S+)\s+statistics:/) {
> $stats = $1;
You can delete everything from here:
> if ($stats =~ /mac/i)
> { $i++; }
> elsif ($stats =~ /phy/i)
> { $j++; }
> else
> { $a++; }
> }
To here. That section is confusingly indented, as is the rest of your
code, so you should look into some automatic indentation-fixer, or at
least try to manually line things up according to a style. 'perldoc
perlstyle' is helpful here, but it's only one option among many-- all
that really matters is that you're consistent in your indentation
style, not so much which one you pick.
> elsif (/^\s+(\d+)\s+(\S.*)/)
> {
> ($value, $key) = ($1, $2);
> if ($stats =~ /mac/i) {
> next unless defined $stats;
> $mac{$key}{$i} = $value;
You can replace this line (and the one above, which increments $i) with:
push @{$mac{$key}}, $value;
Or, if you collect all your stats into one top-level hash:
push @{$stats{mac}{$key}}, @value;
> }
> if ($stats =~ /phy/i) {
> next unless defined $stats;
> $phy{$key}{$j} = $value;
Likewise,
push @{$phy{$key}}, $value;
> }
> if ($stats =~ /network/i) {
> next unless defined $stats;
> $network{$key}{$a} = $value;
and
push @{$network{$key}}, $value;
> }
> }
> else { }
> }
>
> foreach $key (keys (%mac)) {
> foreach $x (keys %{$mac{$key} })
This is bad, because you don't know the order that you'll get from
'keys' here. At the very least you need 'sort keys'. Also, you have
an extra set of parentheses around %mac at the first 'foreach'.
Or, if you use my suggestion above, which I recommend:
foreach my $type, (keys %stats) {
print "$type stats:\n";
foreach my $message (keys %{$stats{$type}}) {
print "\tmessage is: $message\n";
for my $val (@{$mac{$stat_type}}) {
print "\t\tMessage value is: $val\n";
}
}
}
> {
> while ($x <= $i) {
> print "Message Value is: $mac{$key}{$i}\n";
> $i++;
> }
>
> }
> }
> close(NETSTAT) || die("Cannot close $ex_data: $!");
This 'close' should go at the end of the loop which reads from the
filehandle-- just before the 'foreach' which prints them out in your
example.
Let me please say again that the message in which you gave an example
of your data is 8 messages before this one, and I just happened to get
lucky that it was still on my newsserver. If you want the most help
possible, you really need to post, with your example code, an example
of the data you're working on, what you get when you run your code on
it, and what you expected, and how they are different.
-=Eric
------------------------------
Date: 25 Jan 2007 15:51:58 -0800
From: "LtCommander" <LtCommander@gmail.com>
Subject: String Substitution question
Message-Id: <1169769118.637900.95110@m58g2000cwm.googlegroups.com>
This could be a stupid question but I am really stuck!
I am doing
$content=~ s/$m//sig;
The problem is that $m may have all sorts of escape sequence
characters, brackets and so on. So, sometimes, $content doesn't have
$match removed. So, I do this:
$m =~ s/\(/\\(/sig;
$m =~ s/\)/\\)/sig;
$m =~ s/\[/\\[/sig;
$m =~ s/\]/\\]/sig;
$m =~ s/\?/\\?/sig;
$m =~ s/\*/\\*/sig;
$m =~ s/\./\\./sig;
$m =~ s/\$/\\\$/sig;
$m =~ s/\+/\\+/sig;
$m =~ s/\_/\\_/sig;
$m =~ s/\-/\\-/sig;
and then
$content=~ s/$m//sig;
Is there a better way of doing this?
Thanks a lot for any help.
VInce
------------------------------
Date: Fri, 26 Jan 2007 01:10:16 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: String Substitution question
Message-Id: <epbh7b$ge4$1@mlucom4.urz.uni-halle.de>
LtCommander wrote:
> I am doing
> $content=~ s/$m//sig;
>
> The problem is that $m may have all sorts of escape sequence
> characters, brackets and so on. So, sometimes, $content doesn't have
> $match removed. So, I do this:
>
> $m =~ s/\(/\\(/sig;
> ...
> $m =~ s/\-/\\-/sig;
> and then
> $content=~ s/$m//sig;
try:
my @stuff = qw'( ) [ ] ? * . $ + _ -';
my $m = join '|', map "\Q$_\E", @stuff;
$content =~ s/$m//g;
maybe it does what you want ...
Regards
M.
------------------------------
Date: Fri, 26 Jan 2007 01:22:55 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: String Substitution question
Message-Id: <epbhv3$gjl$1@mlucom4.urz.uni-halle.de>
Mirco Wahab wrote:
> LtCommander wrote:
>> I am doing
>> $content=~ s/$m//sig;
>>
>> The problem is that $m may have all sorts of escape sequence
>> characters, brackets and so on. So, sometimes, $content doesn't have
>> $match removed. So, I do this:
>>
>> $m =~ s/\(/\\(/sig;
>> ...
>> $m =~ s/\-/\\-/sig;
>> and then
>> $content=~ s/$m//sig;
>
> try:
>
> my @stuff = qw'( ) [ ] ? * . $ + _ -';
> my $m = join '|', map "\Q$_\E", @stuff;
>
> $content =~ s/$m//g;
the above looks somehow inefficient after a moment - ,
so better try (Perl's '|' alternation is slow)
my @stuff = qw'( ) [ ] ? * . $ + _ -';
my $m = '[' . (join '', map quotemeta, @stuff) . ']';
$content =~ s/$m//g;
Regards
M.
------------------------------
Date: 25 Jan 2007 16:39:46 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: String Substitution question
Message-Id: <1169771986.417198.197480@q2g2000cwa.googlegroups.com>
On Jan 25, 6:51 pm, "LtCommander" <LtComman...@gmail.com> wrote:
> This could be a stupid question but I am really stuck!
>
> I am doing
> $content=~ s/$m//sig;
>
> The problem is that $m may have all sorts of escape sequence
> characters, brackets and so on. So, sometimes, $content doesn't have
> $match removed. So, I do this:
>
> $m =~ s/\(/\\(/sig;
> $m =~ s/\)/\\)/sig;
> $m =~ s/\[/\\[/sig;
> $m =~ s/\]/\\]/sig;
> $m =~ s/\?/\\?/sig;
> $m =~ s/\*/\\*/sig;
> $m =~ s/\./\\./sig;
> $m =~ s/\$/\\\$/sig;
> $m =~ s/\+/\\+/sig;
> $m =~ s/\_/\\_/sig;
> $m =~ s/\-/\\-/sig;
> and then
> $content=~ s/$m//sig;
>
> Is there a better way of doing this?
Dear god yes.
Just do:
$content =~ s/\Q$m\E//sig;
Look up what that does in:
perldoc -f quotemeta
perldoc perlre
Paul Lalli
------------------------------
Date: 25 Jan 2007 19:01:39 -0600
From: Lawrence Statton XE2/N1GAK <yankeeinexile@gmail.com>
Subject: Re: String Substitution question
Message-Id: <87d552k3d8.fsf@gmail.com>
"LtCommander" <LtCommander@gmail.com> writes:
>
> $m =~ s/\(/\\(/sig;
> $m =~ s/\)/\\)/sig;
> $m =~ s/\[/\\[/sig;
> $m =~ s/\]/\\]/sig;
> $m =~ s/\?/\\?/sig;
> $m =~ s/\*/\\*/sig;
> $m =~ s/\./\\./sig;
> $m =~ s/\$/\\\$/sig;
> $m =~ s/\+/\\+/sig;
> $m =~ s/\_/\\_/sig;
> $m =~ s/\-/\\-/sig;
OH! I see it, it's a pony!
--
Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer software consists of only two components: ones and
zeros, in roughly equal proportions. All that is required is to
place them into the correct order.
------------------------------
Date: 25 Jan 2007 15:14:46 -0800
From: usenet@DavidFilmer.com
Subject: Re: Style questions
Message-Id: <1169766886.686542.231950@h3g2000cwc.googlegroups.com>
On Jan 25, 2:52 pm, Sherm Pendley <spamt...@dot-app.org> wrote:
> perldoc perlstyle
I also recommend killing some trees and getting "Perl Best Practices"
by Daminan Conway, which has many sensible stylistic guidelines.
--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 25 Jan 2007 23:25:33 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Style questions
Message-Id: <slrnerif36.tcf.abigail@alexandra.abigail.be>
Colin B. (cbigam@somewhereelse.nucleus.com) wrote on MMMMDCCCXCV
September MCMXCIII in <URL:news:45b93355@news.nucleus.com>:
`' Hey all;
`'
`' I'm not a programmer, and never have been. I can grind out a decent shell
`' script, and beat my head against perl until things work, but I'm seldom
`' happy with the inelegance of the solution. Does anyone have any good style
`' guides for perl?
`'
`' And more specifically, I've got the following general case that keeps coming
`' up routinely.
`'
`' foreach (`some_unix_command_that_puts_out_multiple_lines`) {
`' chomp;
`' split;
`' (do_stuff_on_the_separate_fields);
`' }
`'
`' Anything to fix up there?
Not really. Except that using split in void context is deprecated
(if you have warnings turned on, Perl will tell you).
Abigail
--
CHECK {print "another "}
INIT {print "Perl " }
BEGIN {print "Just " }
END {print "Hacker\n"}
------------------------------
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 76
*************************************