[23231] in Perl-Users-Digest
Perl-Users Digest, Issue: 5452 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 6 03:05:39 2003
Date: Sat, 6 Sep 2003 00:05:08 -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 Sat, 6 Sep 2003 Volume: 10 Number: 5452
Today's topics:
Re: Embedded Perl or Python (XPost) <rebel@removethis.rebel.com.au>
Re: Embedded Perl or Python (XPost) <aleax@aleax.it>
libxml-perl-0.07 and perl5.8.0 - fails test <thecommissioner@hotmail.com>
Re: libxml-perl-0.07 and perl5.8.0 - fails test <jwillmore@cyberia.com>
Re: Net::SSH::Perl <jwillmore@cyberia.com>
Re: Perl - Absolute min. environment required. <jwillmore@cyberia.com>
Re: perl and bash about localization (Mi)
Re: read VB file with Perl (Tad McClellan)
Re: read VB file with Perl <david-del@del-nonspiritual.com>
Re: read VB file with Perl <krahnj@acm.org>
Re: read VB file with Perl <david-del@del-nonspiritual.com>
Re: read VB file with Perl <david-del@del-nonspiritual.com>
Re: read VB file with Perl (Jay Tilton)
Re: Regexp Help <krahnj@acm.org>
Re: uping and downing letters (Greg Bacon)
Re: uping and downing letters <wenjoh26@emNOSPAMail.pct.edu>
Re: uping and downing letters <krahnj@acm.org>
Re: Weird interaction between Net::FTP and DBI / DBD::O <jwillmore@cyberia.com>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 06 Sep 2003 05:27:19 GMT
From: Chris <rebel@removethis.rebel.com.au>
Subject: Re: Embedded Perl or Python (XPost)
Message-Id: <78e5340818d8ad47fde9693b0d79bed8@news.teranews.com>
Hi Cameron
Thanks for the interest.
when I say smallest footprint its because to me size does matter :)
I like my apps to be as small as possible for easy delivery.
So for example if PERL "requires" the whole package to be present then
it would be too bloated
I would like just a small as possible DLL or possibly statically link
the interpreter into my app with minimum external files
so my concerns are
can it be done
which will do it better
which will be faster. (some of the scripts will be called many times so
compounding speed is an issue) can I precompile to decrease load times ?
which will be the smallest in size?
Chris
claird@lairds.com (Cameron Laird) wrote in
news:vlgkb4dtchna9e@corp.supernews.com:
> In article <c907a3eba2b531449c8dc7a212285911@news.teranews.com>,
> Chris <rebel@removethis.rebel.com.au> wrote:
> .
> .
> .
>>I am developing a software project where a major portion of it is to
>>enable script access to c++ classes
>>
>>The idea is to extend the basic functionality of the program by
>>allowing third parties to write add ons that are called by my c++
>>classes as virtual functions.
> .
> .
> .
>>Given the above which interpreter is most likely to fit my bill with
>>the smallest footprint ?
> .
> .
> .
> Let's be clear on what we're discussing. When you write,
> "smallest footprint", do you seriously mean, "creates the
> smallest differential in the size of the resulting exe-
> cutable image"? Frankly, that would surprise me; your
> project sounded interesting and useful up until those
> last two words. I don't mean to be harsh; unless there's
> something you're not telling us, though, the size of
> executables-as-file-images is quite unlikely to be even
> the tenth most important aspect of your target.
>
> I'll anticipate a bit more, and observe that Python is
> likely to be the better choice, because it remains easier
> for a newcomer to extend-or-embed (it's not clear that
> you've decided between these alternatives), at least until
> Perl 6 meets all its goals.
------------------------------
Date: Sat, 06 Sep 2003 06:55:33 GMT
From: Alex Martelli <aleax@aleax.it>
Subject: Re: Embedded Perl or Python (XPost)
Message-Id: <Fxf6b.20653$hE5.755579@news1.tin.it>
Chris wrote:
> LOL
>
> thanks for the heads up on Boost
You're welcome.
> I have just downloaded Swig and am beginning to explore that, So boost
> also sounds like a good idea.
Personally, I prefer SWIG when what I have to interface to is basically
C code. In that case, SWIG does have the advantage of being able to
interface a C library to _several_ HLLs and VHLLs. But for C++ I never
really got the hang of it, while Boost and pyste are a snap to use (for
Python, which coversa basically all I need).
> I think with my penchant for small things I may be getting carried away.
"Small binary size" is a perfectly respectable target when one's
target requires it (mobile phones, small palmtops, etc). Otherwise,
personally, I consider it way less important than productivity,
maintainability, correctness, and even speed. But if your priorities
are otherwise, you might consider LUA -- it probably won't do all you
want, but it may come near and it WILL be far smaller anyway.
Some scripting languages are designed for power, others focus on
being small. Perl and Python definitely consider power, ease of
use (by their very different criteria), and so on, far more crucial
than saving some bytes of disk. When that disk saving is crucial,
you may choose scripting languages designed to be small, even if
that sacrifices a lot of power -- after all, many scripting tasks
don't really require all that power.
> I guess suck it and see is my best option, I have explored the source
> code for perl 5.8 and got considerably lost :(
Ah, yes, I remember that feeling from back when I wrested with it
(Python's C source code I find very readable, and anyway you do not
need to look at it to use Boost or pyste).
> I will have to try python and see if I come out any wiser
Another option you may want to consider is Ruby. I don't know
how easy it is to interface it specifically to C++, and in
particular to get the cross-language subclassing and overriding
effect you want (which Boost provides so smoothly) -- but it's
basically the same power as Perl or Python, a distinctive style
of its own that along some axes lies in-between the two P's,
and a small but enthusiastic community. Size-wise, though, I
don't think it will significantly help you.
Alex
------------------------------
Date: Sat, 06 Sep 2003 05:42:32 GMT
From: "dj" <thecommissioner@hotmail.com>
Subject: libxml-perl-0.07 and perl5.8.0 - fails test
Message-Id: <3f5973c7$1@news.comindico.com.au>
Hi,
Does anyone know if libxml-perl works with perl 5.8.0. I read something in
the xml-perl archive that suggested that there may be a problem with this,
but it was a rather old message. I am trying to get XML::Grove to work, but
of course it needs libxml-perl. Has anyone come accross this problem?
during the make test, libxml-perl fails at t/stream (test 11) every other
test is fine except this one.
Any help would be greately appreciated,
Drew J
------------------------------
Date: Sat, 06 Sep 2003 06:05:13 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: libxml-perl-0.07 and perl5.8.0 - fails test
Message-Id: <20030906020512.10b2538f.jwillmore@cyberia.com>
On Sat, 06 Sep 2003 05:42:32 GMT
"dj" <thecommissioner@hotmail.com> wrote:
> during the make test, libxml-perl fails at t/stream (test 11) every
> other test is fine except this one.
>
Does it say why it fails? Have you read the README for the module?
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Garbage In -- Gospel Out.
------------------------------
Date: Sat, 06 Sep 2003 06:19:40 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: Net::SSH::Perl
Message-Id: <20030906021940.5c7caffe.jwillmore@cyberia.com>
On Fri, 05 Sep 2003 10:07:49 -0800
blob <jaws@skyinet.net> wrote:
> Hi all,
>
> Below is my script that will be used to connect to a remote host and
>
> change my password automatically:
<sniped for brevity>
>
> After running the program, my password didnt changed I was still
> able to connect using the old password.
>
> Does anybody has an idea what's missing or wrong with my script?
Just a suggestion - you may wish to use one of the Expect modules for
what you're doing. Expect is, IMHO, better suited for this task. And
in true Perl fashion, there is a module to interact with Expect :)
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Hlade's Law: If you have a difficult task, give it to a lazy
person -- they will find an easier way to do it.
------------------------------
Date: Sat, 06 Sep 2003 06:03:02 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: Perl - Absolute min. environment required.
Message-Id: <20030906020300.74df09c3.jwillmore@cyberia.com>
On 5 Sep 2003 11:29:05 -0700
Prab_kar@hotmail.com (Prabh) wrote:
> Hi,
> What is the absolute minimum required environment to execute a Perl
> program?
This is covered several places on the 'Net:
http://www.perl.com/
http://www.activestate.com/
http://perldoc.com/
>
> I want to execute a .pl on a PC which doesnt have Perl installed.
> I was thinking of copying the Perl .exes on to a network drive and
> invoke the intepreter from there.
> Something along the lines,
>
> <%> <path-to-network-drive>\perl.exe C:\foo.pl
Do _NOT_ just copy files. If you are a long time Windows user, you
should know better.
>
> Could anyone, please tell me what all do I need to copy to the
> network?
Go to the places listed above that offer documentation.
> If the Perl install changes the registry, how do I ensure they still
> work on User PC?
Which is why you _don't_ just copy files on a Windows platform :)
>
> If this is not possible, is there any Perl-LITE that can be
> installed locally?
Yes - go to the places where the documentation is located to find out
how to install Perl.
>
> Thanks,
> Prabh
I will thank you _after_ you do some more research :)
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
All I can think of is a platter of organic PRUNE CRISPS being
trampled by an army of swarthy, Italian LOUNGE SINGERS ...
------------------------------
Date: 5 Sep 2003 22:24:23 -0700
From: eastcapital@hotmail.com (Mi)
Subject: Re: perl and bash about localization
Message-Id: <1ed28a22.0309052124.774eab44@posting.google.com>
Eric Schwartz <emschwar@pobox.com> wrote in message news:<etooexyrcqt.fsf@wormtongue.emschwar>...
> eastcapital@hotmail.com (Mi) writes:
> > I am quite a newbie.
> > When I use command "$cal" in console, I can see the calender which is
> > localized. However in a cgi script
> >
> > print `$cal`;
> >
> > the result(the calender) is not localized. I appreciate if anyone
> > could give advice. Thank you.
I am sorry for mistaking copy of my script.
I did in my script
$cal = `cal`;
print "$cal";
the result was OK, however it was in English,not localized. I was
advised that
I had better write
ENV{'LANG'} = "ja_EUC.eucJP";
$cal = `cal`;
print "$cal";
and I could see Japanese though I don't know why because I am really
quite a newbie.Anyway thank you for your advice.
------------------------------
Date: Fri, 5 Sep 2003 19:55:31 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: read VB file with Perl
Message-Id: <slrnblic43.3pr.tadmc@magna.augustmail.com>
[ F'ups trimmed ]
[ reverse chronology reversed ]
David McDivitt <david-del@del-nonspiritual.com> wrote:
>>From: "Andrew Faust" <afaust@aradyme.com.REMOVE>
>>"David McDivitt" <x12code-del@del-yahoo.com> wrote in message news:462ilvotf8jms9ti5sg2colos9q3t129q4@4ax.com...
>><Snip A Question about how to read a binary file written in VB from Perl>
>>
>>I haven't done much with Perl, but I have done enough to know that
>>what you propose is possible. However, you are asking in the wrong
>>forum. I would recommend finding a Perl forum and asking how to
>>read a binary file.
Reading the file is the easy part.
>>There's no need to even mention it was written
>>in VB, as the same principles will apply no matter what language
>>your file was written in.
The hard part was how to _parse_ it once it is read in.
(the "get Perl to interpret VB data types" part in the OP.)
> I posted to VB and Perl forums. What I can tell Perl reads and writes
> string ascii data natively, only.
Pffft!
Wouldn't be much a system administration language if it could not
deal with binary files, so you just can't tell enough, yet. :-)
Use read() (or sysread) instead of readline(), aka: <FILEHANDLE>.
Use binmode().
> As I get further into the language I
> am sure I can read
You want to "read" but you haven't even checked to see if there
is a function named read() yet?
> a byte at a time
You can tell read() how many bytes to read.
> from the header and reconstruct VB
> data types with some algorithm. That would be a pain though.
Exactly. The reading of binary data is a nothing-problem
compared to that.
> someone has some code or at least suggest methodology so I don't have to
> reinvent the wheel. As prolific as these two languages are, surely
> someone has done something similar.
I didn't find anything on CPAN (but you've surely already tried that too).
If you do it, you can publish your module there for the next person. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 05 Sep 2003 23:21:50 -0500
From: David McDivitt <david-del@del-nonspiritual.com>
Subject: Re: read VB file with Perl
Message-Id: <dpnilvoj4i2v8qd7avkrhp6dsliv6c62c6@4ax.com>
I wrote a program to write VB data types. It produced
date 38 A4 65 BC FF CF E1 40
long 98 BA DC FE
integer DC FE
Will unpack() convert this?
Sub main()
Dim vlong&, vint%, vdate As Date, a$
vlong = &HFEDCBA98
Open FolderLocation(0, CSIDL_DESKTOP) & "\LongValue.txt" For Binary As 1
Put 1, 1, vlong
ToAscii
Close
vint = &HFEDC
Open FolderLocation(0, CSIDL_DESKTOP) & "\IntValue.txt" For Binary As 1
Put 1, 1, vint
ToAscii
Close
vdate = #11/15/1999 11:48:07 PM#
Open FolderLocation(0, CSIDL_DESKTOP) & "\DateValue.txt" For Binary As 1
Put 1, 1, vdate
ToAscii
Close
End Sub
Sub ToAscii()
Dim f1, a$, b$
b = ""
a = Space(1)
For f1 = 1 To LOF(1)
Get 1, f1, a
If f1 > 1 Then b = b & " "
b = b & Right("0" & Hex(Asc(a)), 2)
Next f1
Put 1, 1, b
End Sub
>From: Vlad Tepes <minceme@start.no>
>Date: Fri, 5 Sep 2003 23:30:07 +0000 (UTC)
>Lines: 85
>
>David McDivitt <x12code-del@del-yahoo.com> wrote:
>
>...
>
>> I need to get Perl to interpret VB data types when read from the file.
>>
>> This is the VB user defined type:
>>
>> Public Const StatusMaxAppPointer = 57
>> Public Const StatusCommonPointer = 58
>> Public Const StatusResourcePointer = 59
>> Public Const StatusOnCallPointer = 60
>> '
>> Public Type ProcRec
>> LastScanTime As Date
>> NextExecuteTime As Date
>> NextExecuteTimeSet As Integer
>> MinutesToRun As Long
>> TaskID As Double
>> ID As String * 4
>> ProcScheduler As String * 1
>> ProcName As String * 30
>> Active As Integer
>> PassArguments As Integer
>> OwnSection As String * 4
>> OwnUnit As String * 4
>> Executable As String * 256
>> ExecutableType As Integer
>> TextOffset(StatusOnCallPointer, 1) As Long
>> End Type
>>
>
>This can be done with unpack(). I don't know enough details about vb types
>to set up a correct $template, but this might get you started:
>
> # assuming vb Date is long int, strings are ascii, all ints are unsigned
> my $template = <<TMPL;
> L # LastScanTime As Date
> L # NextExecuteTime As Date
> I # NextExecuteTimeSet As Integer
> L # MinutesToRun As Long
> d # TaskID As Double
> A4 # ID As String * 4
> A # ProcScheduler As String * 1
> A30 # ProcName As String * 30
> I # Active As Integer
> I # PassArguments As Integer
> A4 # OwnSection As String * 4
> A4 # OwnUnit As String * 4
> A256 # Executable As String * 256
> I # ExecutableType As Integer
> L # TextOffset(StatusOnCallPointer, 1) As Long
> TMPL
>
> open my $fh, "filename" or die "can't open file: $!";
> $/ = undef;
> my $filestr = <$fh>;
>
> my ( $LastScanTime,
> $NextExecuteTime,
> $NextExecuteTimeSet,
> $MinutesToRun,
> $TaskID,
> $ID,
> $ProcScheduler,
> $ProcName,
> $Active,
> $PassArguments,
> $OwnSection,
> $OwnUnit,
> $Executable,
> $ExecutableType,
> $TextOffset ) = unpack $template, $filestr;
>
>
>...
>
>See
> perldoc -f pack for info about setting up $template
> perldoc -f read for how to read a specific amount of bytes from a file
> perldoc perltoc if there's something else you wonder about ...
------------------------------
Date: Sat, 06 Sep 2003 05:00:13 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: read VB file with Perl
Message-Id: <3F5969BD.A14EB1DC@acm.org>
David McDivitt wrote:
>
> I wrote a program to write VB data types. It produced
>
> date 38 A4 65 BC FF CF E1 40
> long 98 BA DC FE
> integer DC FE
>
> Will unpack() convert this?
Use unpack 'd' for the date, unpack 'l' for the long and unpack 's' for
the integer.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 05 Sep 2003 23:51:03 -0500
From: David McDivitt <david-del@del-nonspiritual.com>
Subject: Re: read VB file with Perl
Message-Id: <nnpilvg6m082b674e6784mfe8dohgd6gav@4ax.com>
I don't think it will be too bad if I have a module for each data type.
Each will receive a file pointer argument, read the number of bytes for
that data type, and add the value of each byte multiplied by 16 raised
to the power of the byte position. String data needs no conversion. Yes,
I will put it out for others.
>From: tadmc@augustmail.com (Tad McClellan)
>Date: Fri, 5 Sep 2003 19:55:31 -0500
>Lines: 80
>
>
>[ F'ups trimmed ]
>
>[ reverse chronology reversed ]
>
>
>David McDivitt <david-del@del-nonspiritual.com> wrote:
>>>From: "Andrew Faust" <afaust@aradyme.com.REMOVE>
>>>"David McDivitt" <x12code-del@del-yahoo.com> wrote in message news:462ilvotf8jms9ti5sg2colos9q3t129q4@4ax.com...
>>><Snip A Question about how to read a binary file written in VB from Perl>
>>>
>>>I haven't done much with Perl, but I have done enough to know that
>>>what you propose is possible. However, you are asking in the wrong
>>>forum. I would recommend finding a Perl forum and asking how to
>>>read a binary file.
>
>
>Reading the file is the easy part.
>
>
>>>There's no need to even mention it was written
>>>in VB, as the same principles will apply no matter what language
>>>your file was written in.
>
>
>The hard part was how to _parse_ it once it is read in.
>(the "get Perl to interpret VB data types" part in the OP.)
>
>
>> I posted to VB and Perl forums. What I can tell Perl reads and writes
>> string ascii data natively, only.
>
>
>Pffft!
>
>Wouldn't be much a system administration language if it could not
>deal with binary files, so you just can't tell enough, yet. :-)
>
>
>Use read() (or sysread) instead of readline(), aka: <FILEHANDLE>.
>
>Use binmode().
>
>
>> As I get further into the language I
>> am sure I can read
>
>
>You want to "read" but you haven't even checked to see if there
>is a function named read() yet?
>
>
>> a byte at a time
>
>
>You can tell read() how many bytes to read.
>
>
>> from the header and reconstruct VB
>> data types with some algorithm. That would be a pain though.
>
>
>Exactly. The reading of binary data is a nothing-problem
>compared to that.
>
>
>> someone has some code or at least suggest methodology so I don't have to
>> reinvent the wheel. As prolific as these two languages are, surely
>> someone has done something similar.
>
>
>I didn't find anything on CPAN (but you've surely already tried that too).
>
>If you do it, you can publish your module there for the next person. :-)
------------------------------
Date: Sat, 06 Sep 2003 00:22:39 -0500
From: David McDivitt <david-del@del-nonspiritual.com>
Subject: Re: read VB file with Perl
Message-Id: <horilv0aqkisna9lq3rmr5hnm0v07172vv@4ax.com>
Thanks!
>From: "John W. Krahn" <krahnj@acm.org>
>Date: Sat, 06 Sep 2003 05:00:13 GMT
>Lines: 20
>
>David McDivitt wrote:
>>
>> I wrote a program to write VB data types. It produced
>>
>> date 38 A4 65 BC FF CF E1 40
>> long 98 BA DC FE
>> integer DC FE
>>
>> Will unpack() convert this?
>
>
>Use unpack 'd' for the date, unpack 'l' for the long and unpack 's' for
>the integer.
>
>
>John
------------------------------
Date: Sat, 06 Sep 2003 06:02:54 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: read VB file with Perl
Message-Id: <3f597323.283697079@news.erols.com>
tadmc@augustmail.com (Tad McClellan) wrote:
: David McDivitt <david-del@del-nonspiritual.com> wrote:
: >>From: "Andrew Faust" <afaust@aradyme.com.REMOVE>
: >>"David McDivitt" <x12code-del@del-yahoo.com> wrote in message news:462ilvotf8jms9ti5sg2colos9q3t129q4@4ax.com...
: >><Snip A Question about how to read a binary file written in VB from Perl>
: >>
: >>I haven't done much with Perl, but I have done enough to know that
: >>what you propose is possible. However, you are asking in the wrong
: >>forum. I would recommend finding a Perl forum and asking how to
: >>read a binary file.
:
: Reading the file is the easy part.
:
: The hard part was how to _parse_ it once it is read in.
: (the "get Perl to interpret VB data types" part in the OP.)
:
: > from the header and reconstruct VB
: > data types with some algorithm. That would be a pain though.
:
: Exactly. The reading of binary data is a nothing-problem
: compared to that.
:
: > someone has some code or at least suggest methodology so I don't have to
: > reinvent the wheel. As prolific as these two languages are, surely
: > someone has done something similar.
:
: I didn't find anything on CPAN
I didn't either when I looked a few years ago, so I wrote a Perl
module that suited my needs at the time.
It's probably still not ready for CPAN prime time, but perhaps it
could become so. Anybody who wants to have a look and offer
suggestions, it's at
http://users.erols.com/tiltonj/perl/Data-Struct.02.20030613.zip
------------------------------
Date: Sat, 06 Sep 2003 04:38:45 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Regexp Help
Message-Id: <3F5964B6.1FEE52CE@acm.org>
raven wrote:
>
> Thanks for the enlightening reply. Sorry for being vague in my
> specification. I am simply tracking the printers, their IPs and the
> current disabled/enabled status. In the future I'm sure I'll add more
> functionality. Below is the the output of the various commands and the
> hack.
>
> lpstat -vsacprn05
> device for sacprn05: /dev/null
> remote to: RNP6C8BF9 on 192.168.25.73
>
> #!/usr/contrib/bin/perl -w
>
> # Printer interfaces directory
> my $interface = "/etc/lp/interface";
> # Printer Array
> my @printers = ();
>
> # Get a list of printers
> open PRINTER, "lpstat -p |";
You should _ALWAYS_ verify that the pipe opened correctly.
> while (<PRINTER>) {
> if (/^printer (\w+).*?(enabled|disabled)/) {
> # Push an anonymous hash REFERENCE onto the array
> push @printers, { "name" => "$1", "ip" => "none", "status" =>
> "$2" };
Excessive quoting. The only thing that needs to be quoted is the string
'none'.
> }
> }
> close PRINTER;
You should _ALWAYS_ verify that the pipe closed correctly.
> # Gather the IP address of each printer
> foreach $printer (@printers) {
> open PRINTER, "lpstat -v$$printer{name} |";
You should _ALWAYS_ verify that the pipe opened correctly.
> while (<PRINTER>) {
> next if /^device.*/;
> if (/^\s+remote.*?(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})/) {
^ ^ ^
^ ^ ^
Dots are special in regular expressions. You need to escape them to
match a literal dot character.
> $$printer{ip} = $1;
> last;
> }
> }
> close PRINTER;
You should _ALWAYS_ verify that the pipe closed correctly.
> # We hope that the printers with 'none' for IP are JetDirect
> if ($$printer{ip} =~ /none/) {
> open INTERFACE, "$interfaces/$$printer{name}" || die
> "Cannot open file!\n";
Using the || operator there won't do what you expect. You need to
either use the 'or' operator or parenthesize the open function.
> while (<INTERFACE>) {
> if (/^PERIPH=(.*)/) {
> $$printer{ip} = $1;
> last;
> }
> }
> close INTERFACE;
> }
> }
>
> # Display the results
> foreach $printer (@printers) {
> print "$$printer{name} / $$printer{ip} / $$printer{status}\n";
> }
It looks like you just need one loop for all that:
#!/usr/contrib/bin/perl -w
use strict;
# Printer interfaces directory
my $interface = '/etc/lp/interface';
# Printer Array
my @printers;
# Get a list of printers
open PRINTER, 'lpstat -p |' or die "Cannot open pipe from lpstat: $!";
while ( <PRINTER> ) {
next unless /^printer (\w+).*?((?:dis|en)abled)/;
# Push an anonymous hash REFERENCE onto the array
push @printers, { name => $1, ip => 'none', status => $2 };
if ( `lpstat -v $printers[-1]{name}` =~
/^\s+remote.*?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/m ) {
$printers[ -1 ]{ ip } = $1;
}
else {
local $/;
open INTERFACE, "$interfaces/$printers[-1]{name}"
or die "Cannot open $interfaces/$printers[-1]{name}: $!";
$printers[ -1 ]{ ip } = $1 if <INTERFACE> =~ /^PERIPH=(.*)/m;
close INTERFACE;
}
}
close PRINTER or die "Cannot close pipe from lpstat: $!";
# Display the results
foreach my $printer ( @printers ) {
print join( ' / ', @{$printer}{ qw/name ip status/ } ), "\n";
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 06 Sep 2003 04:08:10 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: uping and downing letters
Message-Id: <vlinda69vo5k37@corp.supernews.com>
In article <Xns93EDEFDD2B9BFwenjoh26emNOSPAMailp@216.65.98.9>,
john <wenjoh26@emNOSPAMail.pct.edu> wrote:
: Howdy,
:
: looking for a way to change letter
:
: # example
: # a would become b, A would become B, b=c, c=d etc for upping or
: # b would become a, B would become A, etc.
This should get you started:
% cat try
#! /usr/local/bin/perl -l
$_ = "a -> b, b -> c, c -> a";
print;
tr[abc]
[bca];
print;
% ./try
a -> b, b -> c, c -> a
b -> c, c -> a, a -> b
: [...]
See the documentation on Perl's tr/// operator in the perlop manpage.
Hope this helps,
Greg
--
There are more instances of the abridgement of the freedom of the people
by the gradual and silent encroachment of those in power, than by violent
and sudden usurpation.
-- James Madison
------------------------------
Date: 5 Sep 2003 23:18:21 -0500
From: john <wenjoh26@emNOSPAMail.pct.edu>
Subject: Re: uping and downing letters
Message-Id: <Xns93EE32D3A786wenjoh26emNOSPAMailp@216.65.98.9>
>: looking for a way to change letter
>: # example
>: # a would become b, A would become B, b=c, c=d etc for upping or
>: # b would become a, B would become A, etc.
>: Ive tried a couple different things and just cant come up with a way to
>: do it.
> What techniques have you tried? How were those techniques
> unacceptable?
>: I have to be able to use a-z,A-Z,0-9, - and _ and after upping and
>: downing I have to be able to get the original letter back.
> How should the edge cases be handled? For example, should an
> incremented 'z' become whatever is next in the ASCII character set,
> should it wrap back to 'a', turn into 'A', or something else? What
> should an incremented or decremented '-' or '_' become?
> Do you wish to change all the characters in a string, or only one
> character?
> The chr() and ord() functions may be what you want.
> Or the tr/// operator may be more useful.
> It depends.
>
Thanks for the help as for -,_,z,Z etc. I am just looking to push to the
next character in askii. And I am recieving the letters in a string but
have written the code to parse the string into an array of chars
thanks again
john
.
.
.
.
.
.
.
.
.
------------------------------
Date: Sat, 06 Sep 2003 04:54:06 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: uping and downing letters
Message-Id: <3F59684D.A654B57F@acm.org>
john wrote:
>
> Thanks for the help as for -,_,z,Z etc. I am just looking to push to the
> next character in askii. And I am recieving the letters in a string but
> have written the code to parse the string into an array of chars
To go "up":
$string =~ tr/\x0-\xFF/\x1-\xFF\x0/;
To go back "down" again:
$string =~ tr/\x1-\xFF\x0/\x0-\xFF/;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 06 Sep 2003 06:16:00 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: Weird interaction between Net::FTP and DBI / DBD::Oracle
Message-Id: <20030906021558.74f1ae7b.jwillmore@cyberia.com>
On 5 Sep 2003 08:08:56 -0700
plm@gmx.li (Peter Mutsaers) wrote:
> Using perl 5.8.0 and latest versions of libnet and DBI:
>
> The script did
>
> - open DBI to oracle
> - start queries and write in 2 files
> - close files
> - close DB
> - open FTP (Net::FTP->new)
>
> result: the open FTP fails immediately with a connection timeout,
> even though the timeout is 120s (I also tried some other explicit
> settings and traced into IO::Socket).
>
> When I reverse the 2 last steps, i.e. I close the DB handle after
> the Net::Ftp->new, there is no problem.
>
> Note: the FTP->new fails only when the server takes more than about
> 1 second to respond. For fast local servers the problem did not
> occur at all.
>
> Someone has an idea how this can be? Could the closing of the
> DBD::Oracle handle throw some signal (this is on Solaris btw) after
> 1 second which confuses IO::Socket?
2 suggestions:
1) use the DBI 'trace' method
2) use the Net::FTP 'Debug' feature
This may shed some more light on the issue you're having. It will
give a better view of what the client/server conversations are.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
You think Oedipus had a problem -- Adam was Eve's mother.
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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.
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 5452
***************************************