|
|
Up |
|
|
  |
Author: Keith KellerKeith Keller
Date: Oct 3, 2006 22:20
["Followup-To:" header set to comp.lang.perl.misc.]
On 2006-10-04, Todd English gmail.com> wrote:
[> Tad McClellan wrote:]
Please don't snip attributions!
> Very astute observation. I use Google to post because it is convenient.
> However both my work and home isp's news servers list perl.beginners as
> a valid group. I readily accept that yours doesn't and you couldn't
> post your TOFU comments to a nonexistent group.
Did you read the rest of Tad's comments about perl.beginners? It's
a mailing list gated to usenet, not a real newsgroup. Often posts
to those pseudogroups get sent to the bitbucket, either by your
own newsserver or by the mailing list in question. If you look at the
real archive (at http://www.nntp.perl.org/group/perl.beginners/) you'll
see your posts are not there. (Why Google groups misleadingly shows
them is beyond me.) If you want an answer from there, subscribe to the
mailing list.
It seems like you're making progress with your problem here, so if
you haven't read the Posting Guidelines, drop perl.beginners, and good
luck resolving the issue.
|
| Show full article (1.29Kb) |
|
| |
no comments
|
|
  |
Author: attn.steven.kuoattn.steven.kuo
Date: Oct 3, 2006 22:16
John W. Krahn wrote:
(snipped)
>>
>> If I recall correctly, it isn't a good idea to delete
>> and add keys to a hash while iterating over it.
>
> "for my $key ( keys %%hash )" creates a list of the hash keys in memory and any
> modifications to %%hash inside the loop won't affect the contents of that list.
>
> perldoc -f delete
Sorry, my recollection was indeed faulty.
I was thinking of the 'each' function used
to iterate over a hash.
--
Regards,
Steven
|
| |
|
| |
no comments
|
|
  |
Author: smsm
Date: Oct 3, 2006 22:04
Hi Folks,
I do not know if this is the right place for this. I am writing a "Perl TK
script that runs on windows and
have been trying to print add a *print* capability to for the UI. I have
found *Win32::Printer*, *Win32::Printer::Direct*
I have attempted:
1- to get the user selected *printer name* from the *Win32::Printer* to
use in *Win32::Printer::Direct*
In this attempt, I have not found a way of getting the *printer
name* form *Win32::Printer* after user
selects a printer.
2- I can not find a way of get the selected file name or file handle to
*Win32::Printer*
I my attempts have been based on the sample code provided in the pod.
Any help is greatly appreciated.
Best regards,
-sm
|
| |
|
no comments
|
|
  |
Author: Tad McClellanTad McClellan
Date: Oct 3, 2006 21:28
Eric Schwartz pobox.com> wrote:
> I'd still use the if-else
> equivalent (and cuddle the else too! Bwahahahah!) just because I
^
> think it's more readable.
^^^^^
If you are the only person who reads your code, then that is
a very sensible criterion.
You are in an enviable position. Most of us have to consider
other programmers when we write programs, where the criterion
is what do most people think is more readable.
--
Tad McClellan SGML consulting
tadmc@ augustmail.com Perl programming
Fort Worth, Texas
|
| |
|
no comments
|
|
  |
Author: Keith KellerKeith Keller
Date: Oct 3, 2006 20:23
On 2006-10-04, John W. Krahn example.com> wrote:
>> John W. Krahn wrote:
>>>
>>>for my $key ( keys %%hash ) {
>>> for my $flavour ( @{ delete $hash{ $key } } ) {
>>> push @{ $hash{ $flavour } }, $key;
>>> }
>>> }
>>
>> If I recall correctly, it isn't a good idea to delete
>> and add keys to a hash while iterating over it.
>
> "for my $key ( keys %%hash )" creates a list of the hash keys in memory and any
> modifications to %%hash inside the loop won't affect the contents of that list.
>
> perldoc -f delete
|
| Show full article (0.92Kb) |
|
no comments
|
|
  |
Author: Mumia W. (reading news)Mumia W. (reading news)
Date: Oct 3, 2006 19:31
On 10/03/2006 07:20 PM, robb@ acm.org wrote:
> Mumia W. (reading news) wrote:
>> package MyLogWrapper;
>> use strict;
>> use warnings;
>> use LogForPerl; # Placeholder for Log::Log4perl
>>
>> BEGIN {
>> LogForPerl->init('/ path/to/log.conf');
>> }
>>
>> sub get_logger {
>> LogForPerl->get_logger('MyPackage::MySubPackage');
>> }
>>
>> __END__
>>
>
> But the point is that it should be usable from many packages. And, I
> don't want to have code inside a package which hardcodes the package ...
|
| Show full article (1.04Kb) |
|
no comments
|
|
  |
Author: John W. KrahnJohn W. Krahn
Date: Oct 3, 2006 19:30
> John W. Krahn wrote:
>>
>>for my $key ( keys %%hash ) {
>> for my $flavour ( @{ delete $hash{ $key } } ) {
>> push @{ $hash{ $flavour } }, $key;
>> }
>> }
>
> If I recall correctly, it isn't a good idea to delete
> and add keys to a hash while iterating over it.
"for my $key ( keys %%hash )" creates a list of the hash keys in memory and any
modifications to %%hash inside the loop won't affect the contents of that list.
perldoc -f delete
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
|
| |
|
no comments
|
|
  |
Author: PerlFAQ ServerPerlFAQ Server
Date: Oct 3, 2006 18:03
This is an excerpt from the latest version perlfaq3.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .
--------------------------------------------------------------------
3.11: Where can I get Perl macros for vi?
For a complete version of Tom Christiansen's vi configuration file, see
http://www.cpan.org/authors/Tom_Christiansen/scripts/toms.exrc.gz , the
standard benchmark file for vi emulators. The file runs best with nvi,
the current version of vi out of Berkeley, which incidentally can be
built with an embedded Perl interpreter--see
http://www.cpan.org/src/misc/ .
--------------------------------------------------------------------
|
| Show full article (1.47Kb) |
|
no comments
|
|
  |
Author: Tad McClellanTad McClellan
Date: Oct 3, 2006 17:53
Mumia W. (reading news) earthlink.net> wrote:
> On 10/03/2006 09:33 AM, Jack wrote:
>> if ($target[$i] =~ m/$temparray2[0]/i) { print " match "; }
^
^
> if (index($target[$i],$temparray2[0]) >= 0) { print " match "; }
if (index(lc $target[$i], lc $temparray2[0]) >= 0) { print " match "; }
(which could become painful in a big loop...)
--
Tad McClellan SGML consulting
tadmc@ augustmail.com Perl programming
Fort Worth, Texas
|
| |
|
no comments
|
|
  |
|
|
  |
Author: Tad McClellanTad McClellan
Date: Oct 3, 2006 17:50
Jim Gibson mail.arc.nasa.gov> wrote:
>
> I recently complained about the lack of alternate approaches to the FAQ
> "How do I change one line in a file/delete a line in a file/insert a
> line in the middle of a file/append to the beginning of a file?"
> Here is my first attempt at a more complete answer. Comments are
> invited.
> You can use a Perl "one-liner" with command-line switches to modify
> a file (see perlrun).
And you can do it in a file-based program with the $^I variable,
or with the -i command-line switch.
If you want to do it in a program file rather than as a one-liner,
then be sure to local()ize the special variables into an appropriate
scope:
|
| Show full article (3.63Kb) |
|
no comments
|
|
|
|
|
|
|