[22934] in Perl-Users-Digest
Perl-Users Digest, Issue: 5154 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 30 06:05:52 2003
Date: Mon, 30 Jun 2003 03: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 Mon, 30 Jun 2003 Volume: 10 Number: 5154
Today's topics:
Re: BTree examples ?? <paul.marquess@btinternet.com>
Re: BTree examples ?? <paul.marquess@btinternet.com>
Re: BTree examples ?? <paul.marquess@btinternet.com>
Completely confused - system and $? == -1 <persicom@acedsl.com>
Re: Completely confused - system and $? == -1 <s_grazzini@hotmail.com>
Re: directory access problem (stegger)
Getting the total size of files matching a pattern? (Math55)
Re: Getting the total size of files matching a pattern? <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: How do you sort a 2D array with column headers? (Mark Jason Dominus)
Re: How do you sort a 2D array with column headers? Dennis@NoSpam.com
How to pass global variables between files (Monday)
Re: How to pass global variables between files <dont@want.spam>
Korn Shell vs. Perl <alvarof2@hotmail.com>
Re: Korn Shell vs. Perl <tassilo.parseval@rwth-aachen.de>
Newbie problem with open <abuse@sgrail.org>
Re: Newbie problem with open (David Efflandt)
Re: Newbie problem with open <abuse@sgrail.org>
reading buffered form data <cyberjeff@sprintmail.com>
Re: Reading JPEG file <zvone.zagar@siol.net>
Re: Reading JPEG file <asu1@c-o-r-n-e-l-l.edu>
Regular expressions <mark_evans029@yahoo.com>
Re: Regular expressions <eric-amick@comcast.net>
Re: Regular expressions <mark_evans029@yahoo.com>
Sending the "down" key via Expect (Nick Leeson)
Re: Sending the "down" key via Expect <ndronen@io.frii.com>
Speed of file vrs dbase access (fatted)
Storable module for Activestate 5.6.1?? (Kenjis Kaan)
Re: Storable module for Activestate 5.6.1?? <kalinabears@hdc.com.au>
String matching not working (Dave from Dublin)
Using filehandle many times (ABC)
Re: Using perl/shell scripts to kill processes more tha <mgjv@tradingpost.com.au>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 30 Jun 2003 09:09:43 +0100
From: "Paul Marquess" <paul.marquess@btinternet.com>
Subject: Re: BTree examples ??
Message-Id: <3efff049$0$10627$ed9e5944@reading.news.pipex.net>
"Jörg Westheide" <joerg@objectpark.org> wrote in message
news:0306QYvULoUrv0yfMhx3ae8Ayw@objectpark.org...
Hi!
> I am wondering if anyone has an example of using BTree for
> storing data on a disk file.?? I found some BTree modules on the
> web, but none give example of how you would then store it and retrieve
> it from disk drive.
Have a look at the DB_File module
> I have a need to store hundred of thousands of
> key, data values
That's no problem (I used it with some millions)
The only backdraw I discovered, is the really bad performance on
Win(2K), it's fine on Linux though
Jörg
------------------------------
Date: Mon, 30 Jun 2003 09:40:09 +0100
From: "Paul Marquess" <paul.marquess@btinternet.com>
Subject: Re: BTree examples ??
Message-Id: <3efff76a$0$10626$ed9e5944@reading.news.pipex.net>
"Vlad Tepes" <minceme@start.no> wrote in message
news:bdigil$a5a$1@troll.powertech.no...
> Paul Marquess <paul.marquess@btinternet.com> wrote:
>
> > The DB_File module, that comes with Perl, has a btree opion. You can
> > easily store hundres of thousands of key/data pairs in it.
> >
> >
> > The example below is derived from the docuemntation that comes with
> > DB_File
> >
> > use warnings ;
> > use strict ;
> > use DB_File ;
> >
> > my %h ;
> > tie %h, "DB_File", "tree", O_RDWR|O_CREAT, 0666, $DB_BTREE
> > or die "Cannot open file 'tree': $!\n" ;
> >
> > # Add a key/value pair to the file
> > $h{'Wall'} = 'Larry' ;
> > $h{'Smith'} = 'John' ;
> > $h{'mouse'} = 'mickey' ;
> > $h{'duck'} = 'donald' ;
> >
> > # Delete
> > delete $h{"duck"} ;
> >
> > # Cycle through the keys printing them in order.
> > # Note it is not necessary to sort the keys as
> > # the btree will have kept them in order automatically.
> > foreach (keys %h)
> > { print "$_\n" }
> >
> > untie %h ;
> >
> > Paul
>
> ( I'm not sure about this, but I think I'm right: )
>
> A small note: If you have a very big hash, you'd might like to save
> memory by doing
>
> while ( (my $k, undef) = each %h ) {
> print "$k\n";
> }
>
> instead of using the foreach loop in the above example.
Good catch. You are quite correct. If you have millions of records in the
database, this is the only way to iterate through them without running out
of memory.
Using "keys" of "values" will result in *all* the keys or values being read
into memory in one go. The "each" function will only read a single key/value
pair at a time.
Paul
------------------------------
Date: Mon, 30 Jun 2003 09:57:48 +0100
From: "Paul Marquess" <paul.marquess@btinternet.com>
Subject: Re: BTree examples ??
Message-Id: <3efffb8c$0$10631$ed9e5944@reading.news.pipex.net>
"Jörg Westheide" <joerg@objectpark.org> wrote in message
news:0306QYvULoUrv0yfMhx3ae8Ayw@objectpark.org...
> Hi!
>
> > I am wondering if anyone has an example of using BTree for
> > storing data on a disk file.?? I found some BTree modules on the
> > web, but none give example of how you would then store it and retrieve
> > it from disk drive.
>
> Have a look at the DB_File module
>
> > I have a need to store hundred of thousands of
> > key, data values
>
> That's no problem (I used it with some millions)
> The only backdraw I discovered, is the really bad performance on
> Win(2K), it's fine on Linux though
Can you elaborate on the performance issues on Win2k?
I don't do any development on Windows myself, and haven't had any reports of
bad performance (as far as I can remember). If there is a performance issue
with Windows, I'd like to fix it (if it is fixable), or document it if it is
not.
cheers
Paul
------------------------------
Date: Sun, 29 Jun 2003 22:12:20 -0400
From: "Matthew O. Persico" <persicom@acedsl.com>
Subject: Completely confused - system and $? == -1
Message-Id: <1056939135.512729@nntp.acecape.com>
I have a number of places in my code where I call external programs with
backticks or the system command. Sometimes, I get -1 back from system or
$? is -1 with the backticks. I am using perl 5.6.1 on Solaris 2.7. Does
this imply that somehow, a shell is being called on my behalf even
though the backticks have no shell characters and the system command
uses the list form? What else should I be looking for?
When I extract the recalcitrant calls and in a small script I don't have
this problem. Could there be some bad interatction with another module?
I thought I'd get some general ideas before I went willy nilly posting
code 'cause the 'reduced example' that I would post would work!
Thanks
--
Matt
------------------------------
Date: Mon, 30 Jun 2003 02:58:30 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: Completely confused - system and $? == -1
Message-Id: <qHNLa.8293$oF.2531@nwrdny03.gnilink.net>
Matthew O. Persico <persicom@acedsl.com> writes:
> Sometimes, I get -1 back from system or $? is -1 with
> the backticks. I am using perl 5.6.1 on Solaris 2.7.
> Does this imply that somehow, a shell is being called
> on my behalf even though the backticks have no shell
> characters and the system command uses the list form?
Nope.
It means that, during the failed call, either fork(), exec()
or waitpid() failed and you need to check $! instead.
$ perldoc -f system
To be fair, it sounds like you've read at least the first
paragraph already... just keep reading :-)
--
Steve
------------------------------
Date: 29 Jun 2003 22:18:48 -0700
From: iaegger@hta.fhz.ch (stegger)
Subject: Re: directory access problem
Message-Id: <f4c61bfa.0306292118.611cf712@posting.google.com>
Eric Amick <eric-amick@comcast.net> wrote in message news:<4e1ufv0d4r9s549isrds8gt6dduemla0ap@4ax.com>...
> On 29 Jun 2003 07:43:56 -0700, iaegger@hta.fhz.ch (stegger) wrote:
>
> >I am a perl newbie and should solve a script problem.
> >
> >I have defined a directory in the smbldap_conf.pm file similar to the
> >following line:
> >$mk_ntpasswd = "/usr/local/sbin/mkntpwd";
> >
> >Then in the smbldap-passwd.pl the line below generates an unexpected
> >output and the script behaves not like expected
> >
> >Perl line which gerates the error:
> >my $ntpwd = `$mk_ntpasswd '$pass'`;
> >
> >The error (or output)
> >sh: /usr/local/sbin/mkntpwd: is a directory
>
> The error message seems clear enough to me--you're trying to use the
> name of a directory as if it were a program or shell script. Perhaps
> the program you want to run is in that directory?
Thanks. I was just not sure if the perl line is correct or not. There
are too many quotes for a perl beginner. :-)
--
Stefan
Lucerne, CH
------------------------------
Date: 30 Jun 2003 02:27:27 -0700
From: magelord@t-online.de (Math55)
Subject: Getting the total size of files matching a pattern?
Message-Id: <a2b8188a.0306300127.24f87e08@posting.google.com>
hello, is there a goor mothod to get the total size of special files
in a directory? for example all *.gz and *.html file in /var/log or
something like that. i tried with du -c *.gz but this is not working
as it should.
any ideas?
THANKS:)
------------------------------
Date: Mon, 30 Jun 2003 09:32:14 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Getting the total size of files matching a pattern?
Message-Id: <Xns93AA74F1F8341elhber1lidotechnet@62.89.127.66>
Math55 wrote:
> hello, is there a goor mothod to get the total size of special files
> in a directory? for example all *.gz and *.html file in /var/log or
> something like that. i tried with du -c *.gz but this is not working
> as it should.
>
> any ideas?
1. open the directory you're interested in (perldoc -f opendir)
2. loop through all files in the open directory... (perldoc -f readdir)
3. ...ignoring the files you're not interested in (perldoc -f grep)
4. add the size of the files in the loop (perlodc -f -x)
5. print the result after the loop terminates (perldoc -f print)
1, 2 and 3 can also be done using File::Find (perldoc File::Find). Perhaps
File::Find can do 4 as well, but I'm not sure.
--
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Mon, 30 Jun 2003 03:37:21 +0000 (UTC)
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: How do you sort a 2D array with column headers?
Message-Id: <bdob9h$4bq$1@plover.com>
In article <vfunk060dd9b30@corp.supernews.com>,
Greg Bacon <gbacon@hiwaay.net> wrote:
>(I might be setting a bad example. mjd, rightly IMHO, says using
>$#ARRAY is a red flag[*]. The usage is correct in this case, but
>do what I say, not what I do. :-)
>[*] http://groups.google.com/groups?selm=3bd70c54.b10%24141%40news.op.net
In that article, I said I thought I was going to add $#array as a red
flag. I did add it to the class, but I did not accord it 'red flag'
status. A 'red flag' is something that is almost always wrong. After
doing a study, I concluded that although $#array is often wrong, it is
not 'almost always wrong'.
The details of the study are at
http://perl.plover.com/yak/flags/dollar-pound/. Here is the short
version. $#array is commonly used for five things:
1. Generating a list of indices for an array. (Your example above is
one of these; it is @{$m}[1..$#$m].)
2. The upper bound of a C-style 'for' loop, as
for ($i=0; $i <= $#array; $i++) {
do something with $array[$i];
}
3. As a boundary check to see if a value is in the proper index range
for an array. (2) could be considered a special case of this.
Here's an example:
if ($last_item >= $#list) {
$Init_Disp_Limits->();
}
4. To pre-extend an array, as with
$#array = $EXPECTED_NUMBER_OF_ITEMS;
5. To access the last element of an array, as with $last = $array[$#array].
In my judgement, all of the class (2) and (5) uses, and many of the
class (3) uses, would have been better written some other way. For
example, I think the example in (5) is obviously better as $last = $array[-1].
Overall, about 20% of the uses of $#array would have been better off
some other way. Class (1) did not seem to be in this 20%. I don't
know any better way to write
%hash = map { $array[$_] => $_ } 0 .. $#array;
without the $#array, for example.
------------------------------
Date: Sun, 29 Jun 2003 23:20:56 -0500
From: Dennis@NoSpam.com
Subject: Re: How do you sort a 2D array with column headers?
Message-Id: <2bevfvsti9fbk1u6s0cvb1n4gf9r8s0lqk@4ax.com>
gbacon@hiwaay.net (Greg Bacon) wrote:
>In article <q4iufvkdmm9etdlqbdbliidf7u6prdhs0l@4ax.com>,
> <Dennis@NoSpam.com> wrote:
>
<snip really great code and explanations for all my beginner questions>
>
>Hope this helps,
>Greg
Thanks Greg for the really great Perl code and explanations on how it works. I
really appreciate the time and effort you put in to teach me and all the others
who are reading these posts. I have really learned a lot...much more than the
Perl books I've been reading.
Thanks again.
Dennis
------------------------------
Date: 30 Jun 2003 01:09:14 -0700
From: monday94301@yahoo.com (Monday)
Subject: How to pass global variables between files
Message-Id: <3f1048bc.0306300009.4825c540@posting.google.com>
Hello, I am new to Perl. I want to do something simple but seem to be
unable to do this. I want to call a subroutine and have it access the
global variables in the caller program, similar to below where
index.cgi is the calling program and called.cgi is the called program.
How do I do this since there is no 'include' type of statement in
Perl? -Monday
index.cgi
=========
#!c:/perl/bin/perl.exe
our $globalVar = "Chicago";
callNow();
return 1;
called.cgi
==========
callNow() {
print "global variable is $globalVar";
}
------------------------------
Date: Mon, 30 Jun 2003 10:09:25 +0100
From: Chris Lowth <dont@want.spam>
Subject: Re: How to pass global variables between files
Message-Id: <97TLa.5382$MO2.4684@newsfep4-winn.server.ntli.net>
Monday wrote:
> Hello, I am new to Perl. I want to do something simple but seem to be
> unable to do this. I want to call a subroutine and have it access the
> global variables in the caller program, similar to below where
> index.cgi is the calling program and called.cgi is the called program.
> How do I do this since there is no 'include' type of statement in
> Perl? -Monday
>
> index.cgi
> =========
> #!c:/perl/bin/perl.exe
> our $globalVar = "Chicago";
> callNow();
> return 1;
>
> called.cgi
> ==========
> callNow() {
> print "global variable is $globalVar";
> }
you can use "do" as a simple include-ish sort of thing
in index.cgi:
do "called.cgi";
"use" is better on the whole but you need to get into the idea of packages /
modules and name spaces for that. Use "do" if you want dead simple code,
use "use" if you want to import a "package" or "module".
Chris
--
Real address: chris at lowth dot sea oh em.
World's first wrist-watch PDA with Palm OS, available June 30
from Amazon.com. Order now to beat the rush!
http://www.lowth.com/shop/wrist_pda
------------------------------
Date: Mon, 30 Jun 2003 06:17:35 GMT
From: "A. Fuentes" <alvarof2@hotmail.com>
Subject: Korn Shell vs. Perl
Message-Id: <3CQLa.32344$hV.2016692@twister.austin.rr.com>
Fellow Perl Netters:
At the level of the internals, IN GENERAL terms, what is the difference
in how Perl operates compared with the Korn shell?
From the Operating System view, do they operate similarly, or
entirely different?
Any Opinions/Info about this issue will be greatly appreciated.
Best,
A. Fuentes
System Admin
------------------------------
Date: 30 Jun 2003 07:14:46 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Korn Shell vs. Perl
Message-Id: <bdoo16$978$1@nets3.rz.RWTH-Aachen.DE>
Also sprach A. Fuentes:
> Fellow Perl Netters:
>
> At the level of the internals, IN GENERAL terms, what is the difference
> in how Perl operates compared with the Korn shell?
> From the Operating System view, do they operate similarly, or
> entirely different?
That's an odd question. It's like asking in which way MySQL differs
from, say, WindowMaker implementation-wise. They don't have much in
common:
The Korn shell is, as its name suggests, a shell whereas Perl is a
programming language. Similarity between those two is probably that both
are written in C. A shell is primarily made to be interactive. You have
something where to type your commands in, the shells processes this
input and produces some sort of output. Even shell scripts aren't much
different: they are considered to be a sequence of commands as if they
were given interactively.
Perl however, like most other languages, is not interactive. What it
receives is a large string that is checked and parsed against a
context-free grammar. If the string was a valid Perl program, a tree of
operators (called OPs) can be created from it. On execution perl walks
through this optree and executes each OP accordingly.
If you compared how a shell script is processed on the internals as
opposed to a Perl script, you might indeed find some similarites. Shells
often use context-free grammars as well to validate and process their
input. I am not sure about the Korn shell, but at least the bash has a
yacc/bison grammar included. So has Perl.
The main difference is that shells seldom provide a tight interaction
with the operating system. If you wanted to do something that involves
creating sockets, reading/writing from/to them etc. you'd use an
external program for it, like wget for downloading a remote file. A
shell then spawns off a new process for that. In its most basic form a
shell just needs a very limited grammar and some means to create
processes. To be more powerful they provide some ways to have different
processes interact with each other by using pipes for example.
Therefore, a typical shell command is
find /usr/include -name \*.h | xargs grep -l ^#define | sort > output.txt
In programming languages such as Perl the above could be done
differently. When you fetch a remote file, you could directly open a
socket and do all the low-level communication yourself. If you wanted to
mimic a find like the above, you could be using File::Find, open each
file, apply a regular expression to each line, collect matching
filenames in an array, sort this array, open a file output.txt and write
the sorted array into this file.
The implication this has for the internals of a shell and a programming
language should be obvious.
Btw, have you considered looking at the respective sources?
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Mon, 30 Jun 2003 05:44:37 GMT
From: derek / nul <abuse@sgrail.org>
Subject: Newbie problem with open
Message-Id: <rbjvfvsnhij4eqf4tcsjc3386ike9as6oq@4ax.com>
Have been through perldoc -f open and trying to do:-
open(FH, "<:utf8", "file")
My code looks like:-
#win32 Activestate 5.8.0
use strict;
use warnings;
use Encode qw/encode decode/;
my $dash9= "c:/program files/microsoft games/train
simulator/trains/trainset/dash9/dash9.eng";
open (DASH9, "<:utf16", "$dash9"), or die "Cannot open $dash9 for read :$!";
I get the error:-
perlio: unknown layer "utf16".
What am I doing wrong?
Derek
------------------------------
Date: Mon, 30 Jun 2003 06:42:29 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Newbie problem with open
Message-Id: <slrnbfvmul.1le.efflandt@typhoon.xnet.com>
On Mon, 30 Jun 2003 05:44:37 GMT, derek / nul <abuse@sgrail.org> wrote:
> Have been through perldoc -f open and trying to do:-
> open(FH, "<:utf8", "file")
>
> My code looks like:-
>
> #win32 Activestate 5.8.0
>
> use strict;
> use warnings;
> use Encode qw/encode decode/;
> my $dash9= "c:/program files/microsoft games/train
> simulator/trains/trainset/dash9/dash9.eng";
>
> open (DASH9, "<:utf16", "$dash9"), or die "Cannot open $dash9 for read :$!";
>
>
> I get the error:-
>
> perlio: unknown layer "utf16".
>
> What am I doing wrong?
According to 'perldoc Encode' under Encoding via PerlIO it looks like you
should be using something like [was there some reason for the extra comma
after your open()]:
open (DASH9, "<:encoding(utf16)", "$dash9")
or die "Cannot open $dash9 for read :$!";
--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Mon, 30 Jun 2003 06:48:56 GMT
From: derek / nul <abuse@sgrail.org>
Subject: Re: Newbie problem with open
Message-Id: <39nvfv0u450ncgo1tcc28cd7ieql9bte0b@4ax.com>
On Mon, 30 Jun 2003 06:42:29 +0000 (UTC), efflandt@xnet.com (David Efflandt)
wrote:
>On Mon, 30 Jun 2003 05:44:37 GMT, derek / nul <abuse@sgrail.org> wrote:
>> Have been through perldoc -f open and trying to do:-
>> open(FH, "<:utf8", "file")
>>
>> My code looks like:-
>>
>> #win32 Activestate 5.8.0
>>
>> use strict;
>> use warnings;
>> use Encode qw/encode decode/;
>> my $dash9= "c:/program files/microsoft games/train
>> simulator/trains/trainset/dash9/dash9.eng";
>>
>> open (DASH9, "<:utf16", "$dash9"), or die "Cannot open $dash9 for read :$!";
>>
>>
>> I get the error:-
>>
>> perlio: unknown layer "utf16".
>>
>> What am I doing wrong?
>
>According to 'perldoc Encode' under Encoding via PerlIO it looks like you
>should be using something like [was there some reason for the extra comma
>after your open()]:
>
>open (DASH9, "<:encoding(utf16)", "$dash9")
> or die "Cannot open $dash9 for read :$!";
hmmm, I did not notice that one.
didn't make any difference though??
------------------------------
Date: Mon, 30 Jun 2003 06:58:51 GMT
From: Jeff Thies <cyberjeff@sprintmail.com>
Subject: reading buffered form data
Message-Id: <3EFFDF35.183314E5@sprintmail.com>
I have a multipart form with several fields including an imput
type="file" that needs to be FTP'd elsewhere. The file input may be
quite large.
If I were to read in the file using CGI.pm, CGI.pm would slurp in the
entire "file" into a temp file, potentially exceeding the storage quota.
I think I'm going to have read from STDIN directly.
my $flag=0;
while(<STDIN>){
if($_=~/^-------/){ # reset if form boundary, do all form boundaries
start like that?
$flag=0;
}
if($flag){&appendFTP($_)}
if($_=~/name="name_of_file"/){ # look for form name
$flag=1;
}
}
That seems a bit simple and crude. Do I need to do this?:
$_ =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; (before
appendFTP)
Do I need to filter out the "Content-type: ...\n\n" that seems to start
the file?
What else have I overlooked?
Jeff
------------------------------
Date: Mon, 30 Jun 2003 01:00:44 +0200
From: Zvone Zagar <zvone.zagar@siol.net>
Subject: Re: Reading JPEG file
Message-Id: <GdKLa.1908$78.104444@news.siol.net>
Eric J. Roode wrote:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> Zvone Zagar <zvone.zagar@siol.net> wrote in
> news:l_4La.1859$78.94796@news.siol.net:
>
>> I have searched for days, but found almost nothing (except some
>> excerpts from C code).
>> I hope I made myself clear enough. Any help would be appreciated.
>
> How about Image::Magick, or the GD module?
>
> - --
> Eric
> $_ = reverse sort qw p ekca lre Js reh ts
> p, $/.r, map $_.$", qw e p h tona e; print
>
> -----BEGIN xxx SIGNATURE-----
> Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
>
> iQA/AwUBPvz4a2PeouIeTNHoEQJNEwCdH0QWF8H8ril5E27f9R9yd/nd++YAn3Ly
> cc8UAjQRM2YhRylTFiVtB9Wd
> =Urtr
> -----END PGP SIGNATURE-----
Thanks for the tip.
I have tried Image::Magick. A picture could be saved as PS file.
It is not exactly what I want, but it will help me.
Regards Zvone Zagar
------------------------------
Date: 30 Jun 2003 02:24:06 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Reading JPEG file
Message-Id: <Xns93A9E3E24859Easu1cornelledu@132.236.56.8>
Zvone Zagar <zvone.zagar@siol.net> wrote in
news:GdKLa.1908$78.104444@news.siol.net:
> I would like to read a jpg image, get data (decode) out of it and make
> a postscript file from scratch. I can get width, height, color depth
> but I don't know how to make a hex string needed for postscript.
> Postscript line should look like: width height depth matrix {<hex
> data>} false 3 colorimage.
> Eric J. Roode wrote:
>
>> Zvone Zagar <zvone.zagar@siol.net> wrote in
>> news:l_4La.1859$78.94796@news.siol.net:
>>
>>> I have searched for days, but found almost nothing (except some
>>> excerpts from C code). I hope I made myself clear enough. Any help
>>> would be appreciated.
>>
>> How about Image::Magick, or the GD module?
>>
> Thanks for the tip.
> I have tried Image::Magick. A picture could be saved as PS file.
> It is not exactly what I want, but it will help me.
ImageMagick can save image data in raw RGB format. Although I have never
used it, and do not have it installed, I thought pointing that out might
help.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Sun, 29 Jun 2003 21:05:50 -0500
From: "mark" <mark_evans029@yahoo.com>
Subject: Regular expressions
Message-Id: <F-SdnWyA54aWBmKjXTWJiw@www.bayou.com>
i am attempting to write a script using Net::Telnet. The script telnets to
a machine
logs in and issues a command to list the config. Tthe output of the command
pauses
about every screenfull and gives the user the prompt " --More-- ". The
script
contains the followin code to account fot the prompt.
$telnet->waitfor('/-\-More\-\- $/i');
$telnet->print('\s');
the script does not proceed past the " --More-- " prompt. this problems
seems to have stumpt me. does anyone have any suggestions for me?
Thanks
mark
------------------------------
Date: Sun, 29 Jun 2003 23:49:43 -0400
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: Regular expressions
Message-Id: <t8cvfvgsnhcpqf9pfjkt1853janjth9bne@4ax.com>
On Sun, 29 Jun 2003 21:05:50 -0500, "mark" <mark_evans029@yahoo.com>
wrote:
>i am attempting to write a script using Net::Telnet. The script telnets to
>a machine
>logs in and issues a command to list the config. Tthe output of the command
>pauses
>about every screenfull and gives the user the prompt " --More-- ". The
>script
>contains the followin code to account fot the prompt.
>
>$telnet->waitfor('/-\-More\-\- $/i');
Hyphens are special only within character classes, so I'd remove the
backslashes for readability if nothing else. Are you absolutely certain
the prompt ends with exactly one space?
>$telnet->print('\s');
This looks suspicious. Shouldn't that be a space in the quotes? You
probably want put() instead of print(); print() sends out a newline
automatically, and you wouldn't press return when typing it manually.
--
Eric Amick
Columbia, MD
------------------------------
Date: Mon, 30 Jun 2003 00:05:25 -0500
From: "mark" <mark_evans029@yahoo.com>
Subject: Re: Regular expressions
Message-Id: <osqcnUR_UcLKWGKjXTWJiw@www.bayou.com>
"Eric Amick" <eric-amick@comcast.net> wrote in message
news:t8cvfvgsnhcpqf9pfjkt1853janjth9bne@4ax.com...
> On Sun, 29 Jun 2003 21:05:50 -0500, "mark" <mark_evans029@yahoo.com>
> wrote:
>
> >i am attempting to write a script using Net::Telnet. The script telnets
to
> >a machine
> >logs in and issues a command to list the config. Tthe output of the
command
> >pauses
> >about every screenfull and gives the user the prompt " --More-- ". The
> >script
> >contains the followin code to account fot the prompt.
> >
> >$telnet->waitfor('/-\-More\-\- $/i');
>
> Hyphens are special only within character classes, so I'd remove the
> backslashes for readability if nothing else. Are you absolutely certain
> the prompt ends with exactly one space?
>
> >$telnet->print('\s');
>
> This looks suspicious. Shouldn't that be a space in the quotes? You
> probably want put() instead of print(); print() sends out a newline
> automatically, and you wouldn't press return when typing it manually.
>
> --
> Eric Amick
> Columbia, MD
ya, i tried exactly one space prior to trying the /s. ya fairly certain it
is just one space. i was thought it might
be sending an unprintable character for what ever reason, so i changed
input_log to a dump_file and checked
the last character in it. the end of the file just one character with
character code 20. I just tried using the put in
place of the print, but didn't seem to help.
Thanks mark
mark
------------------------------
Date: 29 Jun 2003 15:11:23 -0700
From: nickleeson78@yahoo.com (Nick Leeson)
Subject: Sending the "down" key via Expect
Message-Id: <78117dd.0306291411.1d29e6e0@posting.google.com>
Hi,
I am using an expect script to interact with lynx running on a remote
server.I am trying to figure out how to send the direction keys
...left(->), right(<-),up and down keys....I know i need to send their
equivalent ASCII values..but what would they be?
Please let me know...
Thanks...
Nick
------------------------------
Date: 30 Jun 2003 05:11:11 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: Sending the "down" key via Expect
Message-Id: <3effc66f$0$205$75868355@news.frii.net>
Nick Leeson <nickleeson78@yahoo.com> wrote:
NL> Hi,
NL> I am using an expect script to interact with lynx running on a remote
NL> server.I am trying to figure out how to send the direction keys
NL> ...left(->), right(<-),up and down keys....I know i need to send their
NL> equivalent ASCII values..but what would they be?
NL> Please let me know...
Try this in your machine:
$ cat | od -c
^[[B <-- arrow down, then ENTER
0000000 033 [ B \n
0000004
Looks like 033 (octal), '[', and 'B' here.
Regards,
Nicholas
--
"Why shouldn't I top-post?" http://www.aglami.com/tpfaq.html
"Meanings are another story." http://www.ifas.org/wa/glossolalia.html
------------------------------
Date: 30 Jun 2003 01:38:15 -0700
From: fatted@yahoo.com (fatted)
Subject: Speed of file vrs dbase access
Message-Id: <4eb7646d.0306300038.2be15c80@posting.google.com>
A request for some data is processed by my perl script. The data is
currently stored in plain text files on a linux system. Each file's
data contains less than 600 characters. The data from 3 files will be
required (read into the script) per request. I now have the
opportunity, to place the data in a MySQL table. A database handle
(using the DBI module) is already opened to the database where this
new table would be stored.(MySQL database and data files are stored on
machine where perl script is run).
Would database access be quicker or slower than direct file access to
the current linux files?
------------------------------
Date: 30 Jun 2003 00:03:45 -0700
From: tivolinewbie@canada.com (Kenjis Kaan)
Subject: Storable module for Activestate 5.6.1??
Message-Id: <6a8ba9f8.0306292303.5259f69b@posting.google.com>
I am running Activestate Perl 5.6.1 and wanted to install the Storable
module. HOwever, from PPM, I tried to install and it replied.
"Error installing package 'Storable': Could not locate a PPD file for
package Storable"
I really think the package already exists for Activestate, but can't
seem to install it nor able to find the ppd for it. Anybody know?
------------------------------
Date: Mon, 30 Jun 2003 17:33:11 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Storable module for Activestate 5.6.1??
Message-Id: <3effe8ec$0$22124@echo-01.iinet.net.au>
"Kenjis Kaan" <tivolinewbie@canada.com> wrote in message
news:6a8ba9f8.0306292303.5259f69b@posting.google.com...
> I am running Activestate Perl 5.6.1 and wanted to install the Storable
> module. HOwever, from PPM, I tried to install and it replied.
> "Error installing package 'Storable': Could not locate a PPD file for
> package Storable"
>
> I really think the package already exists for Activestate, but can't
> seem to install it nor able to find the ppd for it. Anybody know?
ActiveState certainly have this package. There is apparently some problem
with the functionality of your ppm installation. (I think there is a number
of possible causes for receiving this error.)
Does 'ppm search Storable' report that it exists ?
You could download Storable.zip from
http://ppm.activestate.com/PPMPackages/zips/6xx-builds-only/
and then try a local ppm install (as per instructions in the readme). At
least you'll then have the blib (it's in the MSWin32 '.tar.gz') that Randy
spoke of - which you can deal with manually if need be. (Note that the
version of Storable obtained this way might not be as recent as the version
contained in the AS repository.)
For problems with ppm, ActiveState has a 'ppm' mailing list - if you don't
get the problem resolved here.
Best to get it fixed.
Cheers,
Rob
------------------------------
Date: 30 Jun 2003 02:56:51 -0700
From: davidmcguinness@dublin.ie (Dave from Dublin)
Subject: String matching not working
Message-Id: <9d18d9fe.0306300156.1482a28c@posting.google.com>
Hi,
I am quite new to Perl. I have several sets of data and within each
individual file news stories are seperated using ========.
My goal is to recreate each file without this divider. Eventually I
will look to iterate through the whole directory but for now I just
want to print all lines but the divider into a new file for one file
(1.ref)
But it's not working, all lines are being printed. Can anyone tell me
what's wrong (see code below), NOTE the ELSE is just a test
Thanks,
David
#!/usr/bin/perl
open(FILEREAD, "< 1.ref");
open(FILEWRITE, "> 1a.ref");
while (<FILEREAD>){
chop ( $line );
if ($line !=~ /====/ ){
print FILEWRITE;
}
else{
print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
}
}
close FILEWRITE;
close FILEREAD;
------------------------------
Date: 29 Jun 2003 23:43:42 -0700
From: cdcer@hongkong.com (ABC)
Subject: Using filehandle many times
Message-Id: <d618a781.0306292243.21381f0f@posting.google.com>
print on closed filehandle main::DST at tempQGen line 71, <SRC> chunk
28.
I understand the meaning of this error message, but I want to know how
to solve it?
How could I open and close this filehandle many times inside a
for-loop? Or how could I clear the filehandle?
Thanks.
------------------------------
Date: 30 Jun 2003 01:42:19 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Using perl/shell scripts to kill processes more than x days old
Message-Id: <slrnbfv5bt.3er.mgjv@verbruggen.comdyn.com.au>
On Sat, 28 Jun 2003 16:30:13 GMT,
Walt Fles <wefles@ameritech.net> wrote:
[fixed Jeopardy style post]
> "Jimmy" <jimmy_mcnamara@hotmail.com> wrote in message
> news:e08ac7c8.0306270541.55c20f09@posting.google.com...
>> Hi Folks,
>>
>> OS : Solaris 8
>>
>> I have a question regarding killing processes on a unix server. I
>> would like to run a cron job to kill processes run by certain binaries
>> that are more than 2 weeks old. I had a look at using the awk combined
>> with the output of ps but this doesn'tgive me what I want as the
>> output of ps is limited in what
>> it outputs as a start date of the process. Has anyone used perl or
>> shell scripting to come up with a nice way of doing this.
If you use ps, it's probably best to use the -o option (look at etime,
so your output is a bit more predictable, and probably easier to use.
> Your best bet is to go into /proc and disect the data yourself, instead of
> relying on what formatting commands ( ie, ps ) gives you.
Perl specific:
If you want to use the /proc filesystem on Solaris, you're probably
best off using the Proc::ProcessTable module, which does all of the
handling of the structs stored there for you.
Martien
--
|
Martien Verbruggen | +++ Out of Cheese Error +++ Reinstall
Trading Post Australia | Universe and Reboot +++
|
------------------------------
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 5154
***************************************