[17694] in Perl-Users-Digest
Perl-Users Digest, Issue: 5114 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 14 18:05:40 2000
Date: Thu, 14 Dec 2000 15:05:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976835117-v9-i5114@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 14 Dec 2000 Volume: 9 Number: 5114
Today's topics:
Re: #include files? sort of (Stan Brown)
Re: #include files? sort of <elijah@workspot.net>
Re: #include files? sort of <ren.maddox@tivoli.com>
Re: #include files? sort of <bart.lateur@skynet.be>
.NET in One Day Seminar - 2001 Schedule alexander_prigozhin@my-deja.com
Re: .NET in One Day Seminar - 2001 Schedule <uri@sysarch.com>
Re: 3 questions <ren.maddox@tivoli.com>
Re: 3 questions <peter.sundstrom@eds.com>
[q] split in while loop <bh_ent@my-deja.com>
Re: [q] split in while loop <krahnj@acm.org>
Re: [q] split in while loop <latsharj@my-deja.com>
Re: [q] split in while loop <stephenk@cc.gatech.edu>
[Zvon Announcement] DOM Factory - version 0.9 <nicmila@idoox.com>
Re: Ada feature borrowed for Perl?? <iowa8_song8.remove_eights@hotmail.com>
Algorithm::Diff -- unexpected behavior? <iowa8_song8.remove_eights@hotmail.com>
Re: Algorithm::Diff -- unexpected behavior? <iowa8_song8.remove_eights@hotmail.com>
Re: Algorithm::Diff -- unexpected behavior? (Malcolm Dew-Jones)
Associate more than one FH with a $cgi? alazarev1981@my-deja.com
Calling a remote script. <jeffahill@_ANTISPAM_.lucent.com>
CGI: Dealing with checkboxes and multiple <SELECTS> <cleon42@my-deja.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Dec 2000 15:45:57 -0500
From: stanb@panix.com (Stan Brown)
Subject: Re: #include files? sort of
Message-Id: <91bbi5$6rq$1@panix6.panix.com>
In comp.lang.perl.misc you write:
>In <3A38E8B7.5EAF4AB0@home.com> Michael Carman <mjcarman@home.com> writes:
>>Stan Brown wrote:
>>>
>>> I have a small perl script that will eventually be one of a pair
>>> of co-operating tasks. I am planing on using on confiugration
>>> file for both tasks. Since the code for pareseing this file is
>>> common, I wnat to pull it out into a file to "#included" by both
>>> scripts.
>>In a nutshell, what you want to do is create a separate file, put all
>>your global vars and your sub in it, tell it to export them, and then
>>put a 'use Foo' in each of your main scripts, where 'Foo' whatever you
>>choose to name your module.
Well, I must still not understand somehting here. I created a file in
the same direcotry as the script called config.pm
In it I have:
package config;
use Exporter ();
# variable set (Potentialy) from the config file
# These need to be declared here, even though they are set in a subroutine
my ( $my_pid_file, $my_tags_file, $my_ftp_lock_file, $my_max_ftp_wait );
my ( $my_csv_db_dir, $my_sleep_time_per_cycle, $my_lock_wait,
$my_lock_tries);
my ( $my_log_file, $my_partner_task_has_lock, $my_max_data_wait);
my ( $my_max_tags_in_que, $my_max_data_wait_per_tag, $my_loglevel);
my ( $my_badinit);
# Config file name goes here
# May be modifed with -f <filename> at runtime
my $cfg_file = "/opt/local/lib/pi_collect.conf";
@export = ( $my_pid_file, $my_tags_file, $my_ftp_lock_file, $my_max_ftp_wait, $m y_csv_db_dir, $my_sleep_time_per_cycle, $my_lock_wait, $my_lock_tries, $my_log_f ile, $my_partner_task_has_lock, $my_max_data_wait, $my_max_tags_in_que, $my_max_ data_wait_per_tag, $my_loglevel, $my_badinit, $cfg_file);
sub parse_config_file() {
Then in the main script I have:
use config;
# The standard high resolution timer, sleeps for the value in the last
# argument in seconds.
select undef, undef, undef, $conifg::my_sleep_time_per_cycle;
Yet when I run it I get:
Name "conifg::my_sleep_time_per_cycle" used only once: possible typo at
./t4.pl line 132.
Use of uninitialized value in join at ./t4.pl line 33.
Use of uninitialized value in concatenation (.) at ./t4.pl line 41.
Care to enlighten a poor C programer?
------------------------------
Date: 14 Dec 2000 21:00:52 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: #include files? sort of
Message-Id: <eli$0012141557@qz.little-neck.ny.us>
In comp.lang.perl.misc, <nobull@mail.com> wrote:
> stanb@panix.com (Stan Brown) writes:
> > I have a small perl script that will eventually be one of a pair of
> > co-operating tasks. I am planing on using on confiugration file for
> > both tasks. Since the code for pareseing this file is common, I wnat to
> > pull it out into a file to "#included" by both scripts.
...
> > How can I acomplish this in a simple manner?
> You are free to fall back on Perl4 techniques and simply require the
> file. Ignore all the stuff about modules, all you need to do is put
> "1;" on the last line of the file and act like you'd used #include in
> C.
And since this is perl, there are other ways...
do EXPR Uses the value of EXPR as a filename and executes
the contents of the file as a Perl script. Its
primary use is to include subroutines from a Perl
subroutine library.
do 'stat.pl';
is just like
scalar eval `cat stat.pl`;
except that it's more efficient and concise, keeps
track of the current filename for error messages,
searches the @INC libraries, and updates `%INC' if
[...]
Elijah
------
uses 'do' primarily for config files where security isn't a concern
------------------------------
Date: 14 Dec 2000 15:00:08 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: #include files? sort of
Message-Id: <m3n1dybtwn.fsf@dhcp11-177.support.tivoli.com>
stanb@panix.com (Stan Brown) writes:
> In comp.lang.perl.misc you write:
> Well, I must still not understand somehting here. I created a file in
> the same direcotry as the script called config.pm
>
> In it I have:
>
> package config;
> use Exporter ();
So you didn't export any symbols... Read the Exporter documentation
for how to do that.
> # variable set (Potentialy) from the config file
> # These need to be declared here, even though they are set in a subroutine
> my ( $my_pid_file, $my_tags_file, $my_ftp_lock_file, $my_max_ftp_wait );
> my ( $my_csv_db_dir, $my_sleep_time_per_cycle, $my_lock_wait,
> $my_lock_tries);
> my ( $my_log_file, $my_partner_task_has_lock, $my_max_data_wait);
> my ( $my_max_tags_in_que, $my_max_data_wait_per_tag, $my_loglevel);
> my ( $my_badinit);
>
> # Config file name goes here
> # May be modifed with -f <filename> at runtime
> my $cfg_file = "/opt/local/lib/pi_collect.conf";
>
> @export = ( $my_pid_file, $my_tags_file, $my_ftp_lock_file, $my_max_ftp_wait, $m y_csv_db_dir, $my_sleep_time_per_cycle, $my_lock_wait, $my_lock_tries, $my_log_f ile, $my_partner_task_has_lock, $my_max_data_wait, $my_max_tags_in_que, $my_max_ data_wait_per_tag, $my_loglevel, $my_badinit, $cfg_file);
Ah... you're trying to export these symbols, but you didn't do it
correctly. Two problems: it is @EXPORT not @export, and you cannot
simply "use Exporter", you have to inherit it. The Exporter
documentation shows how to do this.
> sub parse_config_file() {
>
> Then in the main script I have:
>
> use config;
>
> # The standard high resolution timer, sleeps for the value in the last
> # argument in seconds.
> select undef, undef, undef, $conifg::my_sleep_time_per_cycle;
>
> Yet when I run it I get:
>
> Name "conifg::my_sleep_time_per_cycle" used only once: possible typo at
> ./t4.pl line 132.
> Use of uninitialized value in join at ./t4.pl line 33.
> Use of uninitialized value in concatenation (.) at ./t4.pl line 41.
In addition to the above (and perhaps because of it), you are running
into an additional problem here (well, two actually). The first
problem is that you have a typo -- you're trying to access a variable
from the "conifg" package rather than the "config" package. But
fixing that isn't going to help because you don't actually have a
"$my_sleep_time_per_cycle" variable in the "config" package. You have
a lexically scoped variable that you are wanting to export from the
"config" package. Once you get the exporting working, the variable
will then be visible in your local package, but not in the "config"
package. So you will simply access it via "$my_sleep_time_per_cycle",
as you probably already tried, but since the exporting wasn't working,
that didn't work for you.
I'm not really sure where else to point you other than perlmod(1).
Maybe the package entry in perlfunc(1) will help a little.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Thu, 14 Dec 2000 22:06:34 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: #include files? sort of
Message-Id: <iigi3tc4q0foktlmko4irr20ulsde9ovpd@4ax.com>
Stan Brown wrote:
> I have a small perl script that will eventually be one of a pair of
> co-operating tasks. I am planing on using on confiugration file for
> both tasks. Since the code for pareseing this file is common, I wnat to
> pull it out into a file to "#included" by both scripts. Hees what I
> have at the top of the existing script.
...
># variable set (Potentialy) from the config file
># These need to be declared here, even though they are set in a subroutine
>my ( $my_pid_file, $my_tags_file, $my_ftp_lock_file, $my_max_ftp_wait );
>my ( $my_csv_db_dir, $my_sleep_time_per_cycle, $my_lock_wait, $my_lock_tries);
>my ( $my_log_file, $my_partner_task_has_lock, $my_max_data_wait);
>my ( $my_max_tags_in_que, $my_max_data_wait_per_tag, $my_loglevel);
>my ( $my_badinit);
...
>$my_pid_file = $state->get("pid_file");
>$my_tags_file = $state->get("tags_file");
>$my_log_file = $state->get("log_file");
>$my_ftp_lock_file = $state->get("ftp_task_lock_file");
>$my_max_ftp_wait = $state->get("max_ftp_delay");
...
> What I want to do, is put this section it it's own file, and have the
> global varibales, and the subroutine be accessiable to booht scripts.
> How can I acomplish this in a simple manner?
Hold your horses. First of all, you declare your variables with "my", so
they are NOT global variables. They are, in this incarnation, file
scoped variables. Therefore, the config library file cannot touch them
directly. Why don't you really make them global variables, by dropping
the "my"? If you just put "::" in font of the variable's names, then you
don't need to declare them, not even when using strict, and better
still, the config file can set them directly. Like this:
$::pid_file = '/opt/local/run/pi_collect.pid';
You may get the complaint from Perl that some variables are used only
once. It's nothing serious, it's just that these are used once in two
different script files, and Perl doesn't make the connection. Use them
more than once, or actually declare them (use vars, or our()).
And, why are't you using a hash?
$config{pid_file} = '/opt/local/run/pi_collect.pid';
Only one variable. Again, make it an actual global variable.
p.s. $::var is identical to $main::var, i.e. $var in package main.
--
Bart.
------------------------------
Date: Thu, 14 Dec 2000 19:25:27 GMT
From: alexander_prigozhin@my-deja.com
Subject: .NET in One Day Seminar - 2001 Schedule
Message-Id: <91b6qv$985$1@nnrp1.deja.com>
.NET IN ONE DAY: The Multi-Language Platform for the Age of the Internet
A one-day course by Bertrand Meyer
NEW LOCATIONS
=============
US:
---
Santa Barbara, CA: January 29
Pittsburgh, PA: February 5
Raleigh, NC: February 6
Detroit, MI: March 26
New York, NY: March 27
Boston, MA: March 29
Washington, DC: March 30
San Francisco, CA: April 6
CANADA:
-------
Montreal, Canada: April 2
Toronto, Canada: April 3
Vancouver, Canada: April 5
PACIFIC RIM:
------------
Singapore, Singapore: February 19
Kuala Lumpur, Malaysia: February 20
Bangkok, Thailand: February 22
EUROPE:
-------
Milan, Italy: March 2
Amsterdam, The Netherlands: March 5
Copenhagen, Denmark: March 6
Frankfurt, Germany: March 8
London, United Kingdom: March 9
**If your company is interested in an in-house presentation of
.NET in One Day please contact training@dotnetexperts.com**
INTRODUCTION
============
In July of 2000 Microsoft introduced the .NET framework, the most
important development since the introduction of Windows in 1991. The
result of a $2 billion investment, .NET is a revolutionary multi-
language platform integrating all aspects of application development
and closely integrating the Web at every step.
This information-packed one-day course covers the essentials of .NET,
including both the "big picture" and a review of all major aspects of
the technology. Presented by Dr. Bertrand Meyer, one of the pioneers of
modern software technology, it is based on more than one year's advance
exposure to .NET prior to the technology's official release. Dr.
Meyer's team at Interactive Software Engineering and Monash University
worked with Microsoft to integrate ISE's technology with .NET,
culminating in a joint appearance with Bill Gates at the Microsoft
Professional Development Conference that first introduced .NET.
COURSE OUTLINE
===============
1. Overview
-----------
* .NET in 15 minutes: an overview of the technology and its
contributions.
2. The challenges: if .NET is the answer, what are the questions?
-----------------------------------------------------------------
* Background: The Internet and the evolution of software development.
E-commerce and its demands. Requirements of mission-critical
applications. Exposing the business model.
* Object Technology: contribution and challenges. O-O languages, GUI
tools, databases.
* Component-based development: COM, CORBA, Enterprise Java Beans. The
notion of Interface Description Language. Contributions and
limitations of pre-.NET component approaches.
* Programming for the Web and e-commerce: CGI scripts, Active Server
Pages, Java Server pages. Advantages and drawbacks.
* The state of multi-language interoperability. Approaches to portable
application development. Graphics, database issues.
3 .NET: The Vision and the Platform
-----------------------------------
* The .NET architecture: runtime, framework, platform, web services.
* The .NET runtime: architecture and goals. Comparison with the Java
Virtual Machine.
* MSIL: the intermediate language. Security issues and the concept of
verifiability. How critical is it to produce verifiable code?
* Organizing and extending your components: assemblies and metadata. An
application: equipping components with contracts.
4. The .NET object model and type system
----------------------------------------
* Classes, methods, fields, properties and events
* .NET types: reference and value types, array types, arrays
* Inheritance concepts: multiple interface inheritance, novariance
* Encapsulating behavior: delegates
* C#: a language for programming .NET
* C# versus Java
* .NET mechanisms and the dominant languages: commonalities
and mismatches. How easy is it to map an existing language
into the .NET model?
5. Language interoperability
----------------------------
* Available languages and degree of interoperability. Cross-language
inheritance; cross-language debugging
* The Common Language System: both a consumer and an extender be
Levels of compliance
* Advantages and challenges of CLS compliance
* Examples: combining components from various languages
* From a common runtime to a common development environment:
Visual Studio.NET and the concept of multi-language, pluggable
environment. GUI, browsing, debugging
6. Frameworks and applications
------------------------------
* Web and Win Forms
* Remoting and threading capabilities
* ASP+: Active Server Pages +. Building advanced Web sites for e-
commerce
* Web services, SOAP and Building Block Services
* Database access and manipulation: ADO+
7. Summary and perspective
--------------------------
* .NET and the competition
* The significance of .NET
* Future developments
* Corporate strategies: getting ready for .NET
COURSE MATERIAL
================
The material distributed to participants includes more than 150 slides,
as well as supporting articles.
WHO SHOULD ATTEND
=================
This course presents a compact, in-depth survey of the .NET
technology over one day. It is intended for both managers
(VPs of technology, CTOs, project leaders, Web content
managers, e-commerce strategy leaders) and for software
developers who want to know about the most important technology
offering in many years. The .NET technology will affect everyone;
no one can afford to miss it.
ABOUT THE SPEAKER
==================
Dr. Bertrand Meyer has played a major role in developing modern software
technology and bringing it to software engineers working in production
environments. Bertrand is best known for his best-seller "Object-
Oriented Software Construction" (2nd edition, Prentice Hall, 1997),
recipient of the Jolt Award and one of the seminal works on modern
software technology. He is the author of 8 other books on software
technology, programming languages and object-oriented development,
including "Reusable Software", "Eiffel: The Language" and "Object
Success", and of numerous widely cited articles. He is a columnist for
Software Development magazine, the Journal of Object-Oriented
Programming and was Department Editor for IEEE Computer. He is the
series chair for the international TOOLS conferences (USA, Europe,
Pacific), devoted to component and object technology.
He is also the editor of the Prentice Hall Object and Component
Technology Series.
As head of ISE's development team, he has led the design of tools and
environments used routinely by major corporations worldwide for their
mission-critical applications.
FEE
===
USA: USD 695.00 or USD 645.00*
Singapore: 995 SGD or 895 SGD*
Malaysia: 1995 MYR or 1795 MYR*
Italy: 1,624,445 ITL or 1,507,695 ITL*
The Netherlands: 1795 NLG or 1695 NLG*
Denmark: 6,195 DKK or 5,775 DKK*
Germany: 1595 DEM or 1495 DEM*
United Kingdom: 495 GBP or 455 GBP*
Canada: 895 CAD or 795 CAD*
* if paid three weeks prior to the session.
A 10% discount will be applied to registrations
for 3 or more people from the same company registering at the same time.
A 20% discount will be applied to registrations
for 5 or more people from the same company registering at the same time.
REGISTRATION FORM
==================
The registration is available on-line at http:www.dotnetexperts.com,
by phone at 805-685-1006, or using the form below by fax at 805-685-
6869
or by email at training@dotnet.experts.com:
I am registering for:
___Santa Barbara, CA: January 29
___Pittsburgh, PA: February 5
___Raleigh, NC: February 6
___Singapore, Singapore: February 19
___Kuala Lumpur, Malaysia: February 20
___Bangkok, Thailand: February 22
___Milan, Italy: March 2
___Amsterdam, The Netherlands: March 5
___Copenhagen, Denmark: March 6
___Frankfurt, Germany: March 8
___London, United Kingdom: March 9
___Detroit, MI: March 26
___New York, NY: March 27
___Boston, MA - March 29
___Washington, DC: March 30
___Montreal, Canada: April 2
___Toronto, Canada: April 3
___Vancouver, Canada: April 5
___San Francisco, CA: April 6
***ALL PAYMENTS (Credit Card, International Money Order and
Bank Transfer) MUST BE MADE IN US DOLLARS.***
Address:
Company__________________________________________________
Department or Division __________________________________
Street Address___________________________________________
City _____________________Zip Code ______________________
State _____ _____________________________________________
Country ____________________________
Telephone ______________________ Fax ____________________
Email ___________________________________________________
Names of Participants:
______________________________________________
______________________________________________
______________________________________________
______________________________________________
______________________________________________
Method of Payment (check one):
_____Check enclosed (amount) ___________________________
(make check payable to Interactive Software Engineering, Inc.)
_____Credit Card
Number____________________________Exp. Date__________
Authorized Signature____________________________________
Substitutions will be accepted at any time. Any cancellation
received three weeks before the seminar will be liable to a
50% service fee. Cancellations received after this date will
be liable for the entire fee.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 14 Dec 2000 21:11:21 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: .NET in One Day Seminar - 2001 Schedule
Message-Id: <x7g0jqiu87.fsf@home.sysarch.com>
keep this spam crap out of this newsgroup. it doesn't mention perl once
nor refer to any perl issues, just this massive redmondware hunk of shit
that will only run on their platforms.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 14 Dec 2000 14:37:38 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: 3 questions
Message-Id: <m3y9xibuy5.fsf@dhcp11-177.support.tivoli.com>
"Konstantin Stupnik" <skv@iis.nsk.su> writes:
> "Chris Fedde" <cfedde@fedde.littleton.co.us> wrote in message
> news:soZZ5.231$B9.188798464@news.frii.net...
> > open(G, "myprog |") or die "$0: can't start myprog: $!";
> Opening a pipe will never return a error.
Never say "never"... :)
Opening a pipe will return an error if the pipe fails to open, which
can happen for a couple of reasons, "fork failed" being the one that
most readily springs to mind.
So you should check the open.
> You can find out that an error happened only
> by checking close;
>
> > while (<G>) {
> > print F;
> > }
> close F;
> close G or die "$0: failed to start myprog: $!";
But, as you say, you most certainly need to check the close of any
piped opens. That's where any failures of the exec will happen.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Fri, 15 Dec 2000 10:31:37 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: 3 questions
Message-Id: <91be7q$af5$1@hermes.nz.eds.com>
>Bill Chapman <bchapman@best.com> wrote in message
news:3A385DF4.43499BF2@best.com...
>I'm trying to convert some .csh files to perl. I have 3 questions. Please
reply:
>- in the csh script, I used redirection of I/O, for example
> % myprog >myfile.txt
> is there a way to do this in perl?
% perlscript >myfile.txt
>
>- related to the last: I took input from the script
> % myprog <<EOF
> this is a line of text
> this is another line of text
> EOF
> is there a way to do this in a perl script?
% perlscript <<EOF
this is a line of text
this is another line of text
EOF
------------------------------
Date: Thu, 14 Dec 2000 20:53:21 GMT
From: Drew Myers <bh_ent@my-deja.com>
Subject: [q] split in while loop
Message-Id: <91bbvv$dkp$1@nnrp1.deja.com>
I am a newbie (and have been for much too long) to perl. I am
attempting to extract information from a log file and format it for a
report.
#!/usr/bin/perl -w
use strict;
my ($file,@data);
my $newestfile=0;
opendir(VMDIR,"/var/adm/vm") || die "Can't open /var/adm/vm: $!\n";
my @vmfilelist = grep !/^\./, sort(readdir(VMDIR));
closedir(VMDIR) || die "Can't close /var/adm/vm: $!\n";
foreach $file(@vmfilelist) {
open(VMFILE, "/var/adm/vm/$file") || die "Can't open $file: $!\n";
while(<VMFILE>) {
next if (/avm/);
my $free = split(" ",$_)[1];
print;
}
}
The log file looks something like this:
memory page faults
avm free si so pi po fr de sr in sy cs
62401 418249 0 0 0 0 0 0 0 74 99 268
CPU
cpu procs
us sy id r b w
24 6 71 1 2 0
I am attempting to grab the number 418249 in this example. The log
file contains multiple occurrences of this type of data, and I want the
number(s) in this same position each time.
The split statement doesn't function (the error states "Can't use
subscript on split"), but I don't understand why.
I know to RTFM but between my Perl books, perldoc (and associated faqs,
etc) I am having trouble determining the solution. Is it a scope
issue? Is it the placement of the split statement itself?
Thanks in advance,
Drew Myers
perotsystems
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 14 Dec 2000 21:44:03 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: [q] split in while loop
Message-Id: <3A393FA1.D9FED6BF@acm.org>
Drew Myers wrote:
>
> I am a newbie (and have been for much too long) to perl. I am
> attempting to extract information from a log file and format it for a
> report.
>
> #!/usr/bin/perl -w
>
> use strict;
>
> my ($file,@data);
> my $newestfile=0;
> opendir(VMDIR,"/var/adm/vm") || die "Can't open /var/adm/vm: $!\n";
> my @vmfilelist = grep !/^\./, sort(readdir(VMDIR));
> closedir(VMDIR) || die "Can't close /var/adm/vm: $!\n";
> foreach $file(@vmfilelist) {
> open(VMFILE, "/var/adm/vm/$file") || die "Can't open $file: $!\n";
> while(<VMFILE>) {
> next if (/avm/);
> my $free = split(" ",$_)[1];
Change this to
my $free = (split(" ",$_))[1];
> print;
> }
> }
John
------------------------------
Date: Thu, 14 Dec 2000 21:39:07 GMT
From: Dick Latshaw <latsharj@my-deja.com>
Subject: Re: [q] split in while loop
Message-Id: <91belr$fp6$1@nnrp1.deja.com>
In article <91bbvv$dkp$1@nnrp1.deja.com>,
Drew Myers <bh_ent@my-deja.com> wrote:
> my $free = split(" ",$_)[1];
> The log file looks something like this:
> 62401 418249 0 0 0 0 0 0 0 74 99
> I am attempting to grab the number 418249 in this example.
> The split statement doesn't function (the error states "Can't use
> subscript on split"), but I don't understand why.
It's the placement of the parentheses:
my $free = (split(" ",$_))[1];
or, since split splits $_ on space chars by default:
my $free = (split)[1];
--
Regards,
Dick
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 14 Dec 2000 16:51:47 -0500
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: [q] split in while loop
Message-Id: <3A3940F2.9CD2EEA9@cc.gatech.edu>
Drew Myers wrote:
> I am a newbie (and have been for much too long) to perl. I am
> attempting to extract information from a log file and format it for a
> report.
>
> #!/usr/bin/perl -w
>
> use strict;
>
> <snip earlier code>
> my $free = split(" ",$_)[1];
> print;
the [1] is applied to (" ",$_), sintead of the output of the split
statement. Instead, you should use:
my $free = (split / /)[1];
(use slashes instead of quotes, as quotes can be misleading in split
statements)
BTW, the next statement prints $_, not $free .
>
>
> I know to RTFM but between my Perl books, perldoc (and associated faqs,
> etc) I am having trouble determining the solution. Is it a scope
> issue? Is it the placement of the split statement itself?
>
In this case, you are dealing with precedence issues.
perldoc perlop # Terms and list operators
HTH. HAND.
--
Stephen Kloder | "I say what it occurs to me to say.
stephenk@cc.gatech.edu | More I cannot say."
Phone 404-874-6584 | -- The Man in the Shack
ICQ #65153895 | be :- think.
------------------------------
Date: Thu, 14 Dec 2000 17:33:33 +0100
From: Miloslav Nic <nicmila@idoox.com>
Subject: [Zvon Announcement] DOM Factory - version 0.9
Message-Id: <3A38F65D.7C5CAFAC@idoox.com>
Jiri Znamenacek today published at Zvon:
http://zvon.org/xxl/JSDOMFactory/
As many of us are fighting with browsers (and DOM) quite
often, I hope you will find it useful. Jiri did an excellent job.
It can be downloaded under "GNU Free Documentation License" as all Zvon
materials:
http://zvon.org/index.php?nav_id=3
Features
Provide an easy and handy lookup for properties of objects in JavaScript
for loaded document and the same functionality for DOM objects.
Names of properties are clickable and colour-differentiated so
navigation is intuitive and easy.
Properties can be highlighted (also links to appropriate references are
provided).
Found objects can be easy added (by click) for another lookup.
Dislayed output can be filtered in various ways.
Simple DOM 'debugger' for testing DOM in loaded document.
Simple JavaScript 'debugger' for evaluating JavaScript expressions 'on
the fly'.
--
******************************************
<firstName> Miloslav </firstName>
<surname> Nic </surname>
<mail> nicmila@idoox.com </mail>
<support> http://www.zvon.org </support>
<zvonMailingList>
http://www.zvon.org/index.php?nav_id=4
</zvonMailingList>
------------------------------
Date: Thu, 14 Dec 2000 21:36:13 GMT
From: Weston Cann <iowa8_song8.remove_eights@hotmail.com>
Subject: Re: Ada feature borrowed for Perl??
Message-Id: <121220001431559391%iowa8_song8.remove_eights@hotmail.com>
In article <91b4dp$734$1@nnrp1.deja.com>, Jeff Robertson
<jeff_robertson@yahoo.com> wrote:
> In article <91b37a$61h$1@nnrp1.deja.com>,
> Richard Lawrence <ralawrence@my-deja.com> wrote:
> >
> > Having done Ada for 2 years and Perl for about a year I'm ashamed to
> > admit I have no idea what that feature is. Granted I haven't touched
> > Ada in 5 years and granted i'm not that great at Perl or Ada but can
> > anyone tell me what on earth it was that was borrowed??
>
> Packages ?
I don't know Ada at all, but that's what I guessed too. I was thinking
maybe there was some wordplay in Mark-Jason's sentence "a feature you
*use* every day".
Does Ada use 'use' to use packages?
Weston
------------------------------
Date: Thu, 14 Dec 2000 21:52:35 GMT
From: Weston Cann <iowa8_song8.remove_eights@hotmail.com>
Subject: Algorithm::Diff -- unexpected behavior?
Message-Id: <121220001448148220%iowa8_song8.remove_eights@hotmail.com>
I'm using Algorithm::Diff (the diff function therefrom) to find
differences between two texts, and I'm getting some results that
don't seem right.
Take:
@text1 = ( 'The','patient','was','21','years','old' );
@text2 = ( 'The','patient','was','a','21','year','old','male');
so when I do:
@diffs = diff(\@text1,\@text2);
I get @diffs = ( [[+, 3, a ]],
[[-, 4, years]],
[[+, 5, year ]],
[[+, 7, male ]] );
Which is, as I understand it, the list of operations necessary to turn
@text1 into @text2.
The problem is, it doesn't seem to. Check it out:
0 1 2 3 4 5
The patient was 21 years old.
(add 'a' at 3)
0 1 2 3 4 5 6
The patient was a 21 years old.
(remove 'years' at 4 ... except 4 isn't years, but we'll do it)
0 1 2 3 4 5
The patient was a years old.
(add 'year' at 5)
0 1 2 3 4 5 6
The patient was a years year old.
(add 'male' at 7)
0 1 2 3 4 5 6 7
The patient was a years year old male.
Not quite the desired result.
I don't think there's actually a bug in Algorithm::Diff, but I do think
I'm missing some understanding of how things are supposed to work.
Help?
------------------------------
Date: Thu, 14 Dec 2000 22:37:00 GMT
From: Weston Cann <iowa8_song8.remove_eights@hotmail.com>
Subject: Re: Algorithm::Diff -- unexpected behavior?
Message-Id: <121220001532438764%iowa8_song8.remove_eights@hotmail.com>
In article <121220001448148220%iowa8_song8.remove_eights@hotmail.com>,
Weston Cann <iowa8_song8.remove_eights@hotmail.com> wrote:
> I'm using Algorithm::Diff (the diff function therefrom) to find
> differences between two texts, and I'm getting some results that
> don't seem right.
>
Here's another exmaple: one from the Algorithm::Diff documentation on
cpan.org, which seems to have the same sort of problem.
If we have the two sequences:
a b c e h j l m n p
b c d e f j k l m r s t
Then diff should give us: (with Seq #1 changes, step by step)
[
[ [ '-', 0, 'a' ] ], b c e h j l m n p
[ [ '+', 2, 'd' ] ], b c e d h j l m n p
[ [ '-', 4, 'h' ] , b c e d j l m n p
[ '+', 4, 'f' ] ], b c e d f j l m n p
[ [ '+', 6, 'k' ] ], b c e d f j k l m n p
0 1 2 3 4 5 6 7 8 9
note the next # hunk says remove
item 'n' at 8 -- but 8 isn't n --
still, we'll try it.
[ [ '-', 8, 'n' ], b c e d f j k l n p
[ '-', 9, 'p' ], b c e d f j k l n
[ '+', 9, 'r' ], b c e d f j k l n r
[ '+', 10, 's' ], b c e d f j k l n r s
[ '+', 11, 't' ], b c e d f j k l n r s t
]
]
The sequence b c e d f j k l n r s t is close to seq #2, but it's not
the same.
What's going on?
------------------------------
Date: 14 Dec 2000 14:55:06 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Algorithm::Diff -- unexpected behavior?
Message-Id: <3a394fca@news.victoria.tc.ca>
Weston Cann (iowa8_song8.remove_eights@hotmail.com) wrote:
: I'm using Algorithm::Diff (the diff function therefrom) to find
: differences between two texts, and I'm getting some results that
: don't seem right.
: Take:
: @text1 = ( 'The','patient','was','21','years','old' );
: @text2 = ( 'The','patient','was','a','21','year','old','male');
: so when I do:
: @diffs = diff(\@text1,\@text2);
: I get @diffs = ( [[+, 3, a ]],
: [[-, 4, years]],
: [[+, 5, year ]],
: [[+, 7, male ]] );
...perhaps...
#!/not/quite/perl
@newtext=();
for ($i = 0 ; $i<@text1; $i++)
{
if (no operation for this line)
{ push @newtext , $text1[$i];
}else
{ if (operation is '+')
{ push @newtext , the diff string;
push @newtext , $text1[$i];
}
elsif (operation is '-')
{ # do not copy $text1[$i] into @newtext;
}
}
}
which gives
$i @newtext
0 The
1 The patient
2 The patient was
3 The patient was a 21 (+ a then 21)
4 The patient was a 21 (- years)
5 The patient was a 21 year old (+ year then old)
6 The patient was a 21 year old
7 The patient was a 21 year old male (+ male)
My algorithm didn't go to step 7, but since I'm a human I'm allowed to
ignore that minor discrepancy, the general steps still resulted in the
correct answer.
------------------------------
Date: Thu, 14 Dec 2000 20:11:28 GMT
From: alazarev1981@my-deja.com
Subject: Associate more than one FH with a $cgi?
Message-Id: <91b9ha$beh$1@nnrp1.deja.com>
I'm a cgi/perl beginner and I have a pretty simple question:
In my program I do the following:
Associate a single file handler with a $cgi:
use CGI;
open(FH,$fileName);
$cgi = new CGI(FH);
close(FH);
With the code above I can get at the data within that CGI file
($fileName) and store it under a new variable names in my perl program.
Easy as pie.
However, what I really want to do is get data from more than one CGI
file from within the same perl program. So I'm thinking about coding
the following:
use CGI;
open(FH1,$fileName1);
open(FH2,$fileName2);
$cgi = new CGI(FH1, FH2);
close(FH1);
close(FH2);
OR can I associate two filenames with one handler like so:
use CGI;
open(FH, $fileName1 & fileName2);
$cgi = new CGI(FH);
close(FH);
Do either of the above work? If not, how do I get data from two
different CGI files within the same perl program?
Thanks in advance,
Alex Lazarevich
alazarev@itg.uiuc.edu
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 14 Dec 2000 14:36:12 -0600
From: Jeff H <jeffahill@_ANTISPAM_.lucent.com>
Subject: Calling a remote script.
Message-Id: <3A392F3C.21A875EE@_ANTISPAM_.lucent.com>
We have a webserver, separate from the unix box where some data I'd like to
include on a webpage is. The data is in an Informix database (I have little
information about that, but I did not see a module for it under the listing of
Perl mods). There is a local ksh script that pulls some data from it, and then
I use Perl to chop it into little bits, and spit it back out onto a webpage.
That part works fine. When I go to the webserver, there is no .netrc file
associated with the webserver login, and our IT people will not allow one. So,
when I do this:
$somevar = `rsh -l someuser someserver thisscript args`
it won't work. Is there a way to remotely log into a server, using a login and
password, from Perl.
Alternatively, is there a way to run all this stuff through a DBI and circumvent
all of this?
Jeff
------------------------------
Date: Thu, 14 Dec 2000 22:05:13 GMT
From: Adam Levenstein <cleon42@my-deja.com>
Subject: CGI: Dealing with checkboxes and multiple <SELECTS>
Message-Id: <91bg6l$h56$1@nnrp1.deja.com>
Hey all,
As I'm working on this project, I notice that my CGI script (Perl 5,
UNIX) is only returning the last value selected with multiple
checkboxes and <SELECT MULTIPLE> fields. Any way to get around this?
Thanks,
Adam
--
-------------------------------------------------
Adam Levenstein
cleon42@my-deja.com
"Extraordinary claims require extraordinary evidence."
-- Carl Sagan
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 5114
**************************************