[7238] in Perl-Users-Digest
Perl-Users Digest, Issue: 863 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 13 21:07:20 1997
Date: Wed, 13 Aug 97 18:00:29 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 13 Aug 1997 Volume: 8 Number: 863
Today's topics:
-MConfig perl flag <pesybase@newbridge.com>
Re: Amending A database [help] (brian d foy)
associative array question <xkn14@dial.pipex.com>
Building Perl <romeyde@mc0115.mcclellan.af.mil>
Re: Comma Delimited Proggy Example (Tad McClellan)
Experiments fail for stdin/stdout piping - help! <jmasters@pcocd2.intel.com>
Re: filehandles (Jeff Stampes)
Re: Help, this script is killing me... <rootbeer@teleport.com>
Re: How to/is handle/ed mutliple inheritance in constru <sgermain@nortel.ca>
Re: HTTP proxy server in perl? (Xtra)
Re: I can't make my sentence appear when I want (Paco Hope)
Macperl and server errors <aijon@grn.es>
Mostlikley a cgi question (David Siebert)
Re: Need help! (Sami Sandqvist)
need majordomo setup advise alvarez@acunet.net
Re: New User Question on FTP <rootbeer@teleport.com>
Newbie: testing perl on a mac without server and browse (Arthur Sauer)
Novice scratches head (Mike McCurdy)
Re: Novice scratches head <rootbeer@teleport.com>
Re: Odd perl quirk? <rootbeer@teleport.com>
Odd problems with GD with perl 5.003 on windows. (Fergus McMenemie)
Parser for CSS? (Michael Schuerig)
Re: Perl Interface to /etc/passwd <ron@ckm.ucsf.edu>
Random Number question <temp.ed.vanderbush@bentley.com>
Re: Serial Port Access <newman@ttd.teradyne.com>
Re: signals and EOF <psrc@corp.airmedia.com>
Re: split perl string (Nathan V. Patwardhan)
Re: UNC Filenames on Win95 <cdumas@ibm.net>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 13 Aug 1997 18:12:06 -0400
From: Nancy Devin <pesybase@newbridge.com>
Subject: -MConfig perl flag
Message-Id: <33F23136.2EF4@newbridge.com>
Hi everyone,
I am just starting using perl and I am trying to
embed perl code into a C++ program. I found out
in some documentation that if I want to list
all the libraries I need to link, I can enter the
following command:
perl -MConfig -e 'print $Config{libs}'
Sadly I receive the message
Unrecognized switch: -MConfig
I am working on sun solaris 2.51 and
I am running perl 5.001
Can someboby tells me want command should I use
and/or which libraries I need to link.
Rigth now my program does not recognize
perl_eval_sv(newSVpv(string,0),G_DISCARD)
Thanks in advance,
Nancy
------------------------------
Date: Wed, 13 Aug 1997 20:51:29 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Amending A database [help]
Message-Id: <comdog-ya02408000R1308972051290001@netnews.worldnet.att.net>
In article <5stjdr$gjt@news1.infoave.net>, ranson@infoave.net wrote:
> I have a challenge that I have no idea how to do. I am
> writing a shoping cart program for a gem dealer and have to
> amend the data every time someone orders a stone or stones.
> So that the quantity available is always correct to the user.
> The fields [7] are comma delinated, and the last field is the quantity.
>
> Some tips on doing this would be greatly appricated. A sample of the
> data is below.
> 20600:African Amethyst:6mm Rd:20600.jpg:2.75:each:50
if you want to do flat file stuff (not fixed length records) you can:
* read in the file
* store the data (as some abstracted object perhaps)
* manipulate the data
* rewrite the file
or you can opt for fixed length records (padded if necessary)
which would allow you to edit in place, but that requires you to do
a lot more work (like a lookup scheme for the different products).
Perl has interfaces to lots of different database products that will
make your life simpler. poke around CPAN [1] to see what you like :)
[1] Comprehensive Perl Archive Network multiplexer
<URL:http://www.perl.com/CPAN/>
--
brian d foy <URL:http://computerdog.com>
------------------------------
Date: 13 Aug 1997 23:15:09 GMT
From: "Jon Marshall" <xkn14@dial.pipex.com>
Subject: associative array question
Message-Id: <01bca83e$6b6d5fa0$28f882c1@jon>
please could someone point me in the right direction !!!
i am looping through a number of projects one at a time. i am adding up
the total size of the files in each project while at the same time adding
up
the size of groups of similar files within the project. all this is fine -
i end
up with an associative array with the type of file being the key to the
size.
ie.
@filetypes = qw( 3dv cd 3dh );
foreach $project ( @projects ) {
@files = `find /disk/seisworks/*/$project -type f -ls`;
for ( @files ) {
($size,$name) = (split)[6,10];
foreach $type ( @filetypes ) {
if ( $name =~ /$type$/ ) {
$count{$type} += $size;
}
}
$totalsize += $size;
}
}
the problem comes in printing - is there an easy way to print the project
name, the total, and the sizes of the files on the same line in a nice
format-
i need to know which size relates to which filetype because there will be
headings
in the report. I can do this by just adding up the filetypes into separate
variables
but i would like to make this easy to update for myself & others and it
looks very
messy if there are a lot of filetypes which there will be.
Sorry to go on - any help would be greatly appreciated
Jon
------------------------------
Date: Wed, 13 Aug 1997 15:07:43 -0700
From: Derek Romeyn <romeyde@mc0115.mcclellan.af.mil>
Subject: Building Perl
Message-Id: <33F2302F.F0D77ADE@mc0115.mcclellan.af.mil>
Been trying to build perl 5.004 on a HP-UX running 10.10 for the last
two days and getting really annoyed at my stupidity.
Have been getting various compile errors and the majority of them seem
to revolve around ld. Here is the one that pops up most.
----
gcc -L/usr/local/lib -L/opt/binutils/lib -L/usr/lib -o miniperl
miniperlmain.o libperl.a
collect2: ld returned 1 exit status
/usr/bin/ld: Unsatisfied symbols:
sin (code)
cos (code)
__builtin_va_start (code)
log (code)
atan2 (code)
exp (code)
floor (code)
sqrt (code)
pow (code)
make: *** [miniperl] Error 1
----
Anyone want to point me in a direction? I did manage to compile it once
without these errors but then the 'make test' failed on IO.
I am using gcc version 2.7.2.2 to compile. Reply here but a cc via
email would be appreciated.
--
... Derek W Romeyn..................LinuX, it's not just for breakfast
... NCI Information Systems, Inc..............anymore. Ask for it by
... romeyde@deepwell.com.......................................NAME!!!
------------------------------
Date: Wed, 13 Aug 1997 16:49:34 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Comma Delimited Proggy Example
Message-Id: <e5ats5.u7a.ln@localhost>
Ed Paquette (ed@ncia.net) wrote:
: I'd like to find a small Perl script that shows examples for dealing
: with comma delimited files in the following ways:
: - Reading lines
: - Changing certain fields
: - Adding lines
: - Deleting lines
: Anyone know where I can find something like this?
Maybe you want a pre-invented wheel like the Text::CSV module?
(Comma Separated Values)
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 13 Aug 1997 15:56:47 -0700
From: Justin Masters - MPG DA Support <jmasters@pcocd2.intel.com>
Subject: Experiments fail for stdin/stdout piping - help!
Message-Id: <cav4t8tk7yo.fsf@fri035.fm.intel.com>
I'm trying to use open2 for sending interactive commands to a program, and
getting responses back from it.
I wrote a quick program foo.pl that says:
#!/usr/local/bin/perl
$| = 1;
while (<STDIN>) {
if (!/FOOBAR/) {
$foo = $_;
system("$foo");
}
}
I can run it, and type 'ls' and see results, 'pwd' and get results,
etc in an interactive manner.
So then I created a quick program (using stuff on pg456 of the blue camel
book regarding open2, called bar.pl which says:
#!/usr/local/bin/perl
$| = 1;
$/ = '';
use Symbol;
use IPC::Open2;
$WTR = gensym();
$RDR = gensym();
$pid = open2(\*RDR, \*WTR, "foo.pl");
while(<STDIN>) {
print $WTR $_;
$line = <$RDR>;
print STDOUT "$line";
}
The program won't get past the STDIN in query on bar.pl until I enter a
^D, which I believe will pass it on to foo.pl. Trying to add a -d
flag to the foo.pl perl line seems to not allow me to run debuggers "2
deep", but I think the bar.pl buffering would make it difficult.
Anyway, I want foo.pl to "simulate" an interactive program that takes
input, spits out the output, which I could potentially react to, and enter
new commands for.
Can anybody understand why this won't work? I tried using bar.pl on a real
program before running this test, and it made it partway through the calling
program and then suddenly stopped. I havent' figured out why yet, although
I wonder if there is an input buffer issues, as the initial output from the
program is quite lengthy.
any ideas?
Justin
--
------------------------------------------------------------------------------
Justin Masters (Sr. Cad Engineer - Design Automation) PH: 916-356-6735
Intel Corp. FM5-94 FAX: 916 356-7874
1900 Prairie City Rd, Folsom, CA 95630 jmasters@pcocd2.intel.com
------------------------------
Date: 13 Aug 1997 21:46:19 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: filehandles
Message-Id: <5st9vb$rg6$1@neocad.com>
denis@mathi.uni-heidelberg.de wrote:
: i try to hand a filehandle over to a subroutine. only the name arives..
: how can i correct this?
There is a section in the FAQ on files and Filehandles, and one
of the questions is:
How can I make a filehandle local to a subroutine? How do I
pass filehandles between subroutines? How do I make an
array of filehandles?
You may have some success with typeglobs, as we always had
to use in days of old:
local(*FH);
But while still supported, that isn't the best to go about
getting local filehandles. Typeglobs have their drawbacks.
You may well want to use the FileHandle module, which
creates new filehandles for you (see the FileHandle
manpage):
use FileHandle;
sub findme {
my $fh = FileHandle->new();
open($fh, "</etc/hosts") or die "no /etc/hosts: $!";
while (<$fh>) {
print if /\b127\.(0\.0\.)?1\b/;
}
# $fh automatically closes/disappears here
}
Internally, Perl believes filehandles to be of class
IO::Handle. You may use that module directly if you'd like
(see the IO::Handle manpage), or one of its more specific
derived classes.
Once you have IO::File or FileHandle objects, you can pass
them between subroutines or store them in hashes as you
would any other scalar values:
use FileHandle;
# Storing filehandles in a hash and array
foreach $filename (@names) {
my $fh = new FileHandle($filename) or die;
$file{$filename} = $fh;
push(@files, $fh);
}
# Using the filehandles in the array
foreach $file (@files) {
print $file "Testing\n";
}
# You have to do the { } ugliness when you're specifying the
# filehandle by anything other than a simple scalar variable.
print { $files[2] } "Testing\n";
# Passing filehandles to subroutines
sub debug {
my $filehandle = shift;
printf $filehandle "DEBUG: ", @_;
}
debug($fh, "Testing\n");
Please get yourself a copy of the latest FAQ and perl documentation
(Provided free with the latest current 5.004 distribution). Most of
these types of questions are handled in there.
Cheers,
Jeff
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: Wed, 13 Aug 1997 15:49:03 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Stephon <stephon@hempseed.com>
Subject: Re: Help, this script is killing me...
Message-Id: <Pine.GSO.3.96.970813154515.18496P-100000@julie.teleport.com>
On Tue, 12 Aug 1997, Stephon wrote:
> open (PIC, "$graphics");
When your script isn't working, one of the reasons might be that open is
failing. Is this one failing? There's no way for your script to let you
know if it is! It's important to always check the return value of open.
(Also, those double quotes are merely misleading.)
> # Opening Log for Search #########################################
> open (LOG, "$logfile");
> @log = <LOG>;
> close (LOG);
>
> # Searching Log for Current File Access Count ####################
> open(LOG,">$logfile");
Do you know what happens if two processes try to access this file at the
same time? That would be bad. :-)
I think you could use the methods in Randal's fourth Web Techniques
column, which explains how to use flock() to avoid problems when multiple
processes need to modify one file. Hope this helps!
http://www.stonehenge.com/merlyn/WebTechniques/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 13 Aug 1997 16:59:53 -0400
From: "Sylvain St.Germain" <sgermain@nortel.ca>
Subject: Re: How to/is handle/ed mutliple inheritance in constructor?
Message-Id: <33F22049.6AAE@nortel.ca>
To who it may interest...
It calls the first defined function in the ISA array.
Sylvain St-Germain
Sylvain St.Germain wrote:
>
> Hi all,
>
> Let's say we have a base class (ClassA) and a derived classes
>
> ClassA
> |- ClassB
>
> In new of B I have:
> sub new {
> my $that = shift;
> my $type = ref($that) || $that;
> my @args = @_;
> my $self = $type->SUPER::new(@args[0]);
> ...
> }
>
> The question is, what do I do if a new class (ClassC - which also define
> a function called new) arrives and become the parent of ClassB as
> well??
>
> I intend to try it but in case someone knows (I am sure!)...
>
> Will perl look for a new functions is all the first level ancestors?
>
> Regards,
> Sylvain.
------------------------------
Date: Wed, 13 Aug 1997 22:49:59 GMT
From: xxx@no.spam.mclv.net (Xtra)
Subject: Re: HTTP proxy server in perl?
Message-Id: <33f239da.3818379@news.lvdi.net>
Check out:
http://www.stonehenge.com/merlyn/WebTechniques/
darrellb@hhcl.com (Darrell Berry) wrote:
>Can anyone point me at one? Nothing fancy, I just want the skeleton to
>play with...in particular I am looking for proxy code which can build a
>database of visited links, rather than offer a caching service, but
>anything I can hack is fine ;-)
>
>cheers!
>
>pls email responses...
------------------------------
Date: Wed, 13 Aug 1997 21:46:59 GMT
From: bah6f@cs.virginia.edu (Paco Hope)
To: havliogc@cs.man.ac.uk (C E Havlioglu)
Subject: Re: I can't make my sentence appear when I want
Message-Id: <5sta0j$t7i@casper.cs.Virginia.EDU>
havliogc@cs.man.ac.uk (C E Havlioglu) writes:
: I wan't it to write
: Reading URL...
: do the sockets stuff (which takes seconds) and when finished write
: ^^^^^^^^
: done
Make your stdout unbuffered.
Add this near the top of your program:
select STDOUT; $| = 1;
The problem has nothing to do with perl. Your operating system
buffers writes to stdout until it feels like printing them out.
Once you have written enough, or when your program exits, it
flushes stdout and writes all the things you told it to.
By adding the commands above, you make stdout unbuffered. I.e.
the output buffer is flushed every time you write to it.
Cheers,
Paco
--
Paco Hope Computer Systems Engineer
paco@cs.virginia.edu Department of Computer Science
http://www.cs.virginia.edu/~bah6f/ University of Virginia
------------------------------
Date: Wed, 13 Aug 1997 12:04:06 +0100
From: Alfonso Aijsn <aijon@grn.es>
Subject: Macperl and server errors
Message-Id: <33F194A2.497D@grn.es>
hi everybody,
I'm trying to run the free machintosh server Quidpro quo with Macperl
scripts.
The problem is I allways get server errors.
I've saved my scripts as Droplets AND cgi Scripts, same thing.
Should Macperl be in the cgi-bin or not?Where should it be?
Anyone knows about that?
Thanks
------------------------------
Date: 13 Aug 1997 22:10:59 GMT
From: dsiebert@gate.net (David Siebert)
Subject: Mostlikley a cgi question
Message-Id: <5stbdj$1eq4$1@news.gate.net>
I am using the cookie.lib to set a cookie and that works fine. Whne I try to
reset the cookie it doesn't work. The cookie never gets updated. any ideas.
------------------------------
Date: 13 Aug 1997 18:36:03 GMT
From: sami@d246a.mtalo.ton.tut.fi (Sami Sandqvist)
Subject: Re: Need help!
Message-Id: <slrn5v3vmf.2sk.sami@d246a.mtalo.ton.tut.fi>
On Wed, 13 Aug 1997 13:12:52 -0400, Thad Welch
<tw36027@glaxowellcome.com>
wrote:
>Here's my solution:
>
>chop( $line = <STDIN> );
>print "\nline='$line'";
>
>Craig Martin wrote:
>
>> Hi There,
>>
>> My name is Craig Martin and I currently work for an ISP in Toronto,
>> Ontario, Canada. I am trying to write a simple little PERL script that
>>
>> will let the user know how many e-mail messages he has. The way the
>> script is to work is that you call up the script and it asks for what
>> e-mail account they want the information. Then it reads in the info,
[SNIP]
Have you considered that the users should only be able to read their
own mailboxes? In that case, check out $ENV{MAIL} and $ENV{LOGNAME}
etc. You may find something useful if the users have a default shell
on your ISP.
Sami
--
#################################################
#Sami Sandqvist #Finger for PGP key #
#samiss@cc.tut.fi # #
#################################################
------------------------------
Date: Wed, 13 Aug 1997 18:01:14 -0600
From: alvarez@acunet.net
Subject: need majordomo setup advise
Message-Id: <871513058.11167@dejanews.com>
Hi All,
Majordomo was setup by another person.
We are using version 1.94.3 of Majordomo.
Majordomo works fine, except that i have to
create a new mailing list now for the first time
and have encountered a little difficulty.
I would really appreciate any hints on solving this
problem. I will try to explain it the best that i can.
I created a mailing list called "soi" which
stands "Sounds of India"
The configuration for that list is located at:
/usr/local/majordomo/lists/more soi.config
I added an alias for the soi mailing list in the following file:
/var/adm/sendmail/majordomo.aliases
> #soi
> #########################################################
> # list subscriber file: /usr/local/majordomo/lists/soi
> # list admin password: /usr/local/majordomo/lists/soi.passwd
> # list information file: /usr/local/majordomo/lists/soi.info
> #########################################################
> soi: "|/usr/local/majordomo/wrapper resend -l soi soi-list"
> soi-list: :include:/usr/local/majordomo/lists/soi
> owner-soi: majordomo-owner
> soi-owner: owner-soi
> soi-request: "|/usr/local/majordomo/wrapper majordomo -l soi"
> soi-approval: owner-soi
> #END SOI
There are 7 aliases in the above file, but the
newaliases command reports only 6 aliases. I wonder
why? What am i missing?
Finally, when i try to send a message to the soi list
that message never bounces back to me, it
gets stuck the root's email account. Detail follows:
>From MAILER-DAEMON Wed Aug 13 17:48:30 1997
>Date: Wed, 13 Aug 1997 17:48:30 -0400 (EDT)
>From: Mail Delivery Subsystem <MAILER-DAEMON>
>Subject: Postmaster notify: User unknown
>To: postmaster
>Auto-Submitted: auto-generated (postmaster-notification)
>
>The original message was received at Wed, 13 Aug 1997 17:48:30 -0400
(EDT)
>from majordom@localhost
>
> ----- The following addresses had permanent fatal errors -----
>owner-Sounds-of-India@tortola.acunet.net
>
> ----- Transcript of session follows -----
>550 owner-Sounds-of-India@tortola.acunet.net... User unknown
>550 owner-Sounds-of-India@tortola.acunet.net... User unknown
>
> ----- Original message follows -----
>
>Return-Path: <owner-Sounds-of-India@tortola.acunet.net>
>Received: by tortola.acunet.net (8.8.6/1.1.10.5/11Jul97-0513PM)
> id RAA15311; Wed, 13 Aug 1997 17:48:30 -0400 (EDT)
>Date: Wed, 13 Aug 1997 17:48:30 -0400 (EDT)
>From: <owner-Sounds-of-India@tortola.acunet.net>
>Message-Id: <199708132148.RAA15311@tortola.acunet.net>
>To: owner-Sounds-of-India@tortola.acunet.net
>Subject: BOUNCE soi@tortola.acunet.net: Approval required:
>
>>From majordomo-owner Wed Aug 13 17:48:29 1997
>Received: from acunet.net by tortola.acunet.net
(8.8.6/1.1.10.5/11Jul97-0513PM)
> id RAA14879; Wed, 13 Aug 1997 17:48:28 -0400 (EDT)
>Received: from HARVEYPC (tonypc.acunet.net [208.203.130.6])
> by acunet.net (8.8.4/8.8.4) with SMTP
> id RAA16302 for <soi@tortola.acunet.net>; Wed, 13 Aug 1997
17:45:04 -0400 (EDT)
>Message-Id: <1.5.4.32.19970813214403.00918f24@acunet.net>
>X-Sender: alvarez@acunet.net
>X-Mailer: Windows Eudora Light Version 1.5.4 (32)
>Mime-Version: 1.0
>Content-Type: text/plain; charset="us-ascii"
>Date: Wed, 13 Aug 1997 17:44:03 -0400
>To: soi@tortola.acunet.net
>From: Anthony Alvarez <alvarez@acunet.net>
>Subject: POPULUS daily humor!
>
>test
>
>--
Could you please give me a hint as to solving this problem?
I think the problem is in
/usr/var/adm/sendmail/majordomo.aliases
Please advise. Thank you.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Wed, 13 Aug 1997 14:33:03 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Edward Bidinotto <edbid@cobe.com>
Subject: Re: New User Question on FTP
Message-Id: <Pine.GSO.3.96.970813142856.18496J-100000@julie.teleport.com>
On Wed, 13 Aug 1997, Edward Bidinotto wrote:
> Subject: New User Question on FTP
Contrary to popular belief, it's not vital that new users declare
themselves as such. :-)
> I am new to perl and trying to do the following:
>
> If (some condition)
> # Ftp over to a server
> # Login as a user
> # Pass in a passwd
> # Put a file via FTP
> exit
If I needed to do this, I'd use a module which already knows how to speak
the FTP protocol. I would just tell it things like what server, username,
and password to use, and it would do all of the work. There should be a
good module on CPAN, where the good stuff lives. Hope this helps!
http://www.perl.com/CPAN/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 14 Aug 1997 00:11:52 +0100
From: arthur@sauer.demon.nl (Arthur Sauer)
Subject: Newbie: testing perl on a mac without server and browser
Message-Id: <arthur-1408970011520001@sauer.demon.nl>
Is there a way to test perl on a 68k mac without a server and a browser to
test for anstance a FORM sended with POST.
Is there a handy piece of software written for it?
--
------------------- Arthur Sauer -------------------
------------------------------
Date: Wed, 13 Aug 1997 15:11:04 -0700
From: mccurdy@rohan.sdsu.edu (Mike McCurdy)
Subject: Novice scratches head
Message-Id: <MPG.e5bd0d416430862989683@newshub.sdsu.edu>
My understanding was that perl would treat these variables as integers
when used like this. Given that $x's value is not equal to 100000, why is
$x being printed? TIA ...
#!/usr/local/bin/perl
$x = system "/usr/bin/sar -r 1 | tail -1 | cut -c26-32";
if ($x == 100000) {
print $x;
}
--
Mike McCurdy
Oracle/AIX administration
San Diego State University/University Computer Operations
mccurdy@rohan.sdsu.edu 619-594-4653
------------------------------
Date: Wed, 13 Aug 1997 16:06:00 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mike McCurdy <mccurdy@rohan.sdsu.edu>
Subject: Re: Novice scratches head
Message-Id: <Pine.GSO.3.96.970813160054.18496Q-100000@julie.teleport.com>
On Wed, 13 Aug 1997, Mike McCurdy wrote:
> My understanding was that perl would treat these variables as integers
> when used like this. Given that $x's value is not equal to 100000, why is
> $x being printed? TIA ...
>
>
> #!/usr/local/bin/perl
> $x = system "/usr/bin/sar -r 1 | tail -1 | cut -c26-32";
Now, you know that $x is _not_ derived from the output of any of those
commands. Right?
> if ($x == 100000) {
> print $x;
> }
I don't think that Perl is going to print anything there but 100000. But
the system command may print something. Could that be what you're seeing?
(If not, then don't keep me in suspense any longer: What's $x? :-)
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 13 Aug 1997 14:44:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: scott mcclurg <smcclurg@inet.net>
Subject: Re: Odd perl quirk?
Message-Id: <Pine.GSO.3.96.970813144012.18496K-100000@julie.teleport.com>
On Wed, 13 Aug 1997, scott mcclurg wrote:
> The following bit of code works for all letters except the letter j:
> for($dir = 'a';$dir ne 'aa';$dir++) {
> print ("Directory $dir follows...\n");
> print `find /export/home/www/$dir*/public_html -name index.html`;
> }
If you have many directories which start with j (or any other letter),
that could become a _monstrous_ glob. If it makes the command line longer
than the maximum length allowed for your system, there's your problem.
Of course, anything that find can do, Perl can do better. :-) So why not
just have Perl look for those files itself? It's better than starting all
of those slow-running processes.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 13 Aug 1997 21:42:03 +0100
From: fergus@twig.demon.co.uk (Fergus McMenemie)
Subject: Odd problems with GD with perl 5.003 on windows.
Message-Id: <199708132142031098168@twig.demon.co.uk>
Hello all
I am used to using GD with perl on unix platforms without
too much bother. However on windows GD doesnt seem to work
as specified in my docs. After creating my image in $im I
normally do something like:-
open(OUT,">out.out") || die;
binmode (OUT);
print OUT $im->gif;
close(OUT);
to save the image I have created to a file. However on windows
the gif data always appears on standard output!
After lots and lots of trail and error it seems I have to use:-
$im->out("out.out");
Why? I write and develop my scripts on UNIX and for the most
part they port without change to Mac and PC.
--
======================================================================
Fergus McMenemie Email:fergus@twig.demon.co.uk
Technology Basis
======================================================================
------------------------------
Date: Wed, 13 Aug 1997 23:10:10 +0100
From: uzs90z@uni-bonn.de (Michael Schuerig)
Subject: Parser for CSS?
Message-Id: <1997081323101058618@rhrz-isdn3-p11.rhrz.uni-bonn.de>
Has someone already written a parser for cascading style sheets?
Michael
--
Michael Schuerig Most people would rather die than think.
mailto:uzs90z@uni-bonn.de In fact, they do.
http://www.uni-bonn.de/~uzs90z/ -Bertrand Russell
------------------------------
Date: Wed, 13 Aug 1997 14:24:50 -0700
From: Ron Klatchko <ron@ckm.ucsf.edu>
To: Dave Regan <regan@office.ao.com>
Subject: Re: Perl Interface to /etc/passwd
Message-Id: <33F22622.1E6E@ckm.ucsf.edu>
One minor point:
Dave Regan wrote:
> There are 64 possible salt values. Thus, you can still do a dictionary
> attack, but you need 64 dictionaries.
There are 4096 (64 ^ 2) possible salt choices.
moo
----------------------------------------------------------------------
Ron Klatchko - Senior Software Engineer
UCSF Library and Center for Knowledge Management
ron@ckm.ucsf.edu
------------------------------
Date: Wed, 13 Aug 1997 09:21:58 -0400
From: Ed Vander Bush <temp.ed.vanderbush@bentley.com>
Subject: Random Number question
Message-Id: <33F1B4F6.7AD7@bentley.com>
I am tring to choose a random 20 digit number and make sure that is
already hasn't been used (he lit of used ones is in a file. I can chhose
a random number rand 99999999999999999999 but that will give my numbers
other than 20 digits. How can I make sure it hasn't been used. Thanks.
------------------------------
Date: Wed, 13 Aug 1997 14:19:51 -0500
From: Aaron D Newman <newman@ttd.teradyne.com>
Subject: Re: Serial Port Access
Message-Id: <33F208D7.34AC@ttd.teradyne.com>
Yes, there is. I have done it under both solaris and Linux.
Basically you need to use 'pack' and 'unpack' to set up the TCGETA and
TCSETA structures and call the Perl fcntl primitive to set baud rate,
etc. Here is some code to get you started; you can get the magic
numbers (B300 etc) from your /usr/include files.
Aaron
#These are right for my Linux box.
$O_RDWR = 2;
$O_NDELAY = 04000;
$O_NONBLOCK = 04000;
$CS8=0x30;
$CREAD = 0x80;
$CLOCAL = 0x800;
$VMIN = 6;
$VTIME = 5;
$PARODD = 00000100;
$PARENB = 00000400;
$F_SETFL = 4;
$F_GETFL = 3;
$c_iflag = 0;
$c_oflag = $c_lflag = 0;
$c_cflag = 0x0;
$TCSETAW = 0x5407;
$TSGETA = 0x5405;
$TCFLSH = 0x540b;
$B0 =0;
$B50 =1;
$B75 =2;
$B110 =3;
$B134 =4;
$B150 =5;
$B200 =6;
$B300 =7;
$B600 =8;
$B1200 =9;
$B1800 =10;
$B2400 =11;
$B4800 =12;
$B9600 =13;
$B19200 =14;
###########################
#open_tty: opens a communications port
#synopsis: $modem = open_tty($dev,[$baud]);
#desc: opens the device and makes the proper IOCTL
# calls
#example: $modem = open_tty("/dev/ttyb",9600);
#returns: the modem file descriptor
#########################
sub open_tty {
local($bdflag,$MODEM,$oldfh);
local($dev,$baud) = @_;
$bdflag = 0;
$bdflag = $B300 if ($baud == 300);
$bdflag = $B1200 if ($baud== 1200);
$bdflag = $B2400 if ($baud == 2400);
$bdflag = $B9600 if ($baud == 9600);
$bdflag = $B19200 if ($baud == 19200);
$bdflag = $B38400 if ($baud == 28800);
$bdflag = $B38400 if ($baud == 38400);
$BAUD = $baud;
print "Opening $dev at $baud baud\n";
$SIG{'INT'}='handler';
open(MODEM,"+>$dev") || die "ouch $!";
$gttyb_t = "SSSScC8";
#open the output port
select((select(MODEM),$| = 1)[0]); # unbuffer pipe
$oldf = fcntl(MODEM,$F_GETFL,0);
fcntl(MODEM,$F_SETFL,$oldf | ( $O_NDELAY|$O_NONBLOCK));
ioctl(MODEM,$TCFLSH,2);
ioctl(MODEM,$TCGETA,$gttyb);
@ary = unpack($gttyb_t,$gttyb);
$ary[0]=$c_iflag;
$ary[1]=$c_oflag;
$ary[2]= $CS8 | $bdflag | $CREAD | $CLOCAL;
$ary[3] =$c_lflag;
$gttyb = pack($gttyb_t,@ary);
@ary = unpack($gttyb_t,$gttyb);
ioctl(MODEM,$TCSETAW,$gttyb);
sleep(2);
# print "c\n";
(MODEM);
}
Todd C. Sepke wrote:
>
> I was woundering if there is any way to access the serial port in linux
> with perl.
>
> I want to attach a serial port cable and insert the loose wires in a
> breadboard, so I can use my computer to control circuits that I build.
>
> Thanks in advance.
>
> --
> -------------------------------------------------------------------
> Todd C. Sepke | |
> 686 E. McDonel, MSU | How can anyone be enlightened, |
> E. Lansing, MI 48825 | Truth is after all so poorly light. |
> 353-1275 | |
> -------------------------------------------------------------------
--
---------------------------------------------------------------------
| newman@ttd.teradyne.com | "A forest is a finite |
| | (possibly empty) set of |
|http://www.ttd.teradyne.com/~newman | trees." - Baase |
---------------------------------------------------------------------
------------------------------
Date: Wed, 13 Aug 1997 18:19:57 -0400
From: Paul S R Chisholm <psrc@corp.airmedia.com>
Subject: Re: signals and EOF
Message-Id: <33F2330D.5853@corp.airmedia.com>
In article <33EB868D.7B7C@corp.airmedia.com>, Paul S R Chisholm
<psrc@corp.airmedia.com> ... that's me ... complained about not being
able to have:
$_ = <STDIN>;
work well in the face of signals. (The problem was, the script is
reading standard input, but needs to re-read a configuration file when
receiving a SIGHUP. The signal was causing <STDIN> to report EOF, and to
lose data even after working around the spurious EOF.)
Charles DeRykus posted an example that showed me the way to go: use
sysread(STDIN) instead of <STDIN>. Here's what I came up with:
# get the original configuration file
if (! read_config()) {
die("$0: cannot read configuration file(s)");
}
# ... and again on SIGHUP
$SIG{"HUP"} = sub { read_config(); };
# look at standard input, send matching lines to e-mail
# use sysread(0), not <STDIN>, to handle interrupts better
my $buf = "";
my $eintr = EINTR; # value of $! for interrupted read (from POSIX)
while (1) {
# read some stuff
my $read = sysread(STDIN, $buf, (1024*8), length($buf));
if (! defined($read)) {
if ($! == $eintr) {
print "DEBUG: saw EINTR!\n";
next; # interrupted read, continue with loop
} else {
warn("$0 cannot read standard input: $!");
last; # probably can't read any more
}
} elsif ($read == 0) {
last; # true end-of-file
}
# for all the lines in the buffer ...
while ($buf =~ s/^(.*)\n//) {
# process line in $1
}
}
This is a Perl idiom of mine: reading into a buffer, then grabbing lines
out of the buffer. (It's a good way to do a line-by-line "tail -f", too,
since it doesn't involve stdio's idea of EOF.)
All the cruft about a "saw signal" variable is gone; the script works
fine without it.
The really crazy thing is, I never see the "DEBUG: saw EINTR!" message.
It's as if, after catching the signal, the process silently restarts the
sysread(). That's convenient here, but it would be a pain in the rear if
the signal was a SIGALRM, trying to make the sysread() time out!
For the curious:
$ perl -v
This is perl, version 5.003 with EMBED
built under solaris at Nov 14 1996 23:57:52
+ suidperl security patch
$ uname -a
SunOS <host> 5.5.1 Generic_103640-05 sun4m sparc SUNW,SPARCstation-20
I think perl here is built with sigaction, but I'm not sure (yes, I know
how to check).
--
Paul S. R. Chisholm, AirMedia, Inc. (formerly Ex Machina)
mailto:psrc@corp.airmedia.com http://corp.airmedia.com/~psrc
I'm not speaking for the company, I'm just speaking my mind
------------------------------
Date: 14 Aug 1997 00:38:46 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: split perl string
Message-Id: <5stk2m$a1k@fridge-nf0.shore.net>
Danny LaPrade (dannyl@computize.com) wrote:
: How do I split at string like
: "here1here2here3here4here5here6here7"
Probably betters ways to do it, but:
$i = 0; $j = 5;
$word = "here1here2here3here4here5here6here7";
for(1..length($word)/5) { print substr($word, $i, $j)."\n"; $i+=5; }
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Wed, 13 Aug 1997 22:16:58 GMT
From: Chris Dumas <cdumas@ibm.net>
Subject: Re: UNC Filenames on Win95
Message-Id: <33F2325A.31AC0C91@ibm.net>
chris dumas wrote:
> I can not get UNC file names to work with Perl for W95 (activeware).
> Example: stat ("c:\autoexec.bat");
> WORKS
>
> stat ("\\\\fileserver\\volume\\dir\\fn.ft") fails
>
> Does anyone know why???? or a good workaround.
>
> BTW (-e "\\\\fileserver\\volume\\dir\\fn.ft"); doesnt work either
>
> Thanks
> chris
>
> **********************
> cdumas@ibm.net
And the answer is.... to use / instead \\
chris
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 863
*************************************