[8866] in Perl-Users-Digest
Perl-Users Digest, Issue: 2483 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 3 15:06:13 1998
Date: Sun, 3 May 98 12:00:37 -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 Sun, 3 May 1998 Volume: 8 Number: 2483
Today's topics:
'C' command "TOUPPER" or "TOLOWER". <i_hate_spam@spam-sucks.com>
Re: 'C' command "TOUPPER" or "TOLOWER". (Matthew Cravit)
Re: 'C' command "TOUPPER" or "TOLOWER". (Craig Berry)
Re: 'C' command "TOUPPER" or "TOLOWER". (Hakan Hjelmstrom)
Re: 'C' command "TOUPPER" or "TOLOWER". <rjk@coos.dartmouth.edu>
Re: 'C' command "TOUPPER" or "TOLOWER". <rootbeer@teleport.com>
Re: 1701 days hath September (was: Re: rename funciton) (Jonathan Stowe)
Re: A bug in localtime() <lr@hpl.hp.com>
Re: A bug in localtime() (Jonathan Stowe)
Re: ANNOUNCE: Perl Builder IDE Now Available (Georg Bauer)
Re: ANNOUNCE: Perl Builder IDE Now Available <rootbeer@teleport.com>
Re: Array of Arrays, sorting and using <jdf@pobox.com>
Calling another script... <i_hate_spam@spam-sucks.com>
Re: Calling another script... <rootbeer@teleport.com>
Re: Converting COBOL Comp-3 field <rootbeer@teleport.com>
Re: Exporting vs. "direct" access <tchrist@mox.perl.com>
Re: Exporting vs. "direct" access <rootbeer@teleport.com>
Re: Exporting vs. "direct" access (John Siracusa)
help on perl5.004_04 installation lab318@ecolan.sbs.ohio-state.edu
Re: help wanted (trivial) (Craig Berry)
Re: HELP win32 perl (Jonathan Stowe)
Re: HEX to BCD (Mark-Jason Dominus)
Re: How do I print an array in the format I want it? <merlyn@stonehenge.com>
Re: How do I print an array in the format I want it? (Jonathan Stowe)
Re: Interrupts ... or whatever they are called (Jonathan Stowe)
Re: looking for a little bit of help here. <rootbeer@teleport.com>
malformed header? <star@sonic.net>
Re: malformed header? (Hakan Hjelmstrom)
newbie, how to extract line n from a file (Gregory J. Sandell)
Re: newbie, how to extract line n from a file (Craig Berry)
Re: newbie, how to extract line n from a file (Matthew Cravit)
Re: Pattern Matching <peterm@zeta.org.au>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 03 May 1998 13:31:58 -0400
From: University Student <i_hate_spam@spam-sucks.com>
Subject: 'C' command "TOUPPER" or "TOLOWER".
Message-Id: <354CAA0E.DCBB8ED0@spam-sucks.com>
Does anyone know what the alternative to the "C" command
toupper (x);
is in Perl?
TOUPPER meaning concert all alphabet letters to uppercase... or
TOLOWER meaning concert all alphabet letters to lowercase...
reason being I would like to restric some users from
registering TWICE with the same e-mail address, but in
different low/upper case.... ie. I want to equate
username@AOL.COM and UseRnaMe@aol.COM
--
<X>X<X>X<X>X<X>X<X>X<X>X<X>X<X>X<X>
E-mail me for details:
design@netcom.ca
<X>X<X>X<X>X<X>X<X>X<X>X<X>X<X>X<X>
------------------------------
Date: 3 May 1998 11:28:35 -0700
From: mcravit+usenet@mcravit.vip.best.com (Matthew Cravit)
Subject: Re: 'C' command "TOUPPER" or "TOLOWER".
Message-Id: <6iid0j$nea$1@shell3.ba.best.com>
In article <354CAA0E.DCBB8ED0@spam-sucks.com>,
University Student <i_hate_spam@spam-sucks.com> wrote:
>Does anyone know what the alternative to the "C" command
> toupper (x);
perldoc -f uc
perldoc -f lc
perldoc -f ucfirst
Hope this helps.
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@net.com (work) | time you make it.
------------------------------
Date: 3 May 1998 18:21:43 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: 'C' command "TOUPPER" or "TOLOWER".
Message-Id: <6iicjn$r1m$2@marina.cinenet.net>
University Student (i_hate_spam@spam-sucks.com) wrote:
: Does anyone know what the alternative to the "C" command
: toupper (x);
: is in Perl?
perldoc -f uc
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Sun, 03 May 1998 18:31:23 GMT
From: hawk@algonet.se (Hakan Hjelmstrom)
Subject: Re: 'C' command "TOUPPER" or "TOLOWER".
Message-Id: <3550b764.16516199@news.algonet.se>
On Sun, 03 May 1998 13:31:58 -0400, University Student wrote:
> Does anyone know what the alternative to the "C" command
> toupper (x); is in Perl?
Check out the perlfunc documentation under "Functions for SCALARs or
strings", it's all there.
Hekan Hjelmstrvm
hawk@algonet.se
------------------------------
Date: Sun, 03 May 1998 14:50:59 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: 'C' command "TOUPPER" or "TOLOWER".
Message-Id: <354CBC94.EF6DE883@coos.dartmouth.edu>
[posted but not mailed - munged address are annoying]
University Student wrote:
>
> Does anyone know what the alternative to the "C" command
> toupper (x);
> is in Perl?
Yes, the perlfunc documentation knows. Search for the words 'uppercase' and 'lowercase'.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 03 May 1998 18:54:39 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: University Student <i_hate_spam@spam-sucks.com>
Subject: Re: 'C' command "TOUPPER" or "TOLOWER".
Message-Id: <Pine.GSO.3.96.980503114715.21603N-100000@user2.teleport.com>
On Sun, 3 May 1998, University Student wrote:
> Does anyone know what the alternative to the "C" command
> toupper (x);
> is in Perl?
Yes, and you should be able to find it in the perl docs. Start in
perlfunc.
> reason being I would like to restric some users from
> registering TWICE with the same e-mail address, but in
> different low/upper case.... ie. I want to equate
>
> username@AOL.COM and UseRnaMe@aol.COM
Hmmm....
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 02 May 1998 07:59:41 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <354ab881.18189841@news.btinternet.com>
On 3 May 1998 14:07:40 GMT, Stefaan A Eeckels wrote :
>In article <3549e30b.20252989@news.btinternet.com>,
> Gellyfish@btinternet.com (Jonathan Stowe) writes:
>> On 2 May 1998 23:28:14 GMT, John Stanley wrote :
>>
>> Look on the bright side guys you could be Tony Blair (or a morris
>> dancer).
>What's wrong being a morris dancer?
>
>--
>Stefaan
>--
>
There's hundreds of them and they've over-run the streets of Hastings.
When I first moved down here I though I had developed tinitus.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sun, 3 May 1998 08:30:09 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: A bug in localtime()
Message-Id: <6ii2j9$3tm@hplntx.hpl.hp.com>
Jonathan Stowe wrote in message
<354a08f6.29149301@news.btinternet.com>...
...
>The thing is here that the day in the month dis nay get considered as
>an array element. There is no valuable information to be had with an
>array indexed by $mday whereas $months[$mon] and $day[$wday] have a
>value well known by all users of the western calendar. The $yday also
>runs 1 -> 36[56].
...
Unfortunately for your attempt to find a generalization here, it
doesn't!
>From 'man ctime':
int tm_yday; /* days since January 1 - [0,365] */
I too have been bitten by trying to apply logic to the values in struct
tm!
Sigh...
Simplest Perl test: print((gmtime 0)[7], "\n"); # Prints 0
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Sat, 02 May 1998 07:59:48 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: A bug in localtime()
Message-Id: <354ac5f5.21631771@news.btinternet.com>
On Sun, 3 May 1998 08:30:09 -0700, Larry Rosler wrote :
>Jonathan Stowe wrote in message
><354a08f6.29149301@news.btinternet.com>...
>...
>>The thing is here that the day in the month dis nay get considered as
>>an array element. There is no valuable information to be had with an
>>array indexed by $mday whereas $months[$mon] and $day[$wday] have a
>>value well known by all users of the western calendar. The $yday also
>>runs 1 -> 36[56].
>...
>
>Unfortunately for your attempt to find a generalization here, it
>doesn't!
>
>From 'man ctime':
>
> int tm_yday; /* days since January 1 - [0,365] */
>
>I too have been bitten by trying to apply logic to the values in struct
>tm!
>Sigh...
>
>Simplest Perl test: print((gmtime 0)[7], "\n"); # Prints 0
>
>--
Oops,
driven mad by the morris dancers I seem to have gone an example too
far here.
That is absolutely correct of course.
Funny thing is I dont seem to recall ever actually using the $yday
valuable in Perl or its equivalent in C.
Dont worry the morris dancers are going away tomorrow.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Fri, 1 May 1998 20:40:53 GMT
From: gb@hugo.westfalen.de (Georg Bauer)
Subject: Re: ANNOUNCE: Perl Builder IDE Now Available
Message-Id: <gb-0105982240530001@hugo.westfalen.de>
In article <Pine.GSO.3.96.980428104024.15049M-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
>Of course, there's no way to always get the colors correct unless you have
>an error-proof way of parsing Perl - which no one has yet invented. :-)
Makes me wonder how Perl does it, then.
bye, Georg
--
#!/usr/bin/perl -0777pi
s/TS:.*?\0/$_=$&;y,a-z, ,;s, $,true,gm;s, 512,2048,;$_/es
------------------------------
Date: Sun, 03 May 1998 18:55:24 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Georg Bauer <gb@hugo.westfalen.de>
Subject: Re: ANNOUNCE: Perl Builder IDE Now Available
Message-Id: <Pine.GSO.3.96.980503115459.21603O-100000@user2.teleport.com>
On Fri, 1 May 1998, Georg Bauer wrote:
> In article
> <Pine.GSO.3.96.980428104024.15049M-100000@user2.teleport.com>, Tom
> Phoenix <rootbeer@teleport.com> wrote:
>
> >Of course, there's no way to always get the colors correct unless you have
> >an error-proof way of parsing Perl - which no one has yet invented. :-)
>
> Makes me wonder how Perl does it, then.
Perl isn't error-free! :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 03 May 1998 12:42:23 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: eggsite@berlin.snafu.de (bernd wolfsegger)
Subject: Re: Array of Arrays, sorting and using
Message-Id: <hg37xncw.fsf@mailhost.panix.com>
eggsite@berlin.snafu.de (bernd wolfsegger) writes:
> comdog@computerdog.com (brian d foy) wrote:
>
> eggsite@berlin.snafu.de posted:
> > >can anybody tell me how I can sort an Array of Arrays (No Hashes),
> >
> > the perldsc and perllol manpages have lots of examples.
>
> thats right, but its the same as in the camelbook. And I can't find any
> example of sorting an array of arrays, just array of hashes etc...
Please post a brief example of your data structure, with a brief
example of how it should look when sorted. I should warn you, though,
that if the perllol, perlref, and perldsc pages don't do the trick for
you, it's unlikely that we can be of help.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Sun, 03 May 1998 13:28:25 -0400
From: University Student <i_hate_spam@spam-sucks.com>
Subject: Calling another script...
Message-Id: <354CA939.403A1B57@spam-sucks.com>
I use a complicated Perl Script for a BBS. I need to put a randomizzed
ad graphix on each time someone views a message on the BBS. I know where
to insert the script, but it doesn't work.
print "<!--exec:ads.cgi-->";
does not work. So I try to call the AD script :
$something = ../../ads/ad.cgi;
print " $something ";
and all that is printed on the screen via the browser
is some 5 digit number... Not the actuall add....
I am so frustrated with this!
Can anyone help?
--
<X>X<X>X<X>X<X>X<X>X<X>X<X>X<X>X<X>
E-mail me for details:
rdecoste@uoguelph.ca
<X>X<X>X<X>X<X>X<X>X<X>X<X>X<X>X<X>
------------------------------
Date: Sun, 03 May 1998 18:46:57 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: University Student <i_hate_spam@spam-sucks.com>
Subject: Re: Calling another script...
Message-Id: <Pine.GSO.3.96.980503113711.21603M-100000@user2.teleport.com>
On Sun, 3 May 1998, University Student wrote:
> print "<!--exec:ads.cgi-->";
>
> does not work.
That's valid Perl code. If it's not doing what you want, maybe you need to
put something different inside the string. Of course, figuring out what
that string should be has nothing to do with Perl.
> $something = ../../ads/ad.cgi;
That looks as if you forgot to quote the string.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 03 May 1998 16:29:39 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Bob Tate <btate@primary.net>
Subject: Re: Converting COBOL Comp-3 field
Message-Id: <Pine.GSO.3.96.980503092542.21603C-100000@user2.teleport.com>
On Sat, 2 May 1998, Bob Tate wrote:
> I believe that if I can convert HEX to BCD that would give me the
> desired results. And no, the unpack command does not work in the way
> that you or I feel that it should. using either the "H8" or the "h8"
> seems to unpack the number but with a result that is not what I am
> looking for.
Okay, let's try this again.
Unpack with "H8" as a format will unpack the four-byte string
"\x00\x98\x76\x5c" into the eight hex characters "0098765c". Is that
anything close to what you want? If not, please tell us what you actually
want, since I don't think we'll ever guess it. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 3 May 1998 16:01:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Exporting vs. "direct" access
Message-Id: <6ii4c5$m7d$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Jonathan Feinberg <jdf@pobox.com> writes:
:I'm sure
:the gurus will correct me if I'm wrong, but I think that inlined
:functions are actually replaced in the compile tree by constants,
:whereas the typeglob trick, above, still results in a run-time
:interpolation.
Your understanding, sir, is indeed correct.
perl -D can be illustrative.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
I hate programs that chdir --Boyd Roberts
------------------------------
Date: Sun, 03 May 1998 16:35:01 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: John Siracusa <macintsh@cs.bu.edu>
Subject: Re: Exporting vs. "direct" access
Message-Id: <Pine.GSO.3.96.980503093239.21603D-100000@user2.teleport.com>
On 3 May 1998, John Siracusa wrote:
> 1. What advantages or disadvantages does "use constant"
> have over making normal variables that are set to
> references to scalars?
This is covered in the docs for 'use constant'.
> 2. What's faster: using Exporter, or accessing the variables
> via $MyConstants::whatever?
Probably exporting constants, but it depends upon what you're measuring.
It's often not significant enough to worry about. Of course, if you really
care, use Benchmark.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 3 May 1998 18:50:40 GMT
From: macintsh@cs.bu.edu (John Siracusa)
Subject: Re: Exporting vs. "direct" access
Message-Id: <6iiea0$pgu$1@news1.bu.edu>
Thanks for all the info. I ended up using "constant" and
EXPORT_OK-ing after all, although the whole @{[CONST]}
thing still seems kind of whacky to me...like one of those
things that will change a subtly few revisions from now.
Anyway, that brings me to one more question:
use constant CONST => "hello";
...
s/@{[CONST]}/foo/o;
Is the "o" necessary? Does it even have any effect? My
understanding is that what comes out of that @{[]} mess is
a reference to an array containing the results of the call
to the CONST subroutine created earlier by the "use
constant" declaration. It's not exactly a variable, but I
don't want the overhead of a subroutine call each time
through that substitution either (since the return value
will never change). Am I to assume that Perl understands
this and that it'll replace @{[CONST]} with a hard
value at compile time? Does the "o" have any effect?
-----------------+----------------------------------------
John Siracusa | If you only have a hammer, you tend to
macintsh@bu.edu | see every problem as a nail. -- Maslow
------------------------------
Date: Sun, 3 May 1998 18:47:36 GMT
From: lab318@ecolan.sbs.ohio-state.edu
Subject: help on perl5.004_04 installation
Message-Id: <lab318.23.354CBBC8@ecolan.sbs.ohio-state.edu>
Hi All.
We have a SUN OS (5.5.1), and it is the first time we try to install
Perl5.004_04 on it. After "configure" and "make", it failed 28 out of 153
tests (under "make test") and failed 3 out of 101 tests (under "make
minitest"). The typical error message is:
lib/socket........Can't load module Socket, dynamic loading not available in thi
s perl.
(You may need to build a new perl executable which either supports
dynamic loading or has the Socket module statically linked into it.)
at ./lib/socket.t line 14
BEGIN failed--compilation aborted at ./lib/socket.t line 14.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
FAILED at test 0
Any suggestions on how to fix them? Thanks.
--YY
------------------------------
Date: 3 May 1998 16:30:13 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: help wanted (trivial)
Message-Id: <6ii62l$r1m$1@marina.cinenet.net>
fantha (fantha@berlin1.netsurf.de) wrote:
[snip]
: print "Bitte geben Sie eine Farbe ein :";
: $farbe = <STDIN>;
This leaves a newline on the end of $farbe. Add
chomp $farbe;
here and you'll be fine.
: # print $farbe;
: #
: # This only was a test, to see if $farbe contains data
: # It does !
:
: print $COLORS{$farbe};
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Sat, 02 May 1998 07:59:51 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: HELP win32 perl
Message-Id: <354ac80b.22166192@news.btinternet.com>
On Sun, 03 May 1998 10:21:31 GMT, Shawn wrote :
>On Sun, 03 May 1998 06:38:20 GMT, alan@sonic.net (Taran) was forced by
>space aliens to write:
>
Yeah and those same aliens are posing as Morris dancers and
interfering with my head too.
>
>>What am I doing wrong. perl's lib's can't really be this bad... are
>>they????
>no, but the activestate's version of Perl does NOT support sockets so
>Ping does not work.
>
Are you sure about that. The Net::Ping thing doesnt work because it
uses alarm to time out the response and it appears alarm aint
implemented with this variety of Perl.
>don't know why the other doesn't work
>
I'd like to see what error it gives when it fails. You might also
check that the user you are logged in as has permission to do what you
are trying to achieve.
>If you are going to want to use sockets you might want to check into
>the latest GS version of perl available through the CPAN
>(Comprehensive Perl Archive Network) at http://www.perl.com/CPAN/
>according to the readme docs he built it using a form of compiler that
>enables the sockets use (I hope I'm not mangling this).
>
This the "standard" port of Perl to the Win32 platform is based on
5.004.02 where as the ActiveState on is something like 5.003 - a
number of bugs have been fixed and security holes filled between these
two releases. Sarathay's port also has a more comprehensive and more
reliable set of modules such as Tk. Also it feels more perlish for
some undefinable reason.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 3 May 1998 13:55:47 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: HEX to BCD
Message-Id: <6iib33$7tp$1@monet.op.net>
Keywords: boolean Paul Reich yourself
In article <354bf3a2.0@news.primary.net>, Bob Tate <btate@primary.net> wrote:
>Anyone know the math to convert a HEX number to a BCD number?
You seem to be conflating two issues. (I say `seem' because I'm
really not sure what you want.)
Sometimes numbers are stored in the so-called `BCD' format, and have
to be converted to the computer's internal format because the computer
can only calulate with numbers stored in the internal format. Or you
might have a number in the internal format, perhaps as the result of
doing some arithmetic operation, and you want to write it to a file in
BCD format. In all these cases, the internal format is irrelevant to
Perl.
# Suppose $bcd contains some number in BCD format.
# Convert BCD to the computer's internal format
$number = sprintf("%x", $bcd);
# Do some comuptation with $number;
$number = $number * 3 + 15;
# Convert modified number back to BCD
$bcd = hex("$number");
For example, suppose we would like to store the number 1234 in BCD
format. $bcd = hex(1234) in Perl stores the number 4,660 into $bcd;
this number has the bit pattern 0001001000110100, which is just what
you want for the BCD-represented version of 1234. If you write these
two bytes, 00010010,00110100 to a file, you have written the number
1234 in BCD format.
------------------------------
Date: Sun, 03 May 1998 16:35:03 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: How do I print an array in the format I want it?
Message-Id: <8c7m43jotr.fsf@gadget.cscaper.com>
>>>>> "Charles" == Charles Kerekes <dont@want.spam> writes:
Charles> sub PadIp {
Charles> # This sub pads IP address with spaces, if needed, to align the periods.
Charles> my ($ip) = @_[0];
Hmm.. I wonder if that shouldn't just be @_, or maybe my $ip = $_[0].
It works, but I'd say it's misleading to the less aware.
Charles> my @octets = split(/\./,$ip);
Charles> # Format the IP and return as result of sub
Charles> $ip = sprintf
Charles> ("%3d.%3d.%3d.%3d",$octets[0],$octets[1],$octets[2],$octets[3]);
Charles> }
I'd probably try something like this:
sub pad_ip {
my $ip = shift;
sprintf "%3d.%3d.%3d.%3d", split /\./, $ip;
}
That's pretty clean, and it doesn't introduce all that extra
verbosity.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 120 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Sat, 02 May 1998 07:59:53 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: How do I print an array in the format I want it?
Message-Id: <354ad05c.24294865@news.btinternet.com>
On Sun, 03 May 1998 16:35:03 GMT, Randal Schwartz wrote :
<snip>
>
>I'd probably try something like this:
>
> sub pad_ip {
> my $ip = shift;
> sprintf "%3d.%3d.%3d.%3d", split /\./, $ip;
> }
>
>That's pretty clean, and it doesn't introduce all that extra
>verbosity.
>
Or for that added piquancy (but no doubt far slower):
join ".",map sprintf ("%03d",$_), split '\.',$ip;
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 02 May 1998 07:59:43 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Interrupts ... or whatever they are called
Message-Id: <354abd9b.19495244@news.btinternet.com>
On 3 May 1998 14:43:53 GMT, Pablo Hortal wrote :
>Hi,
>
>I need to do the following:
>The user of my system stores a date and a time (Windows 95). At that date &
>time, I need one of my scripts to be called (i.e. like an interrupt).
>
Eh,oh
No not like an interrupt.
You probably need to acquire yourself some kind of scheduling
mechanism like cron on unix or the aborted schedule service on NT. It
is alleged that there are a number of these out there to be had.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sun, 03 May 1998 16:44:50 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Shawn <sweiner@usa.net>
Subject: Re: looking for a little bit of help here.
Message-Id: <Pine.GSO.3.96.980503093631.21603E-100000@user2.teleport.com>
On Sun, 3 May 1998, Shawn wrote:
> Just asking here, but who would I go to to try to report this bug??
The release notes for your copy of Perl should tell you. Generally, you
should contact whoever built Perl for your system. If they can't fix it
for you, use perlbug to report the bug.
> #jeez isn't this a short main?
> procdir($dir,$dirhandle);
Of course, Perl programs don't need to have any 'main' routine at all,
short or long. :-)
> if (index ($_,"\y/") ne "-1") {
Hmmm... You're using a backslash that doesn't do anything, and you're
using a string comparison on a number.
> s|\Q\y/|\../\E|g;
More useless stuff. (I'll let you figure out which one or more characters
there are useless. :-)
> #I decided to put the processing of the dirs in a sub
> #so that I could recurse down paths
Probably should use File::Find, instead.
Well, your code is getting better. :-) Have fun with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 03 May 1998 10:54:24 -0800
From: ~arthur <star@sonic.net>
Subject: malformed header?
Message-Id: <354CBD56.51A3@sonic.net>
Hi,
Anyone know why I get the ole' malformed header message when i try and
get the following program on the net. the problem is O"Reilly's llama
book, Learning Perl page 190-----
#!/usr/bin/perl -w
#cgi-bin/ice_cream:program answer-generate icecream
#order form (version 4)
use strict;#enforce variable declarations and quoting
use CGI qw(:standard);
print header, start_html("Ice Cream Stand"), h1("Ice Cream Stand");
if (param()) {
my $who = param("name");
my $flavor = param("flavor");
my $scoops = param("scoops");
my $taxrate = 1.0743
my $cost = sprintf("%.2f", $taxrate * (1.00 + $scoops * 0.25));
print p("OK, $who, have $scoops scoops of $flavor for \$$cost.");
} else {
print hr();
print start_form();
print p("Whats your name? ", textfield("name"));
print p("What flavor: ", popup_menu("flavor",
['mint',
'cherry', 'mocha']));
print p("How many scoops? ", popup_menu("scoops", [1..3]));
print p(submit("order"), reset("clear"));
print end_form(), hr();
}
print end_html
} else {
print hr, start_form;
print p("Please select a flavor: ", textfield ("flavor", "mint"));
print end_form, hr;
}
-------
I get these errors
# syntax error, near "my"
File 'StarMax HD:Desktop Folder:Mac_Perl:extra folder:ice_cream_stand';
Line 13
# Unmatched right bracket, at end of line
File 'StarMax HD:Desktop Folder:Mac_Perl:extra folder:ice_cream_stand';
Line 13
# syntax error, near "end_html
}"
File 'StarMax HD:Desktop Folder:Mac_Perl:extra folder:ice_cream_stand';
Line 13
# # Execution of StarMax HD:Desktop Folder:Mac_Perl:extra
folder:ice_cream_stand aborted due to compilation errors.
# Callback called exit, <IN> chunk 1.
File 'StarMax HD:Desktop Folder:Mac_Perl:extra folder:ice_cream_stand';
Line 1
# END failed--cleanup aborted, <IN> chunk 1.
File 'StarMax HD:Desktop Folder:Mac_Perl:extra folder:ice_cream_stand';
Line 13
------
Thank you!
~arthur
star@sonic.net
------------------------------
Date: Sun, 03 May 1998 18:35:56 GMT
From: hawk@algonet.se (Hakan Hjelmstrom)
Subject: Re: malformed header?
Message-Id: <3551b8a4.16836239@news.algonet.se>
On Sun, 03 May 1998 10:54:24 -0800, ~arthur <star@sonic.net> wrote:
> Hi, Anyone know why I get the ole' malformed header message when i try and
> get the following program on the net.
<snip code>
You're missing a semicolon after the tax rate declaration.
Hekan Hjelmstrvm
hawk@algonet.se
------------------------------
Date: 3 May 1998 18:05:13 GMT
From: sandell@sparky.parmly.luc.edu (Gregory J. Sandell)
Subject: newbie, how to extract line n from a file
Message-Id: <6iibkp$dpf$1@artemis.it.luc.edu>
Hi, perl newbie here. Can someone tell me how I would grab a line from
a file and assign it to a variable? For example if I had a file FOO
consisting of the lines
Hey there
What's up?
Let's go
I want to be able to say
$myline=getline(2);
And have $myline == "What's up?"
Thanks. Email replies, please!
Greg
--
Gregory J. Sandell, Research Associate, sandell@sparky.parmly.luc.edu
Parmly Hearing Institute, Loyola University Chicago
6525 N. Sheridan Chicago IL 60626 USA voice:773-508-3976 FAX:773-508-2719
WWW: http://www.parmly.luc.edu/sandell/
------------------------------
Date: 3 May 1998 18:27:58 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: newbie, how to extract line n from a file
Message-Id: <6iicve$r1m$3@marina.cinenet.net>
Gregory J. Sandell (sandell@sparky.parmly.luc.edu) wrote:
: Hi, perl newbie here. Can someone tell me how I would grab a line from
: a file and assign it to a variable? For example if I had a file FOO
: consisting of the lines
:
: Hey there
: What's up?
: Let's go
:
: I want to be able to say
: $myline=getline(2);
:
: And have $myline == "What's up?"
Writing this a function requires some design forethought about how the
file gets opened and who else is reading it. If you need to do other
stuff with the file contents, and the file is relatively small, I'd
suggest reading the entire thing into an array:
open FILE, '< myfile.foo' or die "Can't open: $!";
my @lines = <FILE>;
close FILE;
Then just index into the lines array to grab individual lines. Note that
this will give 0-based indices, so your example above would be
$lines[1]. You could easily write a func to do the offset-by-1 lookup if
that's important to you.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 3 May 1998 11:39:13 -0700
From: mcravit+usenet@mcravit.vip.best.com (Matthew Cravit)
Subject: Re: newbie, how to extract line n from a file
Message-Id: <6iidkh$pnc$1@shell3.ba.best.com>
In article <6iibkp$dpf$1@artemis.it.luc.edu>,
Gregory J. Sandell <sandell@sparky.parmly.luc.edu> wrote:
>Hi, perl newbie here. Can someone tell me how I would grab a line from
>a file and assign it to a variable? For example if I had a file FOO
There are a number of ways to do this. You could open the file, read all
the lines from it into an array, and then return the correct element of the
array. Or you could open the file, repeatedly read a line until you've read
the correct number of lines, and return the last line you read. Perhaps if
you posted some code showing what you've tried and where you're running
into a problem, we could be of more help.
>Thanks. Email replies, please!
Why would we do that? If everyone emailed you replies instead of posting
them here, nobody else would learn anything from your problem, and we'd
only be helping you. Besides, if your problem is important enough for us
to spend our time helping you, it should be important enough that you're
willing to visit the newsgroup to look for responses.
Hope this helps.
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@net.com (work) | time you make it.
------------------------------
Date: Sat, 02 May 1998 07:34:11 +0000
From: "Peter G. Martin" <peterm@zeta.org.au>
Subject: Re: Pattern Matching
Message-Id: <354ACC73.343A8358@zeta.org.au>
Angelo Sirigos wrote:
>
> I am trying to find a particular patter in a document and it doesn't
> seem to be working.
.............
>
> $NewHRef = '<!--#include file="clindisc.mdssi"-->';
> $LookFor1 = "<TABLE(.*?)Clinical Discussion(.*?)Submit Your
> Comment(.*?)</TABLE>";
> $buffer =~ s/$LookFor1/$NewHRef/ig;
>
When I see things like:
$LookFor1 = "<TABLE(.*?)Clinical Discussion(.*?)Submit Your
Comment(.*?)</TABLE>";
followed by
$buffer =~ s/$LookFor1/$NewHRef/ig
I tend to reach for perldoc and look up the use of \Q...\E and
s/\W/\\$1/g;
and things like that.
And usually, in debugging,
I try doing a "print $Lookfor1" before I do the search.
Maybe you should, too.
--
peterm
Peter G. Martin, Tech.Writer & Perl User
The Scribe & Chutney Trust
peterm@zeta.org.au, http://www.zeta.org.au/~peterm
------------------------------
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 2483
**************************************