[7267] in Perl-Users-Digest
Perl-Users Digest, Issue: 892 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 20 00:07:57 1997
Date: Tue, 19 Aug 97 21:00:31 -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 Tue, 19 Aug 1997 Volume: 8 Number: 892
Today's topics:
*Really* dynamic function loading? (Dan Zerkle)
Re: *Really* dynamic function loading? (Abigail)
Re: .htgroup files and HTTPD:GroupAdmin:Text.pm <jwyates@netcom.com>
Re: associative array question <polone@sanasys.com>
Re: Chars into Array (Tad McClellan)
Re: comparing for a range of number - easiest way to do <stuartc@ind.tansu.com.au>
Re: Debugging PIPEs script <burleigh@hackberry.chem.niu.edu>
Re: Directory searching <pfeifer@ls6.informatik.uni-dortmund.de>
Re: getting variables <polone@sanasys.com>
Re: Help reading massive file <petri.backstrom@icl.fi>
Re: HELP with script (David Bauman)
Re: help with this search pattern problem!! <pfeifer@ls6.informatik.uni-dortmund.de>
Re: How can I read one single character? <pfeifer@ls6.informatik.uni-dortmund.de>
Re: How do I get started with win95? <rjo100@york.ac.uk>
Re: How to Wrap long lines?? (Novice) (Tad McClellan)
Re: naming arrays (Tad McClellan)
Re: naming arrays <burleigh@hackberry.chem.niu.edu>
Re: need help with perl and dates <polone@sanasys.com>
Re: Number conversion help <burleigh@hackberry.chem.niu.edu>
Re: readig a file into an array (Tad McClellan)
Re: readig a file into an array (Adam Rogoyski)
Re: readig a file into an array (David Bauman)
Retrieving graphic dimensions through PERL w/o actually (Raleigh)
Re: Script testing <polone@sanasys.com>
Re: Universal Descrambler!!! (David Bauman)
When a number is no longer a number <gjb@cs.washington.edu>
Re: Why warning of uninitialized value even if it is in <polone@sanasys.com>
writing to a file <colte@hem.passagen.se>
Re: writing to a file <polone@sanasys.com>
Re: WWW::Search not returning anything (John Heidemann)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 Aug 1997 00:21:05 GMT
From: zerkle@krakatoa.cs.ucdavis.edu (Dan Zerkle)
Subject: *Really* dynamic function loading?
Message-Id: <5tdd9h$j10$1@mark.ucdavis.edu>
Hmmm. The Perl FAQ seems to be inaccessible. I guess I'll have
to post.
I want to do some very late loading and execution of subroutines,
but I don't know if it is possible. Here's what I want:
#1 Write library containing useful set of Perl functions.
#2 Write data file containing name of library and its functions.
#3 Run a magical program in Perl. Magic program loads data file
and sees names of library and its functions.
#4 Magical program somehow loads library.
#5 Magical program makes calls to useful functions and gets data
back from them.
Is this possible? How?
I'm pretty much a novice with Perl, so please don't leave out
any details. If possible, I'd really like a reference in the
2nd edition Camel book.
--
Dan Zerkle zerkle@cs.ucdavis.edu
GCS d(---)(!) p- c++ !l u++ e++(+++) m s++/-- !n h+(--) f g+++(-) w+ t+ r(-) y+
Stamp out Internet spam! See http://www.vix.com/spam/ to help.
------------------------------
Date: Wed, 20 Aug 1997 00:58:58 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: *Really* dynamic function loading?
Message-Id: <EF6tEA.K9y@nonexistent.com>
Dan Zerkle (zerkle@krakatoa.cs.ucdavis.edu) wrote on 1450 September 1993
in <URL: news:<5tdd9h$j10$1@mark.ucdavis.edu>>:
++
++ I want to do some very late loading and execution of subroutines,
++ but I don't know if it is possible. Here's what I want:
++
++ [ snip ]
++
++ I'm pretty much a novice with Perl, so please don't leave out
++ any details. If possible, I'd really like a reference in the
++ 2nd edition Camel book.
page 380. "Autoload - Load functions only on demand".
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=$]*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Wed, 20 Aug 1997 02:25:08 GMT
From: "John W. Yates" <jwyates@netcom.com>
To: rootbeer@teleport.com, dougm@opengroup.org
Subject: Re: .htgroup files and HTTPD:GroupAdmin:Text.pm
Message-Id: <33FA5584.33E4@netcom.com>
Thanks to those who helped on the Text.pm problem I posted. I
discovered today that the problem was a back level version of the
file on the ISP. I'm using a "hacked" version until the newest
version of HTTPD gets installed.
Appreciate your time and help.
John
--
John W. Yates mailto:jwyates@netcom.com \
home page: ftp://ftp.netcom.com/pub/jw/jwyates/jwyates.html
------------------------------
Date: Tue, 19 Aug 1997 21:00:19 -0500
From: Patrick O'Lone <polone@sanasys.com>
Subject: Re: associative array question
Message-Id: <33FA4FB2.1BAE@sanasys.com>
Use a format statement, one for the header and one for the general body.
To make it so that it updates easily, make sure it overwrites the old
output file like this:
open(FILE,">filename.txt");
us a format like:
format FILESIZES=
@<<<<<<<<<<< @<<<<<<<<<<<<
$_,$count{$type}
.
and a format header like:
format FILESIZES_TOP =
File Type File Size
========= =========
.
and then a loop switching off variables. Like this:
$oldhandle = select(OUTPUT);
$~ = "FILESIZES";
select($oldhandle);
foreach(keys @count) {
print OUTPUT;
}
print OUTPUT "The total size is $totalsize\n";
That should work for your program. I hope this helps. Write me if it
does.
--
Patrick O'Lone
Sana Systems Webmaster Administrator
polone@sanasys.com
"The edge is everything..."
------------------------------
Date: Tue, 19 Aug 1997 18:10:24 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Chars into Array
Message-Id: <059dt5.hu9.ln@localhost>
Matthew White (mtw@user1.channel1.com) wrote:
: This message has been emailed and posted.
: John-
: Try something like:
: $x = '-1.942';
: @p = split(//, $x);
: (There is no space between the slashes.)
: The R.E. // tells perl to split on the letter boundary.
^^^^^^^^^^^^^^^^^^^^^^
No, it tells perl to split on the null string.
'-1.942' has seven null strings and five 'word boundaries' (\b).
I don't know what a 'letter boundary' is, but I don't see _any_
letters in that value for $x...
What did you mean by 'letter boundary'?
: On Tue, 19 Aug 1997 10:05:10 -0700, John Grimm <ken1@earthlink.net>
: wrote:
: >How can I get a variable (say $x) into an array (say @p)?
: >
: >I want to get a number like -1.942 so it's like @p = (-,1,.,9,4,2)
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 20 Aug 1997 11:40:22 +1000
From: Stuart Cooper <stuartc@ind.tansu.com.au>
Subject: Re: comparing for a range of number - easiest way to do it?
Message-Id: <yeo4t8l4oop.fsf@kudu.ind.tansu.com.au>
over@the.net (dave) writes:
> Ronald Fischer <rovf@earthling.net> wrote:
>
> >Hi
> >not a very important question, but I am curious ....
> >
> >does someone know an easier way to write
> > die "foo" if ($x <= $a or $x >= $b);
> >provided that
> > $a <= $b
>
> Assuming you are testing input $x against limits $a and $b, I suggest:
>
> die "foo" unless
> ( $x =~ /^(\d+)$/ and $1 > $a and $1 < $b );
not quite- you want $1 > $a or $1 < $b; you want eg x < 2 and x > 5
at the same time: a bit tricky.
>
>
> This requires $x to be an integer between but not including $a and $b.
>
> Dave
This is the way I do these things:
Ex 1) is x between 2 and 5 inclusive?
Math: 2 <= x <= 5
Perl: if ( (2 <= $x) and ($x <= 5))
laying it out like this is superior to
having $x first both times which most programmers would do.
if ( ($x >= 2) and ($x <= 5)) # BAD - harder to read
Ex 2) is x outside of 2 and 5 inclusive?
Math: x < 2, x > 5
Perl: if ( ($x < 2) or ($x > 5))
can we get a nice formatted version of this? Don't think so.
if ( not ((2 <= $x) and ($x <= 5))) # $x outside of range [2,5]
$x is *not* in the range between 2 and 5.
this equates to the or version;
NOT (A and B) <==> ( (NOT A) or (NOT B)) [A De Morgan law]
you can employ the Maths range notation in your comments
ie [2,5] is 2 <= x <=5 (2,5] is 2 < x <=5
[2,5) is 2 <= x < 5 and (2,5) is 2 < x < 5
although it looks mightily like an ordered pair.
Hope this helps,
Stuart Cooper
stuartc@ind.tansu.com.au
------------------------------
Date: Tue, 19 Aug 1997 20:08:09 -0500
From: Darin Burleigh <burleigh@hackberry.chem.niu.edu>
Subject: Re: Debugging PIPEs script
Message-Id: <33FA4379.3DE3@hackberry.chem.niu.edu>
Jay Brunker wrote:
>
> Hi All:
>
> Does anyone see what the error is in this piece of code?
>
> The idea of this code is to run prtvtoc on all devices in
> /dev/rdsk/ of slice '2'.
>
> I get an error near "Cannot open output" or
> if I use 'system()' I seem to get a broken pipe error.
>
> Here 'tis!
>
> foreach $dev (glob('/dev/rdsk/c*t*d*s2'
> {
> open(PIPE, "/usr/sbin/prtvtoc -h $dev|"
> open(OUT,">/tmp/$outfile"
> while(<PIPE> {print OUT;
> close(PIPE ; close(OUT ;
> }
>
> * Please note...to add further confusion the left parens
> symbol doesn't seem to display when I use Netscape. Egads!!!!
>
after you get your left paren working, add something like
die("I can't open this file because: $! \n");
> Any help will be greatly appreciated.
>
> Jay.
--
==========================================================
- darin
burleigh@hackberry.chem.niu.edu
\\//\\//.\\//\\//.\\//\\//. http://hackberry.chem.niu.edu/HOME/dcb/
'2 kinds of green, look out!' - dieter rot
------------------------------
Date: 18 Aug 1997 11:40:38 +0200
From: Ulrich Pfeifer <pfeifer@ls6.informatik.uni-dortmund.de>
Subject: Re: Directory searching
Message-Id: <yfmzpqf3k2x.ulp@gretchen.informatik.uni-dortmund.de>
>>>>> "Anne" == Anne Kumar <annek@nortel.ca> writes:
Anne> I was wondering if there was anyway to search hierarchically through
Anne> directories and replace items in those files. I've tried the chdir and
Anne> opendir but they seem to only work with one subdirectory and no other
Anne> directories below that level. If you have any suggestions please let
Anne> me know.
man File::Find
Ulrich Pfeifer
--
perl -e 'print map chr($_&=127), unpack "C*", pack "w", \
"28031325277245338375695089304165009203757780884355338"'
------------------------------
Date: Tue, 19 Aug 1997 21:15:29 -0500
From: Patrick O'Lone <polone@sanasys.com>
To: Rick Bauman <rick@internetx.net>
Subject: Re: getting variables
Message-Id: <33FA5341.20C4@sanasys.com>
try grepping for the text string first, and see what you get.
That would be a good test ground. I can suggest that you can break up
line headers knowing how many spaces are in between using regular
expressions.
$line = <FILE>;
if ($line =~ /.+\s{the number of spaces}.+/) {
($somename,$randomtext) = split(/\s*/,$line);
}
--
Patrick O'Lone
Sana Systems Webmaster Administrator
polone@sanasys.com
"The edge is everything..."
------------------------------
Date: Tue, 19 Aug 1997 22:49:41 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Help reading massive file
Message-Id: <33F9F8D5.4E8E@icl.fi>
Ed Vander Bush wrote:
>
> I am creating a text file to hold user information for a site.
> User ID Name Var1 var2 etc......,..
> Seperated by tabs
> I need to know how to find a line based on the User Id and then take the
> information out of that line and set each one to a variable in the
> script. Thanks!
Where's the massive part (or do you expect to store
millions of user records, or a few users, but store
massive amounts of data per user)?
Anyway, if you want to use Perl, then look up
open(), die(), the <> operator, close(), split()
and regular expressions in the Perl documentation.
If you dont't know Perl, I suggest you start
with a book such as "Learning Perl, 2nd Edition",
published by O'Reilly, http://www.ora.com
Quick example to start with:
#!/usr/bin/perl -w
use strict;
my $userid;
my $name;
local( *FILEHANDLE );
open( FILEHANDLE, '<filename' ) or
die "error opening file ($!)";
while( <FILEHANDLE> ) {
chomp;
( $userid, $name ) = ( split( /\s+/, $_ ) ) [0,1];
print "UserID: $userid, Name: $name\n";
}
close( FILEHANDLE );
See also http://www.perl.com/FAQ/ before you
ask any questions, and http://www.perl.com/CPAN/
before you try to reinvent wheels that someone
else has already written for you to use.
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: Wed, 20 Aug 1997 03:14:44 GMT
From: davey@harvard.edu (David Bauman)
Subject: Re: HELP with script
Message-Id: <33fb4b6c.605197948@bigheera>
On Tue, 19 Aug 1997 14:28:10 -0700, "Lic. Juan Carlos Murillo"
<murillo@infocostarica.com> wrote:
>could someone tell me how to make my script so each time it writes to
>the log file it appends the new data to the old log file instead of
>making a new one every time.[...]
># Open the log file and write the data
>open(FILE, ">$logfile") || die "I can't open $logfile\n";
Obligatory Opening Statement:
Go read the perlref man pages.
(I'm only kinda kidding... You should make yourself
read documentation; you'll get better faster if you do.
(note to self... read documentation...))
Stick another ">" in there. That should do the trick:
open(FILE, ">>$logfile") || die "I can't open $logfile\n";
This should append to $logfile. If it doesn't already
exist, PERL should create it for you.
A few things that I have a habit of doing when
dealing with logfiles: (examples at bottom)
- Check to see if $logfile is exists; if not, create a new
one with a header that includes a time-stamp. Depending
on what you're doing, this can sometimes help when you
need to archive log files or figure out when something
began.
- If there is a possibility that more than one of your
program might be running at once (if it's a CGI script
for instance), use a simple file locking scheme to
avoid tangled up log entries.
- Turn on $OUTPUT_AUTOFLUSH for that output
stream (stuff written to <FILE>). Your OS buffers
the data that you send to an output stream
(like STDIN, STDOUT, or the file handle
you've created; FILE), and you'll prolly want
the data to get written to disk ASAP. Again, if
you might have more than one process
writing to the same file, letting the OS decide
when it wants to commit the writes may result
in an interwoven logfile! ( $| = 1; )
- Write a logging function. You may find that
you are doing an open(FILE...)...close(FILE)
in more than one place in your program.
Sticking this in a function of it's own is better.
It will impress your friends, or if you don't have
any, it will impress... uh... never mind.
Examples: (I just paste/typed these in; they're
meant to be read, not cut & pasted...) This is
a pretty basic way of doing this stuff, but given
the question you asked, waaaay overkill... heh...
If you wanted to do stuff as I've sketched below,
instead of doing the OPEN...print FILE sequence
each time you wanted to log something, you
might call it like this: ( ".=" appends to a string)
[...]
$msg_to_log = "Someone filled the legal info form\n";
$msg_to_log .= "with the following information:\n";
$msg_to_log .= "Name: $in{'Name-'}\n";
$msg_to_log .= "Company: $in{'Company-'}\n";
log_this($msg_to_log);
[...]
sub log_this {
my($log_message) = @_;
# "$log_message" gets what you pass to log_this()
if( !(-e $logfile) ) { ## if no $logfile...
open(FILE, ">$outfile") || die "Couldn't create $logfile - $!";
select FILE;
$| =1; ## auto-flushes writes to <FILE>
print FILE ("=======================================\n");
print FILE (" My Logfile -- Created: $date_time\n");
### NOTE- $date_time was created elsewhere...
print FILE ("======================================\n\n");
close(FILE);
}
if (-w $logfile) { ## if $logfile is writable...
lock_log($logfile); ## do that file locking thing
open (FILE, ">>$logfile") || die "Uh oh... $!";
## there's that append-to-file! whoo hoo!
select FILE;
$| =1; ## auto-flushes writes to <FILE>
print FILE ("Received on $date_time\n");
print FILE ("$log_message\n\n-----------[end of log entry]");
close (FILE);
unlock_log($logfile); ## remove the lock file
}
else {
print STDERR ("$logfile not writable!!! Bad craziness! $!\n");
}
} ## end of log_this()
### This checks for a lock file, and waits some number
### of seconds before just going ahead anyhow
#
sub lock_log
{
my($log_filename) = @_;
my($unlock_in, $lock_file);
$lock_file = "lock_$log_filename";
## name the lock file "lock_" plus
## the name of your logfile, just in case
## you've got multiple things that you lock
## in this fashion...
$unlock_in = 8; ## kill the lockfile after x seconds
$unlock_in = time + $unlock_in;
while ( -e $lock_file && (time < $unlock_in) ) {
sleep(1);
}
### This will loop for $unlock_in seconds, after which time
### you decide that the lockfile should have been zapped
### by any process that was functioning correctly...
open(LOCK_FILE, ">$lock_file") || die "Ug! $!";
select LOCK_FILE; ## hey, who knows?
$| =1;
close(LOCK_FILE); ## don't need to keep it open
return(1); ## tell the caller that the lock file
## was successfully created. (not used above)
}
### This just blows the lock file away
#
sub unlock_log
{
my($log_filename) = @_;
my($lock_file);
$lock_file = "lock_$log_filename";
unlink($lock_file) || die "more problems... $!";
}
Hope this is helpful. I don't know what inspired me
to sit here and write this. Well, plenty of junk for people
to interject improvements upon... (use flock()... use
semaphores...)
[ d*b ]
------------------------------
Date: 18 Aug 1997 11:36:23 +0200
From: Ulrich Pfeifer <pfeifer@ls6.informatik.uni-dortmund.de>
Subject: Re: help with this search pattern problem!!
Message-Id: <yfm3eo74yug.ulp@gretchen.informatik.uni-dortmund.de>
>>>>> "Xu" == Xu Chu <xuchu@iscs.nus.edu.sg> writes:
Xu> open(FP1,"infile");
Xu> while(<FP1>) {
Xu> die "unknown format for $_"
Xu> unless s#^[\s\S]*<pre>\n((<a href=.*\n)*)</pre>[\s\S]*$#$1#is;
Xu> print;
Xu> }
Xu> close(FP1);
Xu> i think the 's' in the search pattern can deal the whole file
Xu> as a single line but failed.
The search pattern would do what you expect, if you had read the
whole file into $_. But you probably only have the first line in it.
man perlvar / $/
Ulrich Pfeifer
--
perl -e 'print map chr($_&=127), unpack "C*", pack "w", \
"28031325277245338375695089304165009203757780884355338"'
------------------------------
Date: 18 Aug 1997 11:38:18 +0200
From: Ulrich Pfeifer <pfeifer@ls6.informatik.uni-dortmund.de>
Subject: Re: How can I read one single character?
Message-Id: <yfm203r4yr9.ulp@gretchen.informatik.uni-dortmund.de>
>>>>> "Markus" == Markus Daberkow <daberkow@bln.sel.alcatel.de> writes:
Markus> How can I read one single char from STDIN? I don't want to
Markus> press the return key after typing that char.
perl -MCPAN -e shell
m /Term::ReadKey/
Ulrich Pfeifer
--
perl -e 'print map chr($_&=127), unpack "C*", pack "w", \
"28031325277245338375695089304165009203757780884355338"'
------------------------------
Date: Mon, 18 Aug 1997 19:32:18 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: How do I get started with win95?
Message-Id: <33F89532.21DB9522@york.ac.uk>
Richard Butcher wrote:
>
> I've written a few scripts and got them working and I'm learning more every
> day but the only way I can test them is to go on-line, upload the script
> and waste my Service Provider's processing time. Remember too, in some
> benighted countries we still have to pay for the phone connection while
> we're on line.
>
> Of course, in an ideal world, it would be perfect to have enough of what's
> needed for a server to make the things work for real: like I fill in a form
> on my web page, press the send button and it all happens (off line).
Download a web server such as OmniHTTPd (a quick web search should find
it), then set it up on your own machine and point your browser at
http://127.0.0.1/ - no need to go online, you can just execute the
script on your own machine, exactly as you would on your ISP's server.
HTH,
Russ (just started learning perl, and have done the same thing)
---------------------------------------------------------------------
--[ R u s s e l l O d o m ]---[ mailto:rjo100@york.ac.uk ]--
--[ University of York, UK ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[ FAQ maintainer, news:comp.os.ms-windows.win95.moderated ]--
---------------------------------------------------------------------
------------------------------
Date: Tue, 19 Aug 1997 18:14:59 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to Wrap long lines?? (Novice)
Message-Id: <jd9dt5.hu9.ln@localhost>
Daniel E. Macks (dmacks@sas.upenn.edu) wrote:
: Satyajit Patel (sjpatel@spd.dsccc.com) said:
: : Hi all,
: : I have been working with perl for a bit now. But I have not figured out
: : how to
: : wrap a very long line when printing it to screen.
: : I saw someone had written code to do that but I can't remember where I
: : saw it. Can someone please help with this?
: DejaNews, AltaVista and WebCrawler all have very long memories, and
: would be perfectly suited for your situation. Or you might say "I must
: not be the first person who's had this problem...I bet it's in the FAQ
: and/or someone's written a module to do it" and then head on over to
: http://www.perl.com/CPAN/ and scan the docs and module list for some
: relevant keywords.
Most excellent advice from Daniel.
Just let me add that a case-insensitive word search for 'wrap' in
the free documentation that is included with the perl distribution
finds only about 25 lines. One of those (in perltoc.pod) mentions
the module that is used for wrapping text...
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 19 Aug 1997 18:26:04 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: naming arrays
Message-Id: <c2adt5.90a.ln@localhost>
MAHANTA girish (mahanta@cs.concordia.ca) wrote:
: Hello!
: Can I know how to go about this:
: I have a large number of arrays named: @bw00, @bw01, .... @bw050
: Inside the program I want to reference the arrays dynamically, with help of
: the numbers following the @bw string. Say @bw$n where $n has the subscript
: of the array I want to reference, without having to wrtie @bw00 explicitely.
: Is there any way I can do this? I appreciate any help.
Whenever you find yourself using variables with increasing integer parts
in the variable name, you are probably doing something that should be
in an array instead.
So, since you have arrays with such names, you would likely be better
off by using an array of arrays. See the perllol man page for info
on how to do that.
If you insist on doing it as originally stated, then you may find the
'Symbolic references' section in the perlref man page to be helpful...
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 19 Aug 1997 20:09:30 -0500
From: Darin Burleigh <burleigh@hackberry.chem.niu.edu>
Subject: Re: naming arrays
Message-Id: <33FA43CA.2854@hackberry.chem.niu.edu>
MAHANTA girish wrote:
>
> Hello!
>
> Can I know how to go about this:
>
> I have a large number of arrays named: @bw00, @bw01, .... @bw050
> Inside the program I want to reference the arrays dynamically, with help of
> the numbers following the @bw string. Say @bw$n where $n has the subscript
> of the array I want to reference, without having to wrtie @bw00 explicitely.
>
> Is there any way I can do this? I appreciate any help.
>
> Regards,
>
> Girish.
@{bw$n}
--
==========================================================
- darin
burleigh@hackberry.chem.niu.edu
\\//\\//.\\//\\//.\\//\\//. http://hackberry.chem.niu.edu/HOME/dcb/
'2 kinds of green, look out!' - dieter rot
------------------------------
Date: Tue, 19 Aug 1997 20:23:56 -0500
From: Patrick O'Lone <polone@sanasys.com>
To: Masoud M-Kho'i EHS/LI 80441 3322 <ehsmakh@aom.ericsson.se>
Subject: Re: need help with perl and dates
Message-Id: <33FA472C.51DB@sanasys.com>
Masoud M-Kho'i EHS/LI 80441 3322 wrote:
>
> Hi,
>
> I'm a beginner with perl and now I'm constructing webpages with perl.
> Poweful language but I have run into problems which I can't find a
> solution to. I want to fetch the date from the computer time and assign
> it to a variable. I'm just interested in the date. I found out one way
> to do it:
>
> $date=`date '+%y%m%d'`;
>
> It works fine except that a newline is inserted in the end and it's
> essential for me not to have the newline there.
> What to do instead? Why is there a newline? Why can't I see the newline
> as a symbol or something?
> I saw the Perl motto saying "There's more than one way to do it" and
> maybe there is another way...
well, you can use "chop" to cut off the newline character like this:
chop($date);
However, PERL comes with a better way of doing it: using the ctime.pl
include file.
the syntax would be:
require "ctime.pl";
$date = &ctime(time);
That will create a date for you, with no newline. Just print it out to
see the format.
--
Patrick O'Lone
Sana Systems Webmaster Administrator
polone@sanasys.com
"The edge is everything..."
------------------------------
Date: Tue, 19 Aug 1997 20:05:00 -0500
From: Darin Burleigh <burleigh@hackberry.chem.niu.edu>
Subject: Re: Number conversion help
Message-Id: <33FA42BC.13F4@hackberry.chem.niu.edu>
John Grimm wrote:
>
> I need to translate a number like -1.7 to -017000 or something like 9.3
> to +093000
>
> Any suggestions?
what do you mean by translate?
do you mean multiply?
$old_num = 1.7;
$new_num = $old_num * 10000;
or multiply and format?
printf "%06d", $new_num;
--
==========================================================
- darin
burleigh@hackberry.chem.niu.edu
\\//\\//.\\//\\//.\\//\\//. http://hackberry.chem.niu.edu/HOME/dcb/
'2 kinds of green, look out!' - dieter rot
------------------------------
Date: Tue, 19 Aug 1997 18:20:16 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: readig a file into an array
Message-Id: <gn9dt5.90a.ln@localhost>
Ed Vander Bush (temp.ed.vanderbush@bentley.com) wrote:
: Can I
: open a file
: @my_array = filehandle
: close file
: Id there anything wrong with this?
Yes. It will not compile. I'd call that wrong ;-)
Even after modifying it to compile, we still wouldn't know if there
was anything wrong with it, because you haven't told us what you
would expect that to do.
Would you care to share with us what it is that you wish to accomplish?
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 20 Aug 1997 02:18:54 GMT
From: ifqa242@spice.cc.utexas.edu (Adam Rogoyski)
Subject: Re: readig a file into an array
Message-Id: <5tdk6e$5f6$1@geraldo.cc.utexas.edu>
Ed Vander Bush (temp.ed.vanderbush@bentley.com) wrote:
: Can I
: open a file
: @my_array = filehandle
: close file
: Id there anything wrong with this?
Yes, you need <>'s around filehandle
@my_array = <filehandle>;
--
__/\__. [-Temperance-] .__)\__
! \ oO / . :[Adam Rogoyski]: . \ oO / !
. /_\/_\ . :[ apoc@laker.net ]: . /_\/_\ .
\/ . :[ http://www.laker.net/apoc ]: . \/
------------------------------
Date: Wed, 20 Aug 1997 03:29:27 GMT
From: davey@harvard.edu (David Bauman)
Subject: Re: readig a file into an array
Message-Id: <33fd6422.611523904@bigheera>
On Tue, 19 Aug 1997 18:20:16 -0500, tadmc@flash.net (Tad McClellan)
wrote:
>Ed Vander Bush (temp.ed.vanderbush@bentley.com) wrote:
>: Can I
>: open a file
>: @my_array = filehandle
>: close file
>
>: Id there anything wrong with this?
>Yes. It will not compile. I'd call that wrong ;-)
>
>Even after modifying it to compile, we still wouldn't know if there
>was anything wrong with it, because you haven't told us what you
>would expect that to do.
Come on now... I think that Ed was providing us with pseudo-code.
Given that you stick the right syntax in there, it works just fine.
[ d*b ]
------------------------------
Date: Wed, 20 Aug 1997 00:14:44 GMT
From: (Raleigh)
Subject: Retrieving graphic dimensions through PERL w/o actually loading image?
Message-Id: <33fa361d.4759481@news.mindspring.com>
I am writing some Perl CGI scripts that manipulate images. My problem
is that I want to include the WIDTH and HEIGHT attributes with the
HTML code I send back to the client and the images I work with are of
varying sizes.
Any suggestions?
------------------------------
Date: Tue, 19 Aug 1997 21:05:31 -0500
From: Patrick O'Lone <polone@sanasys.com>
To: "Shane P. Miles" <yngwie@erols.com>
Subject: Re: Script testing
Message-Id: <33FA50EB.17ED@sanasys.com>
Shane P. Miles wrote:
>
> Where can I get a hold of a personal web server so I can try out > my scripts? I've searched with very little luck.
Check with your System Administrator. If you r using an ISP, you can
usually telnet into their system and test scripts. Just make sure that
you get permission first. System Admins love knowing what is going on,
and well, not telling them that your going to test out scripts their
server might just tick them off.
--
Patrick O'Lone
Sana Systems Webmaster Administrator
polone@sanasys.com
"The edge is everything..."
------------------------------
Date: Wed, 20 Aug 1997 03:24:33 GMT
From: davey@harvard.edu (David Bauman)
Subject: Re: Universal Descrambler!!!
Message-Id: <33fc615e.610815285@bigheera>
On Tue, 19 Aug 1997 16:29:44 -0500, John Hancock
<John23@worldnet.att.net> wrote:
> I myself a former cable tv repair man is sick of high monthly payments
>and how cable tv employees are treated. I hope to get back at the cable
>companies as much as possible by selling a universal descrambler box!
Wow, cool! Written in PERL?!!??
>That's right this box works on every cable tv system world wide.
Awesome. No portability issues here!
>It is rather simple to make, but just in case you would not be able to
>figure it out by my plans , I made it for you.
Whew. I *hate* having to figure out plans. Thank goodness
for Brian Weber and Microsoft! Huh... I wonder if it decyphers
SSL sessions over a MediaOne feed.
[ d*b ]
(sorry, feeling punchy)
------------------------------
Date: Tue, 19 Aug 1997 23:49:25 GMT
From: Greg Badros <gjb@cs.washington.edu>
Subject: When a number is no longer a number
Message-Id: <qrriux120oq.fsf@chiwawa.cs.washington.edu>
Can anyone explain this behaviour to me? It appears that perl gets
confused by the expression involving a function call and thinks that the
SV assigned to $val is no longer an ordinary number. The bug (?) is
only picked up w/ the xs version of DataDumper since that checks the
actual SV instead of using standard is_a_number heuristics.
Thanks,
Greg J. Badros
gjb@cs.washington.edu
Seattle, WA USA
http://www.cs.washington.edu/homes/gjb
#-----------begin script---------------------
#!/uns/bin/perl5.00402 -w
# Using perl5.004, subversion 0 on linux x86
# also tried w/ subversion 2 on same, same results
use strict;
use Data::Dumper; # version 2.07
{ no strict;
my $val = fn1();
print Data::Dumper->Dumpxs([$val],["*val"]);
print Data::Dumper->Dump([$val],["*val"]);
$val += 0;
print Data::Dumper->Dumpxs([$val],["*val"]);
print Data::Dumper->Dump([$val],["*val"]);
$val = int($val);
print Data::Dumper->Dumpxs([$val],["*val"]);
print Data::Dumper->Dump([$val],["*val"]);
}
exit 0;
sub fn1 () {
return 0 + fn2();
}
sub fn2 () {
return 1;
}
#-----------end script---------------------
Output is:
$val = '1';
$val = 1;
$val = '1';
$val = 1;
$val = 1;
$val = 1;
------------------------------
Date: Tue, 19 Aug 1997 21:02:41 -0500
From: Patrick O'Lone <polone@sanasys.com>
To: Ronald Fischer <rovf@earthling.net>
Subject: Re: Why warning of uninitialized value even if it is initialized?
Message-Id: <33FA5041.31E2@sanasys.com>
yes, it produces the same result.....
--
Patrick O'Lone
Sana Systems Webmaster Administrator
polone@sanasys.com
"The edge is everything..."
------------------------------
Date: Tue, 19 Aug 1997 09:57:26 +0200
From: Robban <colte@hem.passagen.se>
Subject: writing to a file
Message-Id: <33F951E6.5828@hem.passagen.se>
Hello I'm a Perl beginner running perl 5.
When I write to a file using the append mode
it places it at the end of the file.
I want to replace a line in the middle of the file.
(For updating a html page)
Does anyone know how to accomplish this ?
Thanks
Robert
------------------------------
Date: Tue, 19 Aug 1997 21:28:27 -0500
From: Patrick O'Lone <polone@sanasys.com>
To: Robban <colte@hem.passagen.se>
Subject: Re: writing to a file
Message-Id: <33FA564B.C4@sanasys.com>
If the document is static, you could read, check for a flag (could be in
a comment), and write to that place in the document. However, this
approach uses some disk i/o action. (I realized how bad that can be when
you right a chat protocol using PERL, javascript, and HTML). But,
because PERL is so fast - you won't notice the difference unless your
server is always bogged down. :-)
--
Patrick O'Lone
Sana Systems Webmaster Administrator
polone@sanasys.com
"The edge is everything..."
------------------------------
Date: 19 Aug 1997 17:09:47 -0700
From: johnh@dash.isi.edu (John Heidemann)
Subject: Re: WWW::Search not returning anything
Message-Id: <johnh.872033877@dash.isi.edu>
tony@niweb.com (Tony Bowden) writes:
>I've been trying to get the WWW::Search modules to work, but I can't
>actually get the query to return anything ...
Unfortunately, search engines have a tendency to change their output.
Humans adapt well to this, but the regular expressions in WWW::Search
don't. AltaVista finally redid their format, breaking WWW::Search.
Unfortunately, AltaVista's new format is now more difficult to manage
(it uses <input...> rather than just <a href...> to link to the next
page). I hope to update it, but other events (this little marriage
thing this weekend) are conspiring against it happening in the next
week.
-John Heidemann
------------------------------
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 892
*************************************