[10285] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3878 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 2 18:07:14 1998

Date: Fri, 2 Oct 98 15:00:20 -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           Fri, 2 Oct 1998     Volume: 8 Number: 3878

Today's topics:
        Are there conditional comments? <robertk@techne.ca>
        bidirectional pipes & pttys? <james.davis@corp.home.net>
    Re: Checking FS (File system) <eashton@bbnplanet.com>
        Encryption <rob@ccsn.com>
    Re: gas 2.5 for HPUX-10.10 <mgregory@asc.sps.mot.com>
    Re: Help needed with fcntl in perl (Charles DeRykus)
        How do I pass Array names in Perl? <joshi@ee.tamu.edu>
    Re: How do I remove a carriage return or space from a s (Larry Rosler)
        hrefsub missing from Perl Cookbook? (Allan M. Due)
    Re: hrefsub missing from Perl Cookbook? <eashton@bbnplanet.com>
    Re: Is there one different way to order data ? droby@copyright.com
    Re: Mail attachments in NT w/o sendmail, blat, etc... epierre@mail.esiea.fr
        Need help with perl math functions <softsci@eagle.ca>
    Re: Need help with perl math functions (Brand Hilton)
    Re: Need IP Address Sort Subroutine (John Klassa)
    Re: Need IP Address Sort Subroutine (Larry Rosler)
        need some help (Andreas Piesk)
    Re: open2, cmd + args ??? (Charles DeRykus)
    Re: Perl as solution? <george.kuetemeyer@mail.tju.edu>
    Re: Perl as solution? droby@copyright.com
    Re: Perl as solution? <evonzee@tritechnet.com>
    Re: Perl as solution? <ajohnson@gpu.srv.ualberta.ca>
        Redirect STDOUT To a File (Temporarily) (TERENCE MURPHY)
        Row/Column Swapping <jian@cisco.com>
    Re: Row/Column Swapping (Larry Rosler)
    Re: Row/Column Swapping (Larry Rosler)
        Solution found! <eashton@bbnplanet.com>
    Re: uppercase to lowercase <95ncp@eng.cam.ac.uk>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 02 Oct 1998 13:36:08 -0400
From: Robert Krajcarski <robertk@techne.ca>
Subject: Are there conditional comments?
Message-Id: <36150F07.51B46F85@techne.ca>

I sure somebody out there can give me a hand:

I am writing a module for a large app that will be responsible for
logging all important information.  It will include various
DEBUG settings, so that the program can turn off all messages (to
improve performance).  The problem that I am facing is that unlike other
languages (C, C++) there doesn't seem to be any facility to use
conditional comments (similar to the preprocessor #if ... #endif
commands).  I know that there is the -P command line option that will
put the perl script throught a C preprocessor, but that doesn't seem to
be a wonderful solution (since all files will have to be run through the
perl on the command line, rather then making files executable, in
addditional to the problems of comments begining with if, else, ....).

My hands are sort of tied in terms of the computational
requirements...it seems that an "if statement" may be too expensive
since it is likely to be deeply embeded in loops.  So the major question
is this:

    Is there some way for line (4) in the following code to be ignored?
$printStuff will act as a boolean refering to whether anything should be
printed or not, and the class Logger contains the member function log,
which performs the actual printing.

    (1)    $logger = new Logger();
    (2)    $printStuff = false;
    (3)    for ($i = 0; $i < $BIG_NUMBER; $i++) {
                        ..... OTHER CODE ....
    (4)        $logger->log("This stuff should just be ignored, because
of the printStuff variable\n");
                        ..... OTHER CODE ....
    (5)    }

I have tried doing things like reassigning the log function to null
based on $printStuff, but that doesn't help.  I've also tried using
eval, but except for stuffing all of the for loop into a string, and
then evaluating that, it doesn't work.

Sorry for the verbosity, but I can't seem to get my processor to use the
DEBUG flags either :)

Thanks for any help you can offer,

Rob Kracjarski
robertk@techne.ca
Techne Knowledge


------------------------------

Date: Fri, 02 Oct 1998 20:28:54 GMT
From: James Davis <james.davis@corp.home.net>
Subject: bidirectional pipes & pttys?
Message-Id: <36153785.C435ABAD@corp.home.net>

Have a tty-less PERL script running rsh commands, unable to receive
results of output using open2.  Any way to establish a ptty beforehand,
and will this solve the problem?

Thanks,
--
James Davis
james.davis@corp.home.net


------------------------------

Date: Fri, 02 Oct 1998 20:12:16 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Checking FS (File system)
Message-Id: <3615312C.5D9FB32B@bbnplanet.com>

Ian Lowe wrote:

> Let me get everyone's opinion on a more complex filesystem monitor.  We
> use Tivoli in our large Sun environment.  We currently have a filesystem
> monitor in place, but it is very static, and doesn't take into account
> the varying size of our filesystems.  For instance, if a filesystem was
> 300 MB, we might want an alert at 90% capacity, whereas a 90% capacity
> on a 15 GB filesystem would be be way too low to warrant a critical
> event.

We use Tivoli as well. I don't quite care for it, but it does a few
things decently well. As far as I know, you can set the alert threshold
by space available. Check your manuals or ask the Tivoli guy who hangs
out on the group.

e.

Would I live my life over again? 
Make the same unforgivable mistakes? 
Yes, given half a chance. Yes  -R. Carver-


------------------------------

Date: Fri, 2 Oct 1998 15:52:04 -0500
From: "Roberto Cerini" <rob@ccsn.com>
Subject: Encryption
Message-Id: <6v3eei$ari@nnrp1.farm.idt.net>

Does anyone know how I could find the encryption key my Linux box uses, so I
can use it with the crypt command?

Regards,

--
Roberto Cerini
rob@ccsn.com




------------------------------

Date: 02 Oct 1998 16:07:46 +0930
From: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: Re: gas 2.5 for HPUX-10.10
Message-Id: <r8ww6jcvut.fsf@asc.sps.mot.com>

Kiril <work@nospam.idea.co.uk> writes:

> Uri Guttman wrote:
> > 
> > >>>>> "l" == lbello  <lbello@gartner.com> writes:
> > 
> >   l> Does anyone know where I can get gas 2.5 for hp-ux 10.10?  thanks,
> > 
> > boy, this has to be one of the most off-topic, non-spam posts we have
> > ever seen. how does this in any way have to do with perl?
> > 
> > uri
> > 
> <snip sig>
> 
> wild guess:
> wants to use perl --> downloads it --> tries to build it -->
> fails miserably --> ... --> downloads GCC --> tries to build it -->
> fails miserably --> reads GCC docs --> looks for GAS --> asks in
> c.l.p.m
> 
> Whoever said humans fail logically ?

Acutally, it nearly worked well.  I had exactly the same problem, and
had to get gas 2.5 for hpux 10.10.  The only reason I didn't reply is
'cause I darn well can't remember where I got it from!!!  :%)

Martin.


------------------------------

Date: Fri, 2 Oct 1998 21:12:19 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Help needed with fcntl in perl
Message-Id: <F07xKJ.KzB@news.boeing.com>

In article <3614EA58.B39A4C8B@yournews.nl>,
Bas A. Schulte <bas@yournews.nl> wrote:
>
>while trying to toy with some samples from Stevens' Advanced Programming
>in the Unix environment in perl, I've run across something I can't seem
>to figure out. This is the piece of C code I'm trying to do in perl:
>
>   struct flock   lock;
>
>   lock.l_type = F_WRLCK;
>   lock.l_start = 0;
>   lock.l_whence = SEEK_SET;
>   lock.l_l_len = 0;
>
>   fcntl(fd,F_SETLK,&lock);
>
>I just can't seem to be able to do it. IO::File, POSIX::open, built-in
>perl i/o, pack, somehow it doesn't add up for me ;)
>
>

You'll need to convert your OS's flock structure, e.g.
on Solaris:
 

  use Fcntl qw(:DEFAULT);

  $lock = pack("s s l l s", F_WRLCK, 0, 0, 0, 0);
  fcntl(fd, F_SETLKW, $lock) or die "can't lock: $!\n";


There're good examples in the 'Perl Cookbook' by T.Christiansen. 


hth,
--
Charles DeRykus


------------------------------

Date: Fri, 2 Oct 1998 16:29:24 -0500
From: Sanjay Joshi <joshi@ee.tamu.edu>
Subject: How do I pass Array names in Perl?
Message-Id: <Pine.SOL.3.96.981002162906.12744B-100000@eesun1.tamu.edu>

Hi,
	When I write a Perl script to pass parameters, I find that it
works only for non array parameters. How do I pass an array name in? THe
problem I have is, I have to pass in two strings, and any one of the two
might have to take the form of an associative array depending on a
condition.

Eg: I pass in 'a' and 'b', then it should be possible to execute $a{$b}
and $b{$a} depending on a third parameter passed into the CGI script. The
arrays are pre-defined in the script, so the array initializing part runs
first and then the script is supposed to print out the value of the array.

Any help is appreciated.

THanks

Sanjay

------------------------------------------------------------------------
Sanjay Joshi                                   http://ee.tamu.edu/~joshi
------------------------------------------------------------------------




------------------------------

Date: Fri, 2 Oct 1998 12:57:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How do I remove a carriage return or space from a string?
Message-Id: <MPG.107ed01337b17df89897da@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <1dga2ya.1ab5fu3j2qweeN@roxboro0-008.dyn.interpath.net> on 
Fri, 2 Oct 1998 15:36:06 -0500, John Moreno <phenix@interpath.com> 
says...
> Larry Rosler <lr@hpl.hp.com> wrote:
> > John Moreno <phenix@interpath.com> says...
> > > Yogish Baliga <baliga@synopsys.com> wrote:
> > > >   $hello =~ s/\s*$//g;
> > > > 
> > > >  This means remove all the whitespaces at end of string with null.
> > > 
> > > And has either a superfluous * or g.
> > 
> > Not 'either .. or'.  The '*' should be '+' and the 'g' should be omitted.
> > But the effect is the same in any case.
> 
> Right, TMTIWTDI - but using both is a waste.

Heck, no.  They are not related at all.

Using '+' (or '*' less efficiently) is not superfluous.  It is required 
by the problem specification ('remove all the whitespaces').

Using 'g' is superfluous, because of the '$' anchor ('at end of string').

'using both' is not a waste -- it is a non sequitur.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 2 Oct 1998 21:43:45 GMT
From: Allan@Due.net (Allan M. Due)
Subject: hrefsub missing from Perl Cookbook?
Message-Id: <6v3heh$hte$0@206.165.146.21>


Hi Folks,

	Was looking at the Perl Cookbook today and noted that there seems 
to be a missing program example.  On page 732 there is a heading 20.15 
Program: hrefsub but danged if I can see any program, just the 
description of what it is supposed to do.  Anyone know where it wandered 
off to?  In fact, I would really like to see this program so if anyone 
has access to it I would greatly appreciate it if they would send me a 
copy.

__
Allan M. Due
Allan@Due.net

The beginning of wisdom is the definitions of terms.
- Socrates


------------------------------

Date: Fri, 02 Oct 1998 21:49:49 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: hrefsub missing from Perl Cookbook?
Message-Id: <36154807.EE7479A2@bbnplanet.com>

first guess. http://www.ora.com they have always been religious about
publishing errata...whadayaknow, there it is.

http://language.perl.com/critiques/ram/errata.1st-printing

<technical, bug>
733     The program is missing.  It should be:

    #!/usr/bin/perl -w
    # hrefsub - make substitutions in <A HREF="..."> fields of HTML
files
    # from Gisle Aas <gisle@aas.no>

    sub usage { die "Usage: $0 <from> <to> <file>...\n" }

    my $from = shift or usage;
    my $to   = shift or usage;
    usage unless @ARGV;

    # The HTML::Filter subclass to do the substitution.

    package MyFilter;
    require HTML::Filter;
    @ISA=qw(HTML::Filter);
    use HTML::Entities qw(encode_entities);

    sub start {
       my($self, $tag, $attr, $attrseq, $orig) = @_;
       if ($tag eq 'a' && exists $attr->{href}) {
           if ($attr->{href} =~ s/\Q$from/$to/g) {
               # must reconstruct the start tag based on $tag and $attr.
               # wish we instead were told the extent of the 'href'
value
               # in $orig.
               my $tmp = "<$tag";
               for (@$attrseq) {
                   my $encoded = encode_entities($attr->{$_});
                   $tmp .= qq( $_="$encoded ");
               }
               $tmp .= ">";
               $self->output($tmp);
               return;
           }
       }
       $self->output($orig);
    }

    # Now use the class.

    package main;
    foreach (@ARGV) {
        MyFilter->new->parse_file($_);





e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


------------------------------

Date: Fri, 02 Oct 1998 21:22:46 GMT
From: droby@copyright.com
Subject: Re: Is there one different way to order data ?
Message-Id: <6v3g76$f5f$1@nnrp1.dejanews.com>

In article <6v2j6v$1ue$1@nnrp1.dejanews.com>,
  droby@copyright.com wrote:
>
> But if you want to do date arithmetic (i.e., birthdays in the last seven
> days), you really need a Julian date computation.  I suspect the Date::Manip
> module available on CPAN would be useful for this, and you might find there
> something that will help you solve both problems.
>
> Or you can roll your Julian date routine for use in the comparison and in the
> sort, using the localtime function built into Perl and the timelocal function
> in the Time::Local module that is bundled in the core set of things that come
> with Perl.
>

Roby, you twit, you've rephrased someone's question as a FAQ and then answered
it incorrectly!

Slap, slap, slap!

Perfaq4 tells us:


How can I find the Julian Day?

Neither Date::Manip nor Date::DateCalc deal with Julian days. Instead, there
is an example of Julian date calculation in
http://www.perl.com/CPAN/authors/David_Muir_Sharnoff/modules/Time/JulianDay.p
m.gz, which should help.


Curiously, I could not find that file.	This author's Time modules seem to
have been rearranged since that was written.

However, I think the example referenced is in the file
http://www.perl.com/CPAN/authors/David_Muir_Sharnoff/modules/Time-modules-98.
081201.tar.gz

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Fri, 02 Oct 1998 20:17:06 GMT
From: epierre@mail.esiea.fr
Subject: Re: Mail attachments in NT w/o sendmail, blat, etc...
Message-Id: <6v3cc0$9eb$1@nnrp1.dejanews.com>



I have a full Perl solution, it uses perl modules, have a look at

	http://www.esiea.fr/public_html/Emmanuel.PIERRE/perl/ntperl.html

Subject:             Re: Mail attachments in NT w/o sendmail, blat, etc...
Date:             Mon, 10 Aug 1998 10:26:55 -0400
From:            Martin Little <martin@klg.com>
Organization:             KL Group Inc.
To:             Laurie Russinko <laurie@eclipse.net>
Newsgroups:             comp.lang.perl.misc
References:             1


> I use the following program under NT for my perl scripts.

> http://www.stalkerlab.ch/SMailers/index.html

> It has all the basic functionality for what I need but YMMV.

> ../Martin


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Fri, 2 Oct 1998 16:57:37 -0400
From: "Soft Science" <softsci@eagle.ca>
Subject: Need help with perl math functions
Message-Id: <6v3fj9$n5m$1@mur2.odyssey.on.ca>

In a HTML order form, user will be provided 10 or more different fields to
input the cost of the
items with the different quantities per item. Sort of looks like this:
Quantity  Prize
1  $10
2  $20
etc.
(user manually inputs the value in the html form field)
Secondly,  the user will have an pull down menu to select the tax rate.
 .5
 .7
etc
Another pull down menu will be provided to the user to select the shipping
method they want.
eg:
$10 for shipping method1
so on..
Finally, when the user presses the submit button I want the script would be
able to find the
total amount (total item+tax+shipping) and displays it to the user.
Can anybody help me to write this script.  I just want to know the math
(calculation) part and
I will do the rest.  Thank you in advance for your help!!
Kumar
kumarsundaram@usa.net




------------------------------

Date: 2 Oct 1998 21:40:16 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: Need help with perl math functions
Message-Id: <6v3h80$7p23@mercury.adc.com>

In article <6v3fj9$n5m$1@mur2.odyssey.on.ca>,
Soft Science <softsci@eagle.ca> wrote:
>In a HTML order form, user will be provided 10 or more different fields to
>input the cost of the
>items with the different quantities per item. Sort of looks like this:
>Quantity  Prize
>1  $10
>2  $20
>etc.
>(user manually inputs the value in the html form field)
>Secondly,  the user will have an pull down menu to select the tax rate.
>.5
>.7
>etc
>Another pull down menu will be provided to the user to select the shipping
>method they want.
>eg:
>$10 for shipping method1
>so on..
>Finally, when the user presses the submit button I want the script would be
>able to find the
>total amount (total item+tax+shipping) and displays it to the user.
>Can anybody help me to write this script.  I just want to know the math
>(calculation) part and
>I will do the rest.  Thank you in advance for your help!!
>Kumar
>kumarsundaram@usa.net

???

I can't imagine this is really what you want, but it's certainly what
you asked for.

  my $total = 0;
  foreach my $lineitem (@lineitems) {
    $total += $lineitem{price} * $lineitem{quantity};
  }

  $total += $total * $taxrate;

  $total += $shipping;

I'll go the extra mile here and suggest that, if you hadn't already
decided to do so, you should really use CGI.pm for the CGI part of
this.

HTH

-- 
 _____ 
|///  |   Brand Hilton  bhilton@adc.com
|  ADC|   ADC Telecommunications, ATM Transport Division
|_____|   Richardson, Texas


------------------------------

Date: 2 Oct 1998 20:21:11 GMT
From: klassa@aur.alcatel.com (John Klassa)
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <6v3cjn$7f4$1@aurwww.aur.alcatel.com>

Sorry to jump into the middle of this...

On 01 Oct 1998 14:56:40 +0200, Michal Rutka <erhmiru@erh.ericsson.se> wrote:
  > > |> It took me about 10 seconds to understand a syntax. I didn't found
  > > |> it pretty.  And one more thing, in a job which I do I learned to
  > > |> use a word 'transform' to more complicated things than a simple
  > > |> data manipulation. That's why I call it a Schwartzian thing.
  > >
  > >    I suggest you look up transform in a dictionary.
  >
  > And start calling grep as 'transformation program'. No thanks.

The syntax of a Schwartzian Transform may be a bit daunting at first, but
it makes perfect sense if you read it from the bottom up.  There are a
number of useful explanations of this powerful technique lying about (one
is at http://www.5sigma.com/perl/schwtr.html).  The "black transform" (as
Tom Christiansen calls it) is a keeper...

As for whether "transform" is the right word, I defer to the dictionary:

	@trans.form \trans-'fo_.rm\ vb
	  1: to change in structure, appearance, or character
	  2: to change (an electric current) in potential or type
	  SYN: transmute, transfigure
	  -- trans.for.ma.tion \.trans-f*r-'ma_--sh*n\ n
	  -- trans.form.er \trans-'fo_.r-m*r\ n

It would seem, then, that the Schwartzian Transform is aptly named...
(Furthermore, "grep" is not a transform.)

-- 
John Klassa / Alcatel Telecom / Raleigh, NC, USA <><


------------------------------

Date: Fri, 2 Oct 1998 13:44:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <MPG.107edb09c04903e09897db@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <6v3cjn$7f4$1@aurwww.aur.alcatel.com> on 2 Oct 1998 20:21:11 
GMT, John Klassa <klassa@aur.alcatel.com> says...
 ...
> (Furthermore, "grep" is not a transform.)

Sheesh, folks.  Principles of Unix.  'grep' is a *filter*.

fil7ter n. ... 2. Any of various electric, electronic, acoustic, or 
optical devices used to reject signals, vibrations, or radiations of 
certain frequencies while passing others.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Fri, 02 Oct 1998 21:32:36 GMT
From: a.piesk@gmx.net (Andreas Piesk)
Subject: need some help
Message-Id: <36164672.21994566@news.uni-leipzig.de>

hiho,

here's what i'm trying to do:

i retrieve a image from my database and store it in $image. so far so
good. now i want to do some manipulation on this image. i'm using
perlmagick. according to the perlmagick-doc i can create a new image
by typing:

$img = new Image::Magick;

manipulations go this way:
$img->do_something_wth_the_image( params );

but now the question to all you gurus: 

it is possible to copy the data from $image into $img in order to do
the manipulations on the data retrieved from the database ? or can i
"convert" the $image to a $img object ?

i'm new to perl and have no clue :(

hope someone understand me an can help.

ciao -ap
___________________________________________________________________
 
 Andreas Piesk   a.piesk@gmx.net
 IT Manager BFW GmbH Leipzig
 pgp fingerprint: 23CB A7E2 2E53 373C  DBCD 8EFC 7777 61C1
___________________________________________________________________

 at trainstations stops the train.
 at busstations stops the bus.
 at workstations stops the ...
___________________________________________________________________


------------------------------

Date: Fri, 2 Oct 1998 20:44:56 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: open2, cmd + args ???
Message-Id: <F07wAx.IEz@news.boeing.com>

In article <36113006.4536172@news.ml.com>,
Stephen Elias <steven_elias@ml.com> wrote:
>Hi,
>
>However, this doesn't work:
>
> require 'open2.pl';
> &open2(RDR,WTR,"bc data.txt");
> print WTR "2+2\nquit\n";
> while(<RDR>) {
>  print;
> }
>
>>perl mybc.pl
>open2: IO::Pipe: Can't spawn-NOWAIT: No such file or directory at
>mybc.pl line 2
>

Works ok with Solaris 2.5.1, perl 5.005_01, IO::Pipe 1.0901.

What versions are you using?


--
Charles DeRykus


------------------------------

Date: Fri, 02 Oct 1998 16:14:32 -0400
From: George Kuetemeyer <george.kuetemeyer@mail.tju.edu>
Subject: Re: Perl as solution?
Message-Id: <36153428.17A5F419@mail.tju.edu>



Elaine -HappyFunBall- Ashton wrote:

> My neighbor has one of those darned car alarms that goes off every
> morning at 3am with that 'dive dive dive' sound.
>
> For hours.
>
> I would like to solve this annoying problem.

Your problem could be our solution. Since you're up anyway, spend that time
replying to all of our Perl questions.

Seriously, you may want to determine what triggers this apparently regular
behaviour. Maybe there is a Perl solution for that.



------------------------------

Date: Fri, 02 Oct 1998 20:42:45 GMT
From: droby@copyright.com
Subject: Re: Perl as solution?
Message-Id: <6v3ds5$boh$1@nnrp1.dejanews.com>

In article <36150B17.F0938BD3@bbnplanet.com>,
  Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> wrote:
> My neighbor has one of those darned car alarms that goes off every
> morning at 3am with that 'dive dive dive' sound.
>
> For hours.
>
> I would like to solve this annoying problem. Could perl help me develop
> a guidance system for the missile I would like to launch at it? Or
> should I just rely on my trusty tesla coil? Karo syrup in the oil? So
> many choices, so little sleep. Maybe I could stick one of those magnetic
> perl kits all over the hood?
>
> e.
>

Perhaps a sneak attack with a HappyFunBall?

No - here's the routine.

Somewhere out there in the Internet there is an snmp-managed toaster.  (It was
at InterOp many years ago.)  Surely with a few easily found tools it could be
converted to a small scale missile launcher.  Some toasters are almost that
anyway after all.  Then all it takes is a cron job to run your little Perl
program that does the appropriate snmp set to make that car toast.

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Fri, 02 Oct 1998 16:06:05 -0500
From: Eric Von Zee <evonzee@tritechnet.com>
Subject: Re: Perl as solution?
Message-Id: <3615403D.C24686F0@tritechnet.com>

Sure!

sub 12gauge_shotgun {
$planet =~ s/neighbor//;
} #end sub 12gauge_shotgun

HTH!

-Eric

Elaine -HappyFunBall- Ashton wrote:

> I would like to solve this annoying problem. Could perl help me develop
> a guidance system for the missile I would like to launch at it? Or
> should I just rely on my trusty tesla coil? Karo syrup in the oil? So
> many choices, so little sleep. Maybe I could stick one of those magnetic
> perl kits all over the hood?
>
> e.
>
> Would I live my life over again?
> Make the same unforgivable mistakes?
> Yes, given half a chance. Yes  -R. Carver-

--
Best Regards,
Tritech Marketing Inc.

Eric Von Zee
Webmaster




------------------------------

Date: Fri, 02 Oct 1998 16:40:03 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Perl as solution?
Message-Id: <36154833.30BE0E7F@gpu.srv.ualberta.ca>

Elaine -HappyFunBall- Ashton wrote:
> 
> My neighbor has one of those darned car alarms that goes off every
> morning at 3am with that 'dive dive dive' sound.
> 
> For hours.
> 
> I would like to solve this annoying problem. Could perl help me develop
> a guidance system for the missile I would like to launch at it? Or
> should I just rely on my trusty tesla coil? Karo syrup in the oil? So
> many choices, so little sleep. Maybe I could stick one of those magnetic
> perl kits all over the hood?

possibly, going the magnetic perl kit route attaching a script
along the lines of: (untested :-)

#!/usr/bin/perl -w
while(1){
    ($hour=(split(' ',localtime()))[3])=~s/^(\d+).*/$1/;
    if ($hour >= 0 && $hour < 8) {
        $^W=0;
    }else{
        $^W=1;
    }    
}
__END__

of course, this does needless processing and there are certainly more
efficient ways to disable warnings for the desired interval ... but
what do you care, its running on the neighbor's car and you're the
one who wants to sleep() right?

regards
andrew


------------------------------

Date: 2 Oct 1998 21:37:31 GMT
From: tsmurphy@cs.uiuc.edu (TERENCE MURPHY)
Subject: Redirect STDOUT To a File (Temporarily)
Message-Id: <6v3h2r$22k$1@vixen.cso.uiuc.edu>

Hi,

I would like to temporarily redirect STDOUT to a different file.

So a program would be something like this:

printf "a\n";
# do some magic to redirect stdout to a different file
# then...
printf "b\n";
# do some magic to restore stdout
# then...
printf "c\n";

So, "a" and "c" would be written to stdout, and "b" would be
written to some file.  What's the best way to do this?  Or should
I just convert the "b" line to fprintf and open a file?

Thanks in advance.

Regards,

Terry Murphy


------------------------------

Date: Fri, 02 Oct 1998 13:02:59 -0700
From: Jian Zhang <jian@cisco.com>
Subject: Row/Column Swapping
Message-Id: <36153173.188AF106@cisco.com>

Hi,

Given a multiple arrays data record:

@array1 = {a11, a12, ..., a1n};
@array2 = {a21, a22, ..., a2n};
@array3 = {a31, a32, ..., a3n};

I need to create n new arrays such that:

@new_array1 = {a11, a21, a31};
@new_array2 = {a12, a22, a32};
 ..
@new_arrayn = {a1n a2n, a3n};

Are there any clean ways doing this?

Thanks in advance.

Jian Zhang
San Jose, CA



------------------------------

Date: Fri, 2 Oct 1998 14:11:49 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Row/Column Swapping
Message-Id: <MPG.107ee171e7620c5f9897dc@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <36153173.188AF106@cisco.com> on Fri, 02 Oct 1998 13:02:59 -
0700, Jian Zhang <jian@cisco.com> says...
> Given a multiple arrays data record:
> 
> @array1 = {a11, a12, ..., a1n};
> @array2 = {a21, a22, ..., a2n};
> @array3 = {a31, a32, ..., a3n};
> 
> I need to create n new arrays such that:
> 
> @new_array1 = {a11, a21, a31};
> @new_array2 = {a12, a22, a32};
> ..
> @new_arrayn = {a1n a2n, a3n};
> 
> Are there any clean ways doing this?

Life would be much easier if you used two-dimensional arrays instead of 
sets of named arrays.  See `perldoc perllol`.  Then you could say:

#!/usr/local/bin/perl -w
use strict;

my @a = (
    [ 11, 12, 13, 14 ],
    [ 21, 22, 23, 24 ],
    [ 31, 32, 33, 34 ],
  );

my @b =
    map { my $x = $_; [ map $a[$_][$x] => 0 .. $#a ] } 0 .. $#{$a[0]};

print map "@$_\n" => @b;

See also `perldoc perldsc`.  I imagine there are cleaner ways, but this 
is the first one that came to my mind.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Fri, 2 Oct 1998 14:18:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Row/Column Swapping
Message-Id: <MPG.107ee30d6a028bdd9897dd@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <36153173.188AF106@cisco.com> on Fri, 02 Oct 1998 13:02:59 -
0700, Jian Zhang <jian@cisco.com> says...
> Given a multiple arrays data record:
> @array1 = {a11, a12, ..., a1n};
 ...
> I need to create n new arrays such that: 
> @new_array1 = {a11, a21, a31};
 ...
> Are there any clean ways doing this?

Or (instead of my previously posted one-liner) use this module from CPAN:

Math::Matrix - Matrix functions: multiply, invert, transpose, solve. Each 
matrix is an array of array references, as you'd expect: the middle 
element of a 2x2 array is $array[1][1]. 

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Fri, 02 Oct 1998 21:24:49 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Solution found!
Message-Id: <3615422B.FAC0A27@bbnplanet.com>

Eric Von Zee wrote:

> sub 12gauge_shotgun {
> $planet =~ s/neighbor//;
> } #end sub 12gauge_shotgun

No, too violent. I'm a kind-hearted soul who just wants some sleep. 

Perl is going to help with this solution though :) A pilot with perl, a
bit of sophisticated military tech from work and a radio to blast Celine
Dion singing that damned Titanic song. I may start wretching but it
should get the message across. If not, there is always the monster tesla
coil that will have the mechanics scratching their heads. *mwaahaahaa*
God I love working with engineers.

e.

Would I live my life over again? 
Make the same unforgivable mistakes? 
Yes, given half a chance. Yes  -R. Carver-


------------------------------

Date: Fri, 2 Oct 1998 21:17:10 +0100
From: Nigel Parker <95ncp@eng.cam.ac.uk>
Subject: Re: uppercase to lowercase
Message-Id: <Pine.HPP.3.96L.981002211401.22931A-100000@club.eng.cam.ac.uk>

On Fri, 2 Oct 1998 etrim@my-dejanews.com wrote:

: Hey everyone,
: 
: I have a very simple question. I want to check if the user correctly entered
: address of the image (gif or jpg) Using $image =~ /.gif/ i can find out if
: $image contains .gif in it.  But what if the users wrote .Gif, or .JPg and so
: on....i don't want to check for earch one.  Is there a quicker way of doing

Have you read any documentation - ever?

Try the Perlre section of the perl reference man.

if ($image =~ /\.gif/i) {...}

i=ignore case
\.=literal "."


Nigel
-- 
Girton College, Cambridge, England, CB3 0JG.             Tel: 0411 384803

http://welcome.to/nigels                             nigel.parker@iee.org



------------------------------

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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 3878
**************************************

home help back first fref pref prev next nref lref last post