[25728] in Perl-Users-Digest
Perl-Users Digest, Issue: 7968 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 12 14:05:22 2005
Date: Tue, 12 Apr 2005 11:05:10 -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 Tue, 12 Apr 2005 Volume: 10 Number: 7968
Today's topics:
(the simplest question of the century ?) Simple acces <Milca@laposte.net>
Re: [perl-python] Python documentation moronicities (co <richard@zync.co.uk>
Re: [perl-python] Python documentation moronicities (co <peter@engcorp.com>
Re: Basic question about web programming jilerner@yahoo.com
Re: Client socket programming eating up CPU/memory <1usa@llenroc.ude.invalid>
Re: Client socket programming eating up CPU/memory xhoster@gmail.com
Re: FAQ 3.28 Where can I learn about linking C with Per xhoster@gmail.com
Re: not $x respecting numeric 0 jilerner@yahoo.com
Re: Perl function for negative integers using the 2's c <liam@nedernet.net>
Re: Regex and detection on dhcpd.conf file (MaXX)
Re: Regex and detection on dhcpd.conf file <tzz@lifelogs.com>
Remote command execution (be_tnt)
Re: Remote command execution <phaylon@dunkelheit.at>
Re: Remote command execution jilerner@yahoo.com
Re: Remote command execution <matternc@comcast.net>
Re: Remote command execution <matternc@comcast.net>
s/(.)/($1)/g vs s/(.)/$to/eg where $to='($1)' jilerner@yahoo.com
Re: s/(.)/($1)/g vs s/(.)/$to/eg where $to='($1)' <skuo@mtwhitney.nsc.com>
Re: s/(.)/($1)/g vs s/(.)/$to/eg where $to='($1)' <jgibson@mail.arc.nasa.gov>
Re: s/(.)/($1)/g vs s/(.)/$to/eg where $to='($1)' <nobull@mail.com>
Re: Simple Encryption Script <tadmc@augustmail.com>
Re: Simple Encryption Script <RedGrittyBrick@SpamWeary.foo>
Troubleshooting printing to file EmmettPower@gmail.com
Re: Troubleshooting printing to file <noreply@gunnar.cc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 12 Apr 2005 18:58:12 +0200
From: Milca <Milca@laposte.net>
Subject: (the simplest question of the century ?) Simple access to ... ACCESS !
Message-Id: <d3gtgq$c3n$1@s1.news.oleane.net>
Hi all,
I'm a (or "one more") newcomer in Perl, and ask for very basic help.
Despite some time spent to read all this forum and some CPAN docs, I've
not found a simple explanation of my request however simple.
I'd like to access - read only is sufficient for the beginning - to an
MS ACCESS database from perls scripts. I'm on Win 2K.I'd like to make
simple SQL or SQL-like queries (is that a pure dream ?) :seeing my
tables, seeing the data of each table, bing able to select elementary
data in tables, and even not necessarily with joining them. ... Truly a
"basic access to ACCESS" !
... And (to be complete) I would like to use these perl scripts from
"unix style" command lines inside a "cygnus" bash shell ... But this
detail is probably useless.
Well, I spent some time trying to configure an ODBC driver found into
the admin tools of Windows. I have "declared" a specific ".mdb" file as
ODBC souce. I have used another tool (WinBatch) which can has sample
scripts for ODBC use and which can normally detect ODBC sources.
This script correctly sees my file as ODBC proposed source. But cannot
access to it. That's why I would like to make this access from Perl scripts.
I have no "SQL server" neither "anything else server" running on my
machine. Should I ? Should I use Win32::OLE ? DBD ? DBI ? ODBC ? or
maybe SHXK::-[~#GMKX ?
What is all the stuff to install / configure / run to finally get this
simple result : simply querying a simple database ?
TIA,
Micla.
------------------------------
Date: Tue, 12 Apr 2005 15:45:24 +0000
From: Richard Gration <richard@zync.co.uk>
Subject: Re: [perl-python] Python documentation moronicities (continued)
Message-Id: <pan.2005.04.12.15.45.23.858905@zync.co.uk>
On Tue, 12 Apr 2005 04:02:20 -0700, Joe Smith wrote:
> Xah Lee wrote:
>
>> of motherf***ing irrevalent drivel?
>
> I am greatly amused.
> A troll impersonating Xah Lee has made xah look like a total moron. LOL
"The fucking doc cannot be possibly fucking worsely written."
This is very Xahish though, even if it's not him.
It's right up there with "AND, the writting as usuall is fantastic
incompetent."
------------------------------
Date: Tue, 12 Apr 2005 12:22:37 -0400
From: Peter Hansen <peter@engcorp.com>
Subject: Re: [perl-python] Python documentation moronicities (continued)
Message-Id: <FKydnWjMkrRTaMbfRVn-3g@powergate.ca>
Joe Smith wrote:
> Xah Lee wrote:
>> of motherf***ing irrevalent drivel?
>
> I am greatly amused.
> A troll impersonating Xah Lee has made xah look like a total moron.
> LOL
Sorry, Joe, but why do you think this wasn't Xah?
Every detail of the post is consistent with his
recent postings.
And a secondary, but purely rhetorical, question:
how could the post have made him look like a moron
when he already looked like one?
------------------------------
Date: 12 Apr 2005 07:11:16 -0700
From: jilerner@yahoo.com
Subject: Re: Basic question about web programming
Message-Id: <1113315076.678744.55490@z14g2000cwz.googlegroups.com>
Try wget
Yakov
------------------------------
Date: Tue, 12 Apr 2005 13:12:41 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Client socket programming eating up CPU/memory
Message-Id: <Xns96365DA2491A6asu1cornelledu@127.0.0.1>
"Stryder" <stryder22204@gmail.com> wrote in
news:1113309119.624804.111290@z14g2000cwz.googlegroups.com:
> ========================= CODE ==============================
use strict;
use warnings;
> use IO::Socket;
> use IO::Handle;
>
> ############## irrelevant code populating @unaps here
>
> my $paddr = sockaddr_in(9000, inet_aton('127.0.0.1')) || die
> "sockaddr_in error: $!";
Why?
> my $buff;
You should declare variables in the smallest applicable scope.
> foreach $unap ( @unaps ) {
for my $unap ( @unaps ) {
> $remote = IO::Socket::INET->new(
my $remote = ...;
> Proto => "tcp",
> PeerAddr => '127.0.0.1',
> PeerPort => 9000,
> );
> unless ($remote) { die "cannot connect to http daemon on $host" }
> $remote->autoflush(1);
>
> print $remote "$unap\x0d\x0a";
See, we have no idea what $unap is.
> $buff = <$remote>;
Probably my $buf = ...;
> while (<$remote>) {}
Well, do you know if the server ever stops sending data?
> close $remote;
> print "$buff\n";
> }
It is very hard for me to figure out what the real problem is because
there is no way to test this. Why not try and come up with the shortest
possible script that still exhibits the problem.
Please do read the posting guidelines for this group for valuable
information on how you can help others help you.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 12 Apr 2005 17:14:23 GMT
From: xhoster@gmail.com
Subject: Re: Client socket programming eating up CPU/memory
Message-Id: <20050412131423.592$ai@newsreader.com>
"Stryder" <stryder22204@gmail.com> wrote:
> ========================= CODE ==============================
> use IO::Socket;
> use IO::Handle;
>
> ############## irrelevant code populating @unaps here
>
> my $paddr = sockaddr_in(9000, inet_aton('127.0.0.1')) || die
> "sockaddr_in error: $!";
What does this do?
> my $buff;
>
> foreach $unap ( @unaps ) {
You should use strict, not that that matters.
> $remote = IO::Socket::INET->new(
> Proto => "tcp",
> PeerAddr => '127.0.0.1',
> PeerPort => 9000,
> );
> unless ($remote) { die "cannot connect to http daemon on $host" }
There is not variable named $host used elsewhere in your code.
> $remote->autoflush(1);
>
> print $remote "$unap\x0d\x0a";
> $buff = <$remote>;
> while (<$remote>) {}
> close $remote;
> print "$buff\n";
> }
There is nothing in this code that would prevent it from using all the CPU
it can get, other than slowness on the part of the other end of the socket.
> ========================= END CODE ==============================
>
> Here's the "top" readout. Each of these readings is just a few seconds
> apart.
>
> 20001 gatekeep 1 10 0 27M 27M cpu/1 0:06 11.93% perl
> 20001 gatekeep 1 30 0 30M 29M run 0:07 13.25% perl
> 20001 gatekeep 1 10 0 32M 32M cpu/2 0:08 14.21% perl
> 20001 gatekeep 1 30 0 34M 34M cpu/2 0:08 15.01% perl
> 20001 gatekeep 1 20 0 36M 35M run 0:09 15.89% perl
...
> I'm hoping this is just something dumb I'm not understanding about
> this. Any help would be VERY appreciated.
My guess is that the problem is in your server, not your client. If the
server is throwing increasing amounts of crap at the client, the client
needs to use increasing amounts of CPU and memory to deal with it.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 12 Apr 2005 17:15:58 GMT
From: xhoster@gmail.com
Subject: Re: FAQ 3.28 Where can I learn about linking C with Perl? [h2xs, xsubpp]
Message-Id: <20050412131558.470$BG@newsreader.com>
PerlFAQ Server <comdog@panix.com> wrote:
> This message is one of several periodic postings to comp.lang.perl.misc
> intended to make it easier for perl programmers to find answers to
> common questions. The core of this message represents an excerpt
> from the documentation provided with Perl.
>
> --------------------------------------------------------------------
>
> 3.28: Where can I learn about linking C with Perl? [h2xs, xsubpp]
>
> If you want to call C from Perl, start with perlxstut, moving on to
> perlxs, xsubpp, and perlguts. If you want to call Perl from C, then
> read perlembed, perlcall, and perlguts. Don't forget that you can
> learn a lot from looking at how the authors of existing extension
> modules wrote their code and solved their problems.
>
> --------------------------------------------------------------------
Isn't Inline::C worth a mention?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 12 Apr 2005 08:01:40 -0700
From: jilerner@yahoo.com
Subject: Re: not $x respecting numeric 0
Message-Id: <1113318100.807599.259360@f14g2000cwb.googlegroups.com>
You essentially ask 'how to make the condition in if() look
simpler/shorter'.
One answer is:
if(!Empty($x)) { ... }
where Empty() is defined as
sub Empty { return ! defined($_[0]) || $_[0] eq ''; }
Another possibility (in your specific case where you treat
undef and '' same way ) would be make sure your
variables are not undefined:
$x = '' if !defined($x);
...
if( $x ne '') ...
YL
------------------------------
Date: 12 Apr 2005 06:28:10 -0700
From: "stylechief" <liam@nedernet.net>
Subject: Re: Perl function for negative integers using the 2's complement in hex?
Message-Id: <1113312490.555615.102390@o13g2000cwo.googlegroups.com>
Thanks to all for your time and consideration. The solution that I was
seeking:
open (BINFILE, "<000332") || die "Cant open: $!\n";
while(read(BINFILE, $data, 3)){
$data=hex(unpack 'H*',$data);
if ($data & 0x800000) {$data |= 0xff000000};
printf "%d \n", $data;
}
close (BINFILE) || die "Cant close: $!\n";
Unless there is yet a more efficient method . . . .
------------------------------
Date: 12 Apr 2005 07:40:49 -0700
From: romain.daumont@int-evry.fr (MaXX)
Subject: Re: Regex and detection on dhcpd.conf file
Message-Id: <aa422dac.0504120640.7747e0d7@posting.google.com>
Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote in message news:<d3g5ak$eu4$1@nntp.fujitsu-siemens.com>...
> MaXX wrote:
> > Hi,
> >=20
> > I try to extract a information (mac address) in a file dhcpd.conf. I
> > don't manage to detect the field "hardware ethernet" and extract the
> > values which follow (values hex). But, i know, for example, "toto" in
> > the field "host".
> >=20
> >=20
> > So, my file is composed : =20
> >=20
> > host toto {
> > hardware ethernet 00:05:5b:22:55:96;
> > fixed-address 192.168.21.55;
> > }
> > host titi {
> > hardware ethernet 00:B0:DD:D7:FF:78;
> > fixed-address 192.168.21.56;
> > }
> > etc...
> >=20
> > if you have a idea...
>
> Read the file line-by-line looking for the host line.
> If you find the host line, start looking for the hardware ethernet line.
>
> my $hostfound =3D 0;
> my $host =3D 'toto';
> while (<DHCPD_CONF>) {
> if (!$hostfound) {
> if (/^\s*host\s+$host\b/) {
> $hostfound =3D 1;
> }
> next;
> } elsif (/^\s+hardware\s+ethernet\s+(\S+)\s*;/) {
> print "$1\n";
> last;
> } elsif (/^\s*}/) {
> last;
> }
> }
>
> --=20
> Josef M=F6llers (Pinguinpfleger bei FSC)
> If failure had no penalty success would not be a prize
> -- T. Pratchett
Thanks! I m going to try this method.
------------------------------
Date: Tue, 12 Apr 2005 13:34:45 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Regex and detection on dhcpd.conf file
Message-Id: <4nvf6ryk3u.fsf@lifelogs.com>
On 12 Apr 2005, romain.daumont@int-evry.fr wrote:
> I try to extract a information (mac address) in a file dhcpd.conf. I
> don't manage to detect the field "hardware ethernet" and extract the
> values which follow (values hex). But, i know, for example, "toto" in
> the field "host".
>
>
> So, my file is composed :
>
> host toto {
> hardware ethernet 00:05:5b:22:55:96;
> fixed-address 192.168.21.55;
> }
> host titi {
> hardware ethernet 00:B0:DD:D7:FF:78;
> fixed-address 192.168.21.56;
> }
Do regex matching with the /s flag. Do "perldoc perlre" for more
information on this flag and the others available.
Ted
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my $data = join '', <DATA>;
my %host2ether = ($data =~ m/host\s+(\S+).*?hardware\s+ethernet\s+(\S+);/sg);
print Dumper \%host2ether;
__DATA__
host toto {
hardware ethernet 00:05:5b:22:55:96;
fixed-address 192.168.21.55;
}
host titi {
hardware ethernet 00:B0:DD:D7:FF:78;
fixed-address 192.168.21.56;
}
OUTPUT:
$VAR1 = {
'toto' => '00:05:5b:22:55:96',
'titi' => '00:B0:DD:D7:FF:78'
};
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
------------------------------
Date: 12 Apr 2005 07:02:51 -0700
From: decoker@lucent.com (be_tnt)
Subject: Remote command execution
Message-Id: <94944999.0504120602.68e5e8d4@posting.google.com>
Hello,
Is it possible with Perl to execute a command on a remote system?
Thx!
------------------------------
Date: Tue, 12 Apr 2005 16:06:50 +0200
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: Remote command execution
Message-Id: <pan.2005.04.12.14.06.50.87959@dunkelheit.at>
be_tnt wrote:
> Is it possible with Perl to execute a command on a remote system?
Yes[1].
> Thx!
You're welcome.
p
[1] More Details? More Details! or have a look at CPAN on search.cpan.org
--
http://www.dunkelheit.at/
thou shallst fear...
------------------------------
Date: 12 Apr 2005 07:10:06 -0700
From: jilerner@yahoo.com
Subject: Re: Remote command execution
Message-Id: <1113315006.099482.312010@z14g2000cwz.googlegroups.com>
read about ssh , then do
system("ssh ....");
in perl
------------------------------
Date: Tue, 12 Apr 2005 13:48:08 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Remote command execution
Message-Id: <stqdneXSKbZElMHfRVn-hw@comcast.com>
be_tnt wrote:
> Hello,
>
> Is it possible with Perl to execute a command on a remote system?
>
> Thx!
Provided the remote system is running a service to execute commands
submitted remotely, yes. (If not, it'll be difficult for anything to run
commands remotely, unless you can contact the machine via magic
telepathy). Exactly how you might do this would depend on what
service the system is running.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Tue, 12 Apr 2005 13:51:20 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Remote command execution
Message-Id: <stqdneTSKbYFl8HfRVn-hw@comcast.com>
jilerner@yahoo.com wrote:
> read about ssh , then do
> system("ssh ....");
> in perl
One: He's told us nothing about the remote system. If it's not running
sshd, ssh isn't gonna do him much good.
Two: Why screw around with system() when you have Net::SSH::Perl?
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: 12 Apr 2005 06:55:05 -0700
From: jilerner@yahoo.com
Subject: s/(.)/($1)/g vs s/(.)/$to/eg where $to='($1)'
Message-Id: <1113314105.226381.203790@o13g2000cwo.googlegroups.com>
I'm looking for the solution with s/from/to/ when the to-part
comes from ARGV and references the $1. I tried /e and /ee
but still can't get this right.
Here's simlpified example. I need to get equivalent
of s/(.)/($1)/g , the difference being that the (the ($1))
comes from the variable: $to='($1)';
$_="abc"; s/(.)/($1)/g; # this does what I want -> "(a)(b)(c)"
$to='($1)';
$_="abc"; s/(.)/$to/g; # does not do what I want, I want result to be
"(a)(b)(c)"
$_="abc"; s/(.)/$to/ge; # does not do what I want
$_="abc"; s/(.)/$to/gee; # does not do what I want
Yakov
------------------------------
Date: Tue, 12 Apr 2005 09:17:07 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: s/(.)/($1)/g vs s/(.)/$to/eg where $to='($1)'
Message-Id: <Pine.GSO.4.21.0504120916001.24797-100000@mtwhitney.nsc.com>
On 12 Apr 2005 jilerner@yahoo.com wrote:
(snipped)
> I need to get equivalent
> of s/(.)/($1)/g , the difference being that the (the ($1))
> comes from the variable: $to='($1)';
>
> $_="abc"; s/(.)/($1)/g; # this does what I want -> "(a)(b)(c)"
> $to='($1)';
> $_="abc"; s/(.)/$to/g; # does not do what I want, I want result to be
> "(a)(b)(c)"
> $_="abc"; s/(.)/$to/ge; # does not do what I want
> $_="abc"; s/(.)/$to/gee; # does not do what I want
Here's one way:
$_ = "abc";
my $to = '"($1)"';
s/(.)/$to/eeg;
print;
--
Hope this helps,
Steven
------------------------------
Date: Tue, 12 Apr 2005 09:54:18 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: s/(.)/($1)/g vs s/(.)/$to/eg where $to='($1)'
Message-Id: <120420050954186886%jgibson@mail.arc.nasa.gov>
In article <1113314105.226381.203790@o13g2000cwo.googlegroups.com>,
<jilerner@yahoo.com> wrote:
> I'm looking for the solution with s/from/to/ when the to-part
> comes from ARGV and references the $1. I tried /e and /ee
> but still can't get this right.
>
> Here's simlpified example. I need to get equivalent
> of s/(.)/($1)/g , the difference being that the (the ($1))
> comes from the variable: $to='($1)';
>
> $_="abc"; s/(.)/($1)/g; # this does what I want -> "(a)(b)(c)"
> $to='($1)';
> $_="abc"; s/(.)/$to/g; # does not do what I want, I want result to be
> "(a)(b)(c)"
> $_="abc"; s/(.)/$to/ge; # does not do what I want
> $_="abc"; s/(.)/$to/gee; # does not do what I want
Please use whitespace more effectively when posting code. The above is
rather hard to read.
While it looks to be a bit of a kludge, the following does seem to do
what you want:
my $to = '"(".$1.")"';
The problem is that the parthenses get evaluated out by the /e
modifiers, so need to be protected by quotes. There may be better
solutions.
Complete program:
#!/usr/local/bin/perl
use strict;
use warnings;
my $to = '"(".$1.")"';
$_ = "abc\n";
s/(.)/$to/gee;
print;
Produces:
(a)(b)(c)
as output.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
------------------------------
Date: 12 Apr 2005 10:01:40 -0700
From: "nobull@mail.com" <nobull@mail.com>
Subject: Re: s/(.)/($1)/g vs s/(.)/$to/eg where $to='($1)'
Message-Id: <1113325300.282274.251370@g14g2000cwa.googlegroups.com>
jiler...@yahoo.com wrote:
[ My favourite FAQ ]
I gave a lighting talk about this at YAPC::Europe::2004
http://birmingham.pm.org/talks/faq/Hello.html
------------------------------
Date: Tue, 12 Apr 2005 07:58:43 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Simple Encryption Script
Message-Id: <slrnd5nhg3.31q.tadmc@magna.augustmail.com>
Nikos <hackeras@gmail.com> wrote:
> Joe Smith wrote:
>
>> perl -le '@a=qw(a b c); $" = q{_*_}; print @a; print "@a"'
>> abc
>> a_*_b_*_c
>>
>> -Joe
>
> I see.
Yes you do.
> But how is this helpfull?
It seperates (sic) the values of the @array when it comes to
print "@array".
> I cant think of a reason other that seperate the values of the @array
> when it comes to print "@array";
See? You see.
:-)
Perl is chock-a-block full of features that make most programming
easier, $" is but one of them.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 12 Apr 2005 18:03:20 +0000 (UTC)
From: RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>
Subject: Re: Simple Encryption Script
Message-Id: <d3h2h8$6mm$1@sparta.btinternet.com>
Nikos wrote:
> Joe Smith wrote:
>
>> Nikos wrote:
>>
>>>> $toBeEncrypted =~ tr/a-zA-Z/b-zA-Za/;
>>>
>>>
>>>
>>> a-z transletes to b-z
>>> A-Z msut to B-Z why you say A-Za ?
>>
>>
>>
>> If you use tr/A-Z/B-Z/ then Y translates to Z, but the character
>> that Z translates to is not specified. So either
>> tr/A-Z/B-ZA/
>> or
>> tr/A-Z/B-Z[/
>> is appropriate.
>
>
>> Your program should explicitly document what it does to
>> characters that are outside of the A-Z range.
>
>
> Yes, now i think i understand. So the 'A' in tr/A-Z/B-ZA/ means that
> every other character outside the A-Z range should be changes to A
No, lets make it clearer, in tr/A-Z/B-ZA/
1) The "A-Z" is shorthand for "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
2) The "B-Z" is shorthand for "BCDEFGHIJKLMNOPQRSTUVWXYZ"
3) The final "A" just stands for "A"
4) From 2 and 3 we get "BCDEFGHIJKLMNOPQRSTUVWXYZA"
5) Each letter in the first string gets tranlated to the corresponding
position in the second string
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
to "BCDEFGHIJKLMNOPQRSTUVWXYZA"
So, for example "P" in the first string is translated to "Q" in the
second string.
AFAIK the order is unimportant[1] so it is exactly equivalent to
tr/QWERTYUIOPASDFGHJKLZXCVBNM/RXFSUVJPQBTEGHIKMAYDWCMO/
but that would be a pointlessly obscure way to write it.
Any character not matched in the first string is not altered in the result.
[1] so long as the strings are equal in length, and probably subject to
some other edge conditions I don't know about.
------------------------------
Date: 12 Apr 2005 10:48:22 -0700
From: EmmettPower@gmail.com
Subject: Troubleshooting printing to file
Message-Id: <1113328102.720835.300880@l41g2000cwc.googlegroups.com>
Hi,
I have a problem with what should be a simple issue. I am testing a
number of files in a directory for a pattern using a regular
expression. The successful matches are printed to the screen a file
(Output.txt). I've set out the code below. The pattern matches across
lines, hence the use of File::Slurp.
I'm using Perl on a Windows platform. The script works fine when I test
it on one computer but when I migrate it across to the computer holding
the files is fails to print the results to the Output file. It prints
to screen fine. Both computers are using the same version of Windows
and Perl.
It should be simple but I can't figure out what's wrong.
Any suggestions would be appreciated.
Regards
Emmett Power
<--------------------------CODE-------------------------------->
use File::Slurp;
my $file;
my $name;
my $FILELIST = "FileList.txt";
open(LIST, "$FILELIST");
open (OUT,'>Output.txt');
while(<LIST>)
{
chomp;
$name = $_;
$file = read_file($name);
while ($file =~ /test/gi){
print "$&,$_\n";
print OUT "$&,$_\n";
}
}
close(OUT);
close(LIST);
------------------------------
Date: Tue, 12 Apr 2005 20:05:50 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Troubleshooting printing to file
Message-Id: <3c2gtbF6k2b82U1@individual.net>
EmmettPower@gmail.com wrote:
> The script works fine when I test it on one computer but when I
> migrate it across to the computer holding the files is fails to print
> the results to the Output file. It prints to screen fine.
<snip>
I hope you have
use strict;
use warnings;
here.
> use File::Slurp;
>
> my $file;
> my $name;
>
> my $FILELIST = "FileList.txt";
> open(LIST, "$FILELIST");
>
> open (OUT,'>Output.txt');
So, if it fails to print to Output.txt, you should obviously let Perl
check for success (same with the file reading).
open(LIST, "$FILELIST") or die "Couldn't open $FILELIST: $!";
open (OUT,'>Output.txt') or die
"Couldn't open Output.txt for writing: $!";
See "perldoc perlopentut".
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
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 7968
***************************************