[24552] in Perl-Users-Digest
Perl-Users Digest, Issue: 6730 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 25 18:05:40 2004
Date: Fri, 25 Jun 2004 15:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 25 Jun 2004 Volume: 10 Number: 6730
Today's topics:
[ANN] Inline::Lua 0.01 <tassilo.parseval@rwth-aachen.de>
Re: Cron-like module <abigail@abigail.nl>
Defining a regex in a config file <asdf@asdf.com>
Re: Defining a regex in a config file <nobull@mail.com>
Re: error logs... <nobull@mail.com>
Re: error logs... <me@privacy.net>
Help getting into HTML file. <jimsimpson@cox.net>
Re: Help getting into HTML file. <plalli@gmail.com>
Re: Help getting into HTML file. <noreply@gunnar.cc>
Re: Help getting into HTML file. <postmaster@castleamber.com>
Killfile - what they had in mind <norfernuman@yahoo.com>
PAR with active state: Compress::Zlib object version 1. <Graham.T.removethis.Wood@oracle.andthis.com>
Re: Perl editors and debuggers <diggings@argonet.co.uk>
Re: PPT UNIX Reconstruction Project at: http://www.perl <clydenospamorham@nospamorhamgetofftheline.freeservenospamorham.co.uk>
Re: Regexp, Strings and spaces (J. Romano)
Re: Splitting a file <jgibson@mail.arc.nasa.gov>
Re: Strange Behaviour with Hash??? <vticau@excite.com>
Re: Strange Behaviour with Hash??? ctcgag@hotmail.com
Re: Textual inclusion of files into a script. <nobull@mail.com>
Re: Textual inclusion of files into a script. (Bill)
Re: Trim Multiple Dirs to Max Total Space Used - by Dat (Randal L. Schwartz)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 25 Jun 2004 04:58:35 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: [ANN] Inline::Lua 0.01
Message-Id: <HzvHzw.3GM@zorch.sf-bay.org>
I am very pleased to announce a new submission to the CPAN, Inline::Lua.
>From the perldocs:
NAME
Inline::Lua - Perl extension for embedding Lua scripts into Perl code
SYNOPSIS
use Inline 'Lua';
print "The answer to life, the universe and everything is ", answer(6, 7), "\n";
__END__
__Lua__
function answer (a, b)
return a*b
end
# Have Lua access functionality from Perl modules
use Inline 'Lua';
use LWP::Simple;
luaget(\&get, "http://www.google.com/");
__END__
__Lua__
function luaget(get, page)
io.write( get(page) )
end
DESCRIPTION
Inline::Lua allows you to write functions in Lua. Those of you who are
not yet familiar with Lua should have a cursory glance at
<http://www.lua.org/> to get a taste of this language. In short:
Lua was designed to be embedded into other applications and not so much
as a language on its own. However, despite its small set of language
features, it is an extremely powerful and expressive language. Its
strong areas are an elegant and yet concise syntax, good overall per-
formance and a beautiful implementation of some concepts from the world
of functional programming.
[...]
COPYRIGHT AND LICENSE
Copyright (C) 2004 by Tassilo von Parseval
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.8.4 or, at
your option, any later version of Perl 5 you may have available.
Lua 5.0 Copyright (C) 2003-2004 Tecgraf, PUC-Rio.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 25 Jun 2004 19:02:27 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Cron-like module
Message-Id: <slrncdotm3.1ai.abigail@alexandra.abigail.nl>
Sebastian Tymków (Shamrock@psych.uw.edu.pl) wrote on MMMCMLI September
MCMXCIII in <URL:news:slrncdoagb.2u9.Shamrock@engram.psych.uw.edu.pl>:
@@ W artykule <20040625082717.L23512@dishwasher.cs.rpi.edu> Paul Lalli napisa³(a):
@@ > On Fri, 25 Jun 2004, Sebastian [iso-8859-2] Tymk?w wrote:
@@ >
@@ >> I'm looking for some perl module which will
@@ >> work like cron. I want to daemonize my script and
@@ >> run some command periodicly( one at A time and the
@@ >> other at B time)
@@ >
@@ > When you say you're 'looking', are you actually looking, or are you just
@@ > asking the world to look for you?
@@ >
@@ > Where have you looked so far, I'm curious?
@@ >
@@ > The place to look for perl modules is CPAN - visit http://search.cpan.org
@@ >
@@ > A search for 'cron' returns a heck of a lot of responses. Have you seen
@@ > them yet?
@@
@@ Ok, my mistake. I'm curious what do you recommend. I know that I should use
@@ http://search.cpan.org but I'm curious if anybody use something similiar.
Well, if I want something to work like cron, I'd use cron.
Abigail
--
perl -Mstrict='}); print "Just another Perl Hacker"; ({' -le1
------------------------------
Date: Fri, 25 Jun 2004 10:07:50 -0700
From: Tyan <asdf@asdf.com>
Subject: Defining a regex in a config file
Message-Id: <mfmod0toup3kffpcjc5fkh928skuegrs6a@4ax.com>
Hi,
I need to write an app to automate a telnet login but I'm having some
trouble with how to handle the prompt. The app will log into many
platforms (AIX, HP-UX, Solaris, etc.. ) that have varying prompts so I
want to be able to define a regex in a config file for the Net::Telnet
module to match against. For example:
$prompt = "^ $host.*\$ $";
...
$output = $telnet->waitfor('/$prompt/');
Obviously this doesn't work, but how would I implement something like
this?
Thanks for the help...
................................................................
Posted via TITANnews - Uncensored Newsgroups Access
>>>> at http://www.TitanNews.com <<<<
-=Every Newsgroup - Anonymous, UNCENSORED, BROADBAND Downloads=-
------------------------------
Date: 25 Jun 2004 18:54:38 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Defining a regex in a config file
Message-Id: <u98yeby141.fsf@wcl-l.bham.ac.uk>
Tyan <asdf@asdf.com> writes:
^^^^^^^^^^^^^^^
Please don't do that. See http://www.asdf.com/asdfemail.html
If you want an invalid domain name then choose one that ends .invalid,
don't just hijack someone else's at random.
> I need to write an app to automate a telnet login but I'm having some
> trouble with how to handle the prompt. The app will log into many
> platforms (AIX, HP-UX, Solaris, etc.. ) that have varying prompts so I
> want to be able to define a regex in a config file for the Net::Telnet
> module to match against. For example:
>
> $prompt = "^ $host.*\$ $";
> ...
> $output = $telnet->waitfor('/$prompt/');
>
> Obviously this doesn't work, but how would I implement something like
> this?
In Perl double quotes do interpolation and single quotes don't. You
are passing waitfor() the literal string slash-dolar-pee-...
The // that one conventionally sees arround a regex are themselves
quoting characters and not part of the regex.
So if you have a regex in a variable and you want pass it as an
argument to a subroutine that expects a regex as an argument then just
do so. Do not fold, spindle or mutilate.
function_that_expects_a_regex($prompt);
However, I've just been off to look at Net::Telnet and it appears that
what waitfor() is expecting as an argument is not a regex but a
fragment of source Perl code that can be placed on the RHS of a =~
operator. Yuch! (And I say again ... Yuch!!!).
To convert a scalar containing an arbitrary regex into a valid
argument waitfor() is actually quite involved.
Most of the time it would suffice to say...
$output = $telnet->waitfor("/$prompt/");
...but this will fail if the regex actually contains any forward
slashes.
Now to look at how to get a regex into a variable in the first place.
Now when you say...
/^ $host.*\$ $/
...that single backslash protects the $ from being interpreted either
as an interpolation or as a regex metacharacter.
However if you say...
$prompt = "^ $host.*\$ $";
$string =~ $prompt;
...then the backslash is consumed by the interpretation of the double
quotes so it will be seen as a regex metacharacter.
You can say...
$prompt = "^ $host.*\\\$ $";
$string =~ $prompt;
...or...
$prompt = '^ ' . $host . '.*\$ $';
$string =~ $prompt;
But you'd do much better to use the qr// construct.
$prompt = qr/^ $host.*\$ $/;
$string =~ $prompt;
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 25 Jun 2004 19:22:37 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: error logs...
Message-Id: <u9zn6rwl8y.fsf@wcl-l.bham.ac.uk>
Eric Bohlman <ebohlman@omsdev.com> writes:
> "John ©" <johnjcarbone@nospam.hotmail.com> wrote in
> news:rxKCc.4476$L8.3152@nwrdny02.gnilink.net:
>
> > group ... I was supposed to realize that that newsgroup was defunct.
> > That there were FAQ's, that there were guidelines. That because I was
> > a newbie I was lazy. He even got on my case for typing PERL instead of
> > Perl, among other things... and that was the first time I had ever
> > posted.
>
> Usenet newsgroups (and for that matter, Usenet itself) have characteristics
> that meet many of the anthropological criteria for cultures. When visiting
> a foreign culture, it is normally considered necessary to make at least
> some effort to familiarize oneself with it. For example, an American who
> visits England and is surprised, or worse, indignant to find out that
> people drive on the left side of the road hasn't put in that effort. There
> is a stereotype that says that most Americans behave that way (we mostly
> don't but the squeaky wheel gets the grease) and in fact it has a name: the
> "ugly American." You're showing some signs of it.
Yes, I must confess, that I tend to assume that people who come here
and behave this way are Americans. However I was in at least one
recent case shown to be wrong. 'Player' revealed himself to be a Brit
(like me).
http://groups.google.com/groups?threadm=4dafc536.0406090413.2106b642%40posting.google.com
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 26 Jun 2004 08:45:04 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: error logs...
Message-Id: <2k3h61F15f920U1@uni-berlin.de>
"John ©" <johnjcarbone@nospam.hotmail.com> wrote in message
news:iuGCc.4965$A9.3556@nwrdny01.gnilink.net...
>
> #!/usr/local/bin/perl5
>
>
> $GetTime = 5;
> $NextOne = 6;
>
> print "This is a test of $GetTime\n"
> print "The next number is $NextOne\n"
>
> --------------------------------------------------------------------------
>
> Pretty basic, eh? If the <$NextOne = 6;> and <print "The next> etc.. is
not
> in there, then it shows:
>
> This is a test of 5
>
> But when the script it like it is above, it gives a HTTP 500 Internal
server
> error.
If you fixed the syntax errors *and* outputted the appropriate headers,
you'll be fine, ie:
#!/usr/local/bin/perl5
use strict;
use CGI;
my $GetTime = 5;
my $NextOne = 6;
my $q = new CGI;
print $q->header('text/plain');
print "This is a test of $GetTime\n";
print "The next number is $NextOne\n";
------------------------------
Date: Fri, 25 Jun 2004 14:19:13 -0400
From: "Jim Simpson" <jimsimpson@cox.net>
Subject: Help getting into HTML file.
Message-Id: <J0_Cc.1752$_I3.756@lakeread03>
I have the following line of code:
<my $response = $ua->post(whatever)>
The $response which is returned contains HTML code and is now printing on
the DOS screen. How can I get it into an .html file so I can see it on my
computer screen?
Thanks,
Jim
------------------------------
Date: Fri, 25 Jun 2004 14:32:48 -0400
From: Paul Lalli <plalli@gmail.com>
Subject: Re: Help getting into HTML file.
Message-Id: <20040625143010.C23512@dishwasher.cs.rpi.edu>
On Fri, 25 Jun 2004, Jim Simpson wrote:
> I have the following line of code:
>
> <my $response = $ua->post(whatever)>
>
> The $response which is returned contains HTML code and is now printing on
> the DOS screen. How can I get it into an .html file so I can see it on my
> computer screen?
What are you asking? Do you want to print the response to your browser?
Do you want to save the result to a new HTML file on your local computer?
I'm going to assume the latter for now. Somewhere along the way, you must
be printing the response. Rather than printing it to standard output (the
default), open a new file for writing, and print to that file instead.
For documentation on how to do this, see:
perldoc -f open
and
perldoc -f print
After reading that documentation and making an attempt, if you still have
problems, let us know.
Paul Lalli
------------------------------
Date: Fri, 25 Jun 2004 20:32:28 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Help getting into HTML file.
Message-Id: <2k39inF17h4daU1@uni-berlin.de>
Jim Simpson wrote:
> I have the following line of code:
>
> <my $response = $ua->post(whatever)>
>
> The $response which is returned contains HTML code and is now
> printing on the DOS screen. How can I get it into an .html file so
> I can see it on my computer screen?
open my $fh, '> myfile.html' or die $!;
print $fh $response -> content;
close $fh;
(untested)
Then view it with your browser. :)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 25 Jun 2004 13:47:16 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Help getting into HTML file.
Message-Id: <40dc733a$0$211$58c7af7e@news.kabelfoon.nl>
Jim Simpson wrote:
> I have the following line of code:
>
> <my $response = $ua->post(whatever)>
>
> The $response which is returned contains HTML code and is now printing on
> the DOS screen. How can I get it into an .html file so I can see it on my
> computer screen?
"$ua->get( $url , $field_name => $value, ... )
This method will dispatch a GET request on the given $url. Further
arguments can be given to initialize the headers of the request. These
are given as separate name/value pairs. The return value is a response
object. See the HTTP::Response manpage for a description of the
interface it provides.
Fields names that start with ``:'' are special. These will not
initialize headers of the request but will determine how the response
content is treated. The following special field names are recognized:
:content_file => $filename
:content_cb => \&callback
:read_size_hint => $bytes
If a $filename is provided with the :content_file option, then the
response content will be saved here instead of in the response object. "
"... post... Additional headers and content options are the same as for
the get() method. "
RTFM
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Fri, 25 Jun 2004 16:06:11 GMT
From: norfernuman <norfernuman@yahoo.com>
Subject: Killfile - what they had in mind
Message-Id: <T3YCc.1171$7i1.503@newssvr27.news.prodigy.com>
Ahh... to open c.l.p.m with no Puke gurl stupidity showing up.
A quick glance at the filter log shows it's time to scrub that bowl!
Yea baby, scrubbing bubbles!
This is what the framers (mozilla developers) had in mind when the
penned the declaration of independence from intrusive, manipulative
yuck. You gotta' love those folks.
Hmmm... Perl stuff to check out.
- Good day!
- NN
------------------------------
Date: Fri, 25 Jun 2004 17:48:39 +0100
From: Graham Wood <Graham.T.removethis.Wood@oracle.andthis.com>
Subject: PAR with active state: Compress::Zlib object version 1.22 does not match bootstrap parameter 1.16
Message-Id: <tRYCc.29$bK3.76@news.oracle.com>
Can anyone advise me how to get pp to work with activestate perl
Binary build 638 provided by ActiveState Corp. http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Apr 13 2004 19:24:21
I've just installed this build of Perl on win2k and then the PAR module
as supplied by ActiveState and running pp gives me this error.
Do I have to get a C compiler and the source for version 1.16 of the
Compress::Zlib module or is there a less labour intensive way of getting
executables built with lots of modules included without having to buy a
license for something?
I'm assuming I can't hack anything without rebuilding the xs parts of
the compress::Zlib module.
Suggestions welcome
Thanks
Graham
------------------------------
Date: Fri, 25 Jun 2004 18:30:52 BST
From: Ken Down <diggings@argonet.co.uk>
Subject: Re: Perl editors and debuggers
Message-Id: <na.feaf6b4cc4.a60290diggings@argonet.co.uk>
In article <nsSCc.5660$rCA1.2985@news01.bloor.is.net.cable.rogers.com>,
"Doug Gale" <dgaleSPAMTHISYOUSCUM@mailexcite.com> wrote:
> Optiperl is really good
It's certainly helped me - though make sure that you set the export
parameters to Linux rather than MS, as otherwise you get #0d at the end of
every line as well as #0a, and that causes your program to hang.
Ken Down
--
__ __ __ __ __
| \ | / __ / __ | |\ | / __ |__ All the latest archaeological news
|__/ | \__/ \__/ | | \| \__/ __| from the Middle East with David Down
================================= and "Digging Up The Past"
Web site: www.diggingsonline.com
e-mail: diggings@argonet.co.uk
------------------------------
Date: Fri, 25 Jun 2004 21:50:26 +0100
From: "Clyde Ingram" <clydenospamorham@nospamorhamgetofftheline.freeservenospamorham.co.uk>
Subject: Re: PPT UNIX Reconstruction Project at: http://www.perl.com/language/ppt/
Message-Id: <M61Dc.199$B2.41@newsfe6-gui.server.ntli.net>
Tad,
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrncdmo9e.3as.tadmc@magna.augustmail.com...
> Clyde Ingram
<clydenospamorham@nospamorhamgetofftheline.freeservenospamorham.co.uk>
wrote:
> > Does anyone know where this web site has moved to?
>
>
> http://sourceforge.net/projects/ppt/
Thanks for this.
But the PPT foundry is empty.
There are no files and no documentation.
Where should I look for the familiar links to a couple of dozen Perl
implementations of UNIX commands?
Regards,
Clyde
------------------------------
Date: 25 Jun 2004 09:27:13 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Re: Regexp, Strings and spaces
Message-Id: <b893f5d4.0406250827.61127ab1@posting.google.com>
nospam@tomcat.ca.tc (Florent Carli) wrote in message news:<6d12cccb.0406242332.188d519@posting.google.com>...
> The problem is that I have to enter a regex into a config file of a
> software which does not understand lookbehinds (probably a old version
> of perl, since I get a "bad pattern <?...").
Oh, so that's why you had all those restrictions. Without the
knowledge of your restrictions, we couldn't really give you a complete
answer.
> Anyway, I'm not using perl directly for this, I have to find a regex
> to do that, without lookbehinds, that's it.
Are you sure you are using Perl for this? I've done similar things
myself (that is, putting a regular expression in a config file), but I
don't think it was Perl that was evaluating them. It could be that
Perl has nothing to do with this.
> That's why I can not code a second pass to remove quotes after a
> /field2=("[^"]*"|\S*)/ for instance, or something that would give me
> the one backreference I need after a /field2=(?:"([^"]*)"|(\S*))/.
> I can't use a perl module either, of course.
> If fact, I cannot code at all, the only thing I can control is 1
> regexp.
The main problem is that you are searching for different patterns,
depending on what your delimeter is. If you have 'value="some text"',
then you will be looking for the next '"' character to signal the end
of your pattern. But if you have 'value=some_text', then you will be
looking for whitespace to signal the end of your pattern. This flow
of logic (if-then-else) is something that regular expressions alone
weren't made to handle.
I don't think your problem has a working solution because regular
expressions lack the ability to carry out the above logic. So let me
propose two work-arounds:
1. You could modify the program that reads the config files to handle
the logic you need.
or
2. You can write a simple Perl script to convert your config file so
that all the fields have quotes around the values (whether they need
them or not). In other words, your script would change all instances
of:
field1=some_text
to:
field1="some_text"
Then you could just set your regular expression to be:
m/field[0-9]+="([^"]*)"/
and then all your fields would be extracted. Problem solved.
Of course, I would imagine that the second work-around will be much
easier for you to implement, unless there is some other restriction
that you haven't shared with us.
Hopefully you'll find a solution that works for you.
-- Jean-Luc
------------------------------
Date: Fri, 25 Jun 2004 09:50:44 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Splitting a file
Message-Id: <250620040950448413%jgibson@mail.arc.nasa.gov>
In article <3c03ef0c.0406250439.535f6897@posting.google.com>, Gianni
<pincopallo_it@yahoo.it> wrote:
> I have a file done like this
>
> |
> |
> cat
> dog
> monkey
> troll
> |
> |
> silver
> gold
> |
> |
> rome
> london
> praha
> |
> | etc.............
>
> how can I create a new file after the || ??
Do you want to create a new file or extend the old file?
To create a new file, use open for writing:
open($FH,'>',$newfile);
To append to the old file, use open for append:
open($FH,'>>',$oldfile);
Be sure and check whether the open succeeds. For how to do this, check
your local Perl documentation:
perldoc -f open
It is best if you post a complete, working program and explain why it
is not doing what you want. Be sure and read the guidelines for this
group that are posted here semi-weekly.
------------------------------
Date: Fri, 25 Jun 2004 16:53:23 GMT
From: vali <vticau@excite.com>
Subject: Re: Strange Behaviour with Hash???
Message-Id: <40DC4F7D.5010306@excite.com>
Fergus Toolan wrote:
> Hi all,
> We're currently writing some scripts that deal with hashs and are
> getting some strange behaviour with them. We have very little
> experience with dealing with hashs so I want to check something.
>
> Is it correct to assign one hash to another? For instance
>
> %H1 = %H2;
>
> I want the hashs to be distinct. Will the above statement completely
> overwrite the current contents of %H1?
>
> Any comments would be much appreciated
> Regards
> Fergus
>
You may want:
use Storable qw(dclone);
my %H1 = %{ dclone(\%H2)};
------------------------------
Date: 25 Jun 2004 16:36:56 GMT
From: ctcgag@hotmail.com
Subject: Re: Strange Behaviour with Hash???
Message-Id: <20040625123656.458$kF@newsreader.com>
Paul Lalli <mritty@gmail.com> wrote:
>
> > when we are finished this process we then
> > perform the assignment i.e.
> >
> > %H1 = %H2
>
> Confused again. If you're first assigning pieces of H1 to H2, how/why
> are you then assigning all of H1 to H2?
I assume you mean "all of H2 to H1".
This sounds like the classical task of transactionally updating a data
structure. You can't delete the "goners" from H1 immediately as you
recgonize them while iterating over H1, because they need to be used in
comparisons of other things that are still to be checked. So you save the
ones you want to keep to a temporary structure, then use that temporary
structure to replace the original when you are done.
If this is the case, the OP probably shouldn't use a second hash at all,
but an array.
Something like:
my @goner;
while (my $k=each %H1) {
push @goner, $k unless want_to_keep($k);
};
delete @H1{@goner};
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 25 Jun 2004 19:08:15 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Textual inclusion of files into a script.
Message-Id: <u94qozy0hc.fsf@wcl-l.bham.ac.uk>
ddtl <this.is@invalid> writes:
> Is it possible to textually include external files into a perl script,
> the way C/C++'s 'include FILE' does?
Yes if you run Perl with -P then it will support C-style #includes.
At least it will where a C preprocessor is installed where perl
expects it to be.
However, I wouldn't really recommend it.
> I don't want to use
> do/eval/use/require for that purpose, because using those imposes
> additional requirements. For example, in order to use 'eval', additional
> code to open and read the files is required,
Er, yes but you don't need this code if you use 'do' so that's not
really an issue is it?
> and private ('my') variables
> from the 'eval'ed files are not accessible.
Use the right tool for the job. You want a program in a style that
uses lots of global variables. This is generally considerd a bad
programming style. But if you are completely determined to use it
just declare your global variables using "use vars" rather than my.
> I just want to be able to split the original file into smaller
> pieces and have them assembled back automatically by the compiler,
> so that the semantics would be identical in both cases.
I would say your best course of action is to stop wanting that, it is
a bad thing to want.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 25 Jun 2004 11:45:48 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: Textual inclusion of files into a script.
Message-Id: <239ce42f.0406251045.19372ff7@posting.google.com>
ddtl <this.is@invalid> wrote in message news:<mmdod0tf19107j46af96dot9ls3sso6qmb@4ax.com>...
> Hello,
>
> Is it possible to textually include external files into a perl script,
> the way C/C++'s 'include FILE' does? I don't want to use
> do/eval/use/require for that purpose, because using those imposes
> additional requirements. For example, in order to use 'eval', additional
But eval or its equivalent is basic to the perl include system (use
and require). Really, when you run a program in perl, you are doing
this:
eval { my program's text here };
since perl is an interpreted language.
There is also the whole namespace problem--perl may keep variables
defined as lexicals with
my i;
in separate files in separate namespaces unless it is told otherwise.
If the issue is just one of extra programming though, look at
Module::Load
on CPAN. May help simplify loading for you.
-hth
------------------------------
Date: Fri, 25 Jun 2004 17:26:20 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Trim Multiple Dirs to Max Total Space Used - by Date
Message-Id: <f8da08bd90dd60e1020df19842792f3a@news.teranews.com>
>>>>> "Ron" == Ron Heiby <heiby_u@falkor.chi.il.us> writes:
Ron> I have a system where data files are created in multiple
Ron> directories. I need to run a daily script that will total the
Ron> disk space used by all the files in all the directories and see
Ron> whether the space exceeds some MAXSPACE value. In this case, all
Ron> but one of the directories are subdirectories of a common parent
Ron> dir, while the other one is off on its own. If the space does
Ron> exceed the maximum, I need to start deleting files, oldest first,
Ron> until the total space used drops just below the maximum.
Off the top of my head, using File::Finder (my module in the CPAN):
my $MAXSIZE = 102400; # 100K, let's say
my @START = qw(. /tmp); # current directory and /tmp being trimmed
use File::Finder;
my @list = sort { $a->[2] <=> $b->[2] } # sort age newest first
File::Finder->type('f')->collect(sub {
[$File::Find::name, -s, -M]
}, @START;
my $size = 0; # start the accumulator
# keep all new files under the right size
shift @list while @list and $size += $list[0][1] < $MAXSIZE;
# delete the rest
unlink or warn "Cannot delete $_: $!" for @list;
Untested, but I usually get this stuff right. :)
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V10 Issue 6730
***************************************