[16094] in Perl-Users-Digest
Perl-Users Digest, Issue: 3506 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 29 06:05:29 2000
Date: Thu, 29 Jun 2000 03:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <962273115-v9-i3506@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 29 Jun 2000 Volume: 9 Number: 3506
Today's topics:
Re: Book on Perl ASP <ivoz@starmail.com>
Re: Cant get perl cgi result (directly..) omtslug@my-deja.com
Re: Check out this site...:) (Tad McClellan)
Comp.pl and Modem. Pls help <Lambeth_IT@btinternet.com>
Re: different behaviour when running from web and comma (Tad McClellan)
Re: Embedding images into Perl script <vlad@soft-tronik.ru>
explicit package name maroun234@my-deja.com
Extract parts of a Mime mail ... <morin@echo.fr>
Re: File upload output <staceysmithNOstSPAM@legaljargon.com.invalid>
Re: Finding the directory of the current script (David Efflandt)
Re: Finding the directory of the current script <gellyfish@gellyfish.com>
flock question dimus63@my-deja.com
Re: Golf problem <neutron@fc.hp.com>
Re: Golf problem (Abigail)
Re: Help With Reg Exp. (Bart Lateur)
Re: Hot swap modules without shutdown (Malcolm Dew-Jones)
Re: Hot swap modules without shutdown <Peter.Dintelmann@dresdner-bank.com>
how can perl know what url it is using <ts@relson.net>
Re: How to change Solaris user password <gellyfish@gellyfish.com>
Re: how to count number of line in a file ? <RobertSaunders@bigfoot.com>
How to use only Perl functions to schedule tasks? pastan@my-deja.com
Re: Joining lines (R.Roe)
Re: Joining lines <webmaster@[spamblock]web-slingers.com>
Re: Joining lines <webmaster@[spamblock]web-slingers.com>
Re: Keeping track of open files (Tad McClellan)
Re: Keeping track of open files <peter.sundstrom@eds.com>
Re: Keeping track of open files (Abigail)
Loading modules on demand <news@fido.workone.com>
Re: Loading modules on demand (jason)
Re: Loading modules on demand <news@fido.workone.com>
Re: Lots of soft from NORMAN!! <gellyfish@gellyfish.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 29 Jun 2000 08:14:16 +0300
From: "Ivo Zdravkov" <ivoz@starmail.com>
Subject: Re: Book on Perl ASP
Message-Id: <395adabe_2@news.nwlink.com>
Usually perl modules contains docs inside. So go to CPAN
http://www.cpan.org ) and get related to ASP !
regards
Ivo Z.
"Bob Martin" <bob@inu.net> wrote in message news:395A5BEB.2B06FDD@inu.net...
> Can anyone recomend a book on Perl ASP?
>
> Thanks!
>
> Bob
------------------------------
Date: Thu, 29 Jun 2000 07:13:37 GMT
From: omtslug@my-deja.com
Subject: Re: Cant get perl cgi result (directly..)
Message-Id: <8jesuq$nk9$1@nnrp1.deja.com>
Thanks, but it didn't help. Same behaviour as before.
(you see in the script further down that I make stdout
unbuffered).
I don't know if it's some problem with my Apache server running
on NT. After what I've read this script should work as it is
with stdout unbuffered....
In article <8jd3b2$bqd$1@nnrp1.deja.com>,
thoma <thomastk@my-deja.com> wrote:
> Add the following line in the beginning of Perl script:
>
> $| = 1;
>
> In article <8jc7g0$ne6$1@nnrp1.deja.com>,
> omtslug@my-deja.com wrote:
> > Hi! I'm stuck with my perl cgi script which creates a
> > bash file (variabel setup and source of other scripts) and
> > then executing it.
> > I don't get my html response until the script finishes which
> > might be up to 1 hour..
> > I've made stdout unbuffered but it still doesn't work.
> > I also got the suggestion to close stdout which then delivers
> > the browser output directly but I don't get any logging from
> > my executed script to it's logfile.
> >
> > I don't know if this is a perl or apache problem and I can't
> > get this to work.
> > All tips appreciated.
> >
> > Running Apache 1.3.12 on NT4, perl 5.004_02.
> >
> > BR
> > Stefan
> >
> > ps. You get the same result just doing a sleep instead
> > of the exec. ds
> >
> > Here's some code:
> > #------------------------------------------------------------
> > #!/usr/bin/Perl -w
> > $forminfo = <STDIN>;
> > $formpure = $forminfo;
> > $forminfo =~ s/&/\n/g;
> >
> > [snip] here I get some vars from the form
> >
> > ($a,$a,$a,$mday,$mon,$a,$a,$a,$a) = localtime;
> > $buildfile="bs_".sprintf("%02d%02d%d", $mon+1, $mday, time);
> >
> > select(STDERR); $| = 1;
> > select(STDOUT); $| = 1;
> >
> > print "Content-type: text/html \n\n";
> > print "<html><head>";
> > print "<title>Build Confirm</title>";
> > print "</head>";
> > print "<body bgcolor=lightblue>";
> > print "Thank you! Your input has been processed and the kit<br>";
> > print "build is started. Your build id is: ".$buildfile;
> > print "<p>Links to your setup file and log file:<br>";
> > print "<a href=/buildset/".$buildfile.".sh>".$buildfile.".sh<br>";
> > print "<a href=/buildset/".$buildfile.".log>".$buildfile.".log</p>";
> > print "</body></html>";
> > print "\n\n";
> > print "\015\012"; #nothing helps...
> >
> > [snip] Here I generate the bash shell file (buildfile.sh)
> >
> > # force the server to deliver the content.........
> > #close(STDOUT); #close(STDERR); # this kills my buildfile.sh
> > output below!!
> >
> > exec "/Cygnus/cygwin-b20/H-i586-
> > cygwin32/bin/bash.exe ".$buildsetupdir."/".$buildfile.".sh
> > > ".$buildsetupdir."/".$buildfile.".log 2>&1";
> >
> > exit(0);
> > #------------------------------------------------------
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 28 Jun 2000 23:43:16 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Check out this site...:)
Message-Id: <slrn8llhek.2ja.tadmc@magna.metronet.com>
On Thu, 29 Jun 2000 03:01:00 GMT, akashgoel@my-deja.com <akashgoel@my-deja.com> wrote:
>If we don't like it, we mention it!
Well, *we* don't like being spammed.
Please stop it.
>The
>sections covered at our site include: Computers and Internet,
>Education, Software, Webmaster, Music, Desktop, Gaming and more:)
Do you have a section on what action to take against
Internet abusers?
We get them frequently here. Gotta do something about it!
>So please come check us out
No thanks.
I tend to NOT reward anti-social behavior such as yours.
>Please email us or post back
>your comments/suggestions.
^^^^^^^^^^^
Go away and don't come back!
>Thanks,
Err, you're welcome, I guess.
>Akash Goel <===== spammer alert
>Webmaster
^^^^^^
^^^^^^ yeah, right.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Jun 2000 10:35:59 +0100
From: Chris <Lambeth_IT@btinternet.com>
Subject: Comp.pl and Modem. Pls help
Message-Id: <395B187E.C0F1611A@btinternet.com>
I'm trying to use "Comm.pl" to interact with a modem. e.g. Dial out,
check response=CONNECT, then send a message.
Has anyone used this module to interact, could they reply with a code
snippit which just does print "at" and then gets the "OK" response.
Thanks for your help.
Chris
------------------------------
Date: Wed, 28 Jun 2000 22:28:48 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: different behaviour when running from web and command line
Message-Id: <slrn8lld30.2ge.tadmc@magna.metronet.com>
On 29 Jun 2000 11:05:54 +1000, Shao Zhang <shao@linux.cia.com.au> wrote:
>In article <slrn8ljr9i.1ib.tadmc@magna.metronet.com>, Tad McClellan wrote:
>> On 28 Jun 2000 18:16:02 +1000, Shao Zhang <shao@linux.cia.com.au> wrote:
>>
>> > I have wrote a simple perl script that basically does a query from a
>> > website, however, it only works when run from command line, not
>> > from the web...
>>
>>
>> Perl FAQ, part 9:
>>
>> "My CGI script runs from the command line but not the browser.
>> (500 Server Error)"
>
> I don't have a 500 server error. The script executes fine, but just no
> output.
You miss the point.
If it works from the command line and does not work as a CGI
program, then the problem must be something related to the
CGI environment, not related to your Perl code.
So you don't have a Perl question. Your Perl is working fine,
by your own admission.
The newsgroup for discussing the CGI environment is
comp.infosystems.www.authoring.cgi
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Jun 2000 13:41:24 +0400
From: "Vladimir Rybintsev" <vlad@soft-tronik.ru>
Subject: Re: Embedding images into Perl script
Message-Id: <8jf5dp$2rqj$1@storm.comstar.ru>
Thanks to everybody, who answer me!
From your pieces I collect whole mosaic, and now I know right answer.
It was indeed uuencoded gif image, without "begin" and "end" lines.
To make script generate HTML page, we need to save in variable uuencoded
lines.
Called without parameters, it generates HTML document.with string
<img src="$SCRIPT_URL?someparameter=somevalue">
Called with some parameters, it generates output with commands
print "Content-type: image/gif\n\n";
print unpack("u*", $fG);
And we have HTML page with one or more images.
------------------------------
Date: Thu, 29 Jun 2000 09:18:33 GMT
From: maroun234@my-deja.com
Subject: explicit package name
Message-Id: <8jf490$tgi$1@nnrp1.deja.com>
hi,
I'm trying to compile a perl file.
I'm getting the following messge:
Global symbol '$HOST' requires explicit package name at line 50
line 50 has: my $HOST = 'private@201.43.2.2';
anyone has any ideas?
Thank you
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 29 Jun 2000 10:11:49 +0200
From: morin julien <morin@echo.fr>
Subject: Extract parts of a Mime mail ...
Message-Id: <395B04C5.631E149D@echo.fr>
Hello,
I'd like to know how to extract only the text/plain part of a mail just
received via a POP3 account ...
Thanks ...
------------------------------
Date: Thu, 29 Jun 2000 01:03:42 -0700
From: stacey843 <staceysmithNOstSPAM@legaljargon.com.invalid>
Subject: Re: File upload output
Message-Id: <0937f596.23338e52@usw-ex0107-049.remarq.com>
Thanks. I had print<<html_code1
instead of 'return'. Those small errors
will kill ya.
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: 29 Jun 2000 05:52:51 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Finding the directory of the current script
Message-Id: <slrn8llp0s.v1.efflandt@efflandt.xnet.com>
On Wed, 28 Jun 2000 10:18:55 -0700, Jürgen Exner <juex@deja.com> wrote:
>"Sami Maki" <sami.maki@nokia.com> wrote in message
>news:tog65.4226$AM5.52548@news1.nokia.com...
>[de-jeopardized quotations]
>> conic@bigpond.com wrote in message <8jbi4t$94r$1@nnrp1.deja.com>...
>> >Is there a way for a script to realise what directory it is in? I want
>> >to examine files that are in the same directory as the script, but also
>> >to be able to move the script to any directory without changing it.
>> To get path of current working directory..
>>
>> use Cwd;
>> print cwd();
>
>But the CWD is a property of the shell and has nothing to do with the
>location of the script in the file tree.
If the script is in the PATH, the current working dir might not be the dir
the script is in unless you specifically cd to that dir first.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: 28 Jun 2000 23:43:10 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Finding the directory of the current script
Message-Id: <8jdv1u$fop$1@orpheus.gellyfish.com>
On Wed, 28 Jun 2000 00:50:41 GMT conic@bigpond.com wrote:
> Is there a way for a script to realise what directory it is in? I want
> to examine files that are in the same directory as the script, but also
> to be able to move the script to any directory without changing it.
>
I think you are looking for the FindBin module which is part of the
standard distribution.
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: Thu, 29 Jun 2000 07:21:52 GMT
From: dimus63@my-deja.com
Subject: flock question
Message-Id: <8jete8$p02$1@nnrp1.deja.com>
Below is the classical example of modifying a file in place using
temporary file from perlfaq5.
I have to implement it for a multiuser program. Can you advise should I
use exclusive locks for both files, or LOCK_SH for read-only file and
LOCK_EX for write only file? I have impression that they both should be
LOCK_EX, but I am not sure.
Thanks in advance!
Dmitry Mozzherin
$old = $file;
$new = "$file.tmp.$$";
$bak = "$file.orig";
open(OLD, "< $old") or die "can't open $old: $!";
open(NEW, "> $new") or die "can't open $new: $!";
# Correct typos, preserving case
while (<OLD>) {
s/\b(p)earl\b/${1}erl/i;
(print NEW $_) or die "can't write to $new: $!";
}
close(OLD) or die "can't close $old: $!";
close(NEW) or die "can't close $new: $!";
rename($old, $bak) or die "can't rename $old to
$bak: $!";
rename($new, $old) or die "can't rename $new to
$old: $!";
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 29 Jun 2000 05:04:10 GMT
From: Jack Applin <neutron@fc.hp.com>
Subject: Re: Golf problem
Message-Id: <8jelca$h2u$1@fcnews.fc.hp.com>
Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
> perl -F// -ane 'my%c;@c{@F}=1;@F*keys%c==121&&print' /usr/dict/words
This is shorter:
perl -pe '$_=""if/(.).*\1/||11-length' /usr/dict/words
-Jack Applin
neutron@fc.hp.com
------------------------------
Date: 29 Jun 2000 02:01:38 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Golf problem
Message-Id: <slrn8llqju.ka1.abigail@alexandra.delanet.com>
Gwyn Judd (tjla@guvfybir.qlaqaf.bet) wrote on MMCDXCIV September MCMXCIII
in <URL:news:slrn8lli7v.2q5.tjla@thislove.dyndns.org>:
;;
;; what subset is it though? What happens when you treat a hash as a
;; scalar? I can't find that anywhere in the docs.
perldata
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
------------------------------
Date: Thu, 29 Jun 2000 09:23:40 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Help With Reg Exp.
Message-Id: <39610b8f.3572706@news.skynet.be>
spurcell wrote:
>Could someone step me through this please. I understand all the components,
>but when they are all placed together, I am getting lost. This comes from
>Tom C.s class. I really need help understanding what the regular expression
>is doing and how the line is getting pushed to the array.
>
>sub lines_here {
> my $string = shift;
> my @lines = $string =~ /\S.*\S/gm; # \s space, tab or newline
> return @lines;
>}
>
>@thickness = lines_here <<EOF;
>thin and crispy
>thick and doughy
>regular
>EOF
What is it exactly that you don't understand? I must say that the //m
modifier is redundant, because there isn't a ^ or $ in sight. This works
just as well:
my @lines = $string =~ /\S.*\S/g;
This is another example of this, which might be just a bit simpler:
$_ = 'I say, "hello there!"';
@words = /\w+/g;
print map "<$_>\n", @words;
-->
<I>
<say>
<hello>
<there>
Note that the regex doesn't have parentheses. In that case, when using
the //g modifier, you'll get the whole matched string; and that for all
the matches. With parentheses, you'd only get the stuff between them.
So, /\w+/g and /(\w+)/g are equivalent.
Now, back to Tom's regex: /\S.*\S/ . This will attempt to match a
nonspace, followed by anything but a newline, and ending with a
nonspace. So it will match from the first non-blank to the last
non-blank on the same line. It will match "hello there" in the string
" hello there \n ignored".
With //g, it will do that for every line, but do note that it won't work
on lines with only one nonspace. At least two.
--
Bart.
------------------------------
Date: 28 Jun 2000 23:17:02 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Hot swap modules without shutdown
Message-Id: <395ae9de@news.victoria.tc.ca>
John Lin (johnlin@chttl.com.tw) wrote:
: Dear all,
: Can I "hot swap" modules?
: That is, without shutting down the main program, can I unload
: a module and then reload the module of a modified version?
If you entered 'require' or 'use' then perl doesn't reload a module if
it's in the %INC hash. If you remove its name from the %INC hash then
next time you 'require' or 'use' the module then perl will go back to the
disk and reread it.
You can also enter the 'do' statement to unconditionally reload a file,
though you should perform some error checks yourself then, plus
potentially call 'import'.
Reloading the module causes global variables and subroutines and anything
else defined, to be redefined, but does not necessarily undo other things
that have been done by the module, plus references to things still exist
(so that a redefined subroutine, for example, may still not be completely
gone).
------------------------------
Date: Thu, 29 Jun 2000 09:48:02 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: Hot swap modules without shutdown
Message-Id: <8jeuu2$9f11@intranews.dresdnerbank.de>
Hi,
John Lin schrieb in Nachricht <8je9jm$qds@netnews.hinet.net>...
>That is, without shutting down the main program, can I unload
>a module and then reload the module of a modified version?
of course. The key point is %INC which keeps track
on all loaded modules. Thus to get rid of (i.e. "unrequire")
a module Module.pm you
delete $INC{'Module.pm'};
Now perl thinks the module is not yet loaded and you can
require it again.
Best regards,
Peter Dintelmann
------------------------------
Date: Thu, 29 Jun 2000 11:01:19 +0100
From: "Tony Shrimpoton" <ts@relson.net>
Subject: how can perl know what url it is using
Message-Id: <8jf6pg$jp4$1@vg170.it.volvo.se>
hi ,
i am writing an web site at the moment , and becasue it is sending user and
credit card info about i am running it on a 128bit ssl cert
my question is , how can i get my perl cgi script to know that is is
running on https:// and not http:// ?? because i want the script to ent if
it is on a http:// cannection
thanks
ts
------------------------------
Date: 28 Jun 2000 23:48:09 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to change Solaris user password
Message-Id: <8jdvb9$gn8$1@orpheus.gellyfish.com>
On Wed, 28 Jun 2000 09:15:24 GMT alexyuen2092@my-deja.com wrote:
>
> I am working with Netscape Enterprise Server and would like to
> implement some forms of security with Solaris Build-in security.
> However, I would like if there's any programs/scripts that allow user
> to change their own password in Solaris.
>
I find the passwd program usually suffices
>
> P.S. please email me at alexyuen2092@my-deja.com as I could not do
> frequent access to this newsgroup.
>
And I have infrequent access to email so what do we do now ?
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: Thu, 29 Jun 2000 10:36:54 +0200
From: "Robert Saunders" <RobertSaunders@bigfoot.com>
Subject: Re: how to count number of line in a file ?
Message-Id: <395b0ab9$0$231@hades.is.co.za>
B Kemp <hyagillot@tesco.net> wrote in message
news:8jduct$jab$1@epos.tesco.net...
>
> >Your solution offers no speed advantage (maybe a slight speed
> >disadvantage thanks to spawning three processes instead of zero
> >processes). As well, your solution has a distict portability
> >disadvantage.
>
>
> The above must be worth thinking about,
> but I did test it on my apache access log, and my suggestion was 10x
slower.
>
> Please note, though, that my suggestion was for discussion purposes only
> (ie not something I'd really want to do), something that I thought I made
> clear. But obviously not clear enough.
>
ah geez, can't you just admit that your idea was basically a bad one and
retire gracefully?
------------------------------
Date: Thu, 29 Jun 2000 07:42:28 GMT
From: pastan@my-deja.com
Subject: How to use only Perl functions to schedule tasks?
Message-Id: <8jeul2$pod$1@nnrp1.deja.com>
Hello All,
I'm using free www.Hypermart.net account. It support Perl but doesn't
allow to use Cron and similar opportunities to schedule my tasks and
proceses. Is it possible to use some Perl functions instead to make
tracking software?
If so, then how?
Thank You, all
Regards,
Andrew
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 29 Jun 2000 05:47:18 GMT
From: rroe@mail.com (R.Roe)
Subject: Re: Joining lines
Message-Id: <8F621C5BCrroemailcom@64.34.205.9>
Thanks a lot. Got it working. Yes, I have the camel book by Larry Wall et
al. But if you have some other book suggestion, I would buy it.
news@webneeds.com (Dan Manion) wrote in
<xis65.132$%O.184145@news.uswest.net>:
>## First step ... open your file
>open (FILE, "bigassfile") || die "open error: $!";
>my @ALL = <FILE>;
>close (FILE);
>## SEE perldoc -f open
>
>##2nd step ... use chomp.
>chomp(@ALL);
>## SEE perldoc -f chomp
>
>##3rd Step ... use join.
>my $str = join('',@ALL);
>##perldoc -f join
>
>
>There are tons of great books and online documentation on learning perl.
>Might be worth your time to go find some good bathroom reading material
>and start to tackle some of the basics.
>
>Hope this helps!
>
>"R.Roe" <rroe@mail.com> wrote in message
>news:8F617E505rroemailcom@64.34.205.9...
>> I would appreciate help with with the following:
>> I need to convert a text file containing several lines which have
>> carriage returns at the end, into one long string by joining the
>> lines. How do I
>write
>> the perl code for this please?
>>
>> Thanks in advance.
>
>
------------------------------
Date: Wed, 28 Jun 2000 19:21:16 -0400
From: "Rick Stricker" <webmaster@[spamblock]web-slingers.com>
Subject: Re: Joining lines
Message-Id: <395a882f.0@speedtrap.i2k.com>
That's the reply I'd expect from someone who doesn't know
the answer.
Lighten up, Paul. Nobody asked for a complete app, just
a code snippet. That's the purpose of Usenet, BTW.
Paul Taylor wrote in message <395A267B.FB3AC977@NOTHEREsotonians.org.uk>...
>"R.Roe" wrote:
>>
>> I would appreciate help with with the following:
>> I need to convert a text file containing several lines which have
carriage
>> returns at the end, into one long string by joining the lines. How do I
write
>> the perl code for this please?
>>
>> Thanks in advance.
>
>Honestly, if you want someone to code it for you, go hire a programmer.
>
>Or read the fabulous manual page. Or O'Reilly's books.
>
>Pap.
------------------------------
Date: Wed, 28 Jun 2000 19:21:37 -0400
From: "Rick Stricker" <webmaster@[spamblock]web-slingers.com>
Subject: Re: Joining lines
Message-Id: <395a8844.0@speedtrap.i2k.com>
That's the reply I'd expect from someone who doesn't know
the answer.
Nobody asked for a complete app, just a code snippet.
That's the purpose of Usenet, BTW
.
Dan Manion wrote in message ...
>## First step ... open your file
>open (FILE, "bigassfile") || die "open error: $!";
>my @ALL = <FILE>;
>close (FILE);
>## SEE perldoc -f open
>
>##2nd step ... use chomp.
>chomp(@ALL);
>## SEE perldoc -f chomp
>
>##3rd Step ... use join.
>my $str = join('',@ALL);
>##perldoc -f join
>
>
>There are tons of great books and online documentation on learning perl.
>Might be worth your time to go find some good bathroom reading material and
>start to tackle some of the basics.
>
>Hope this helps!
>
>"R.Roe" <rroe@mail.com> wrote in message
>news:8F617E505rroemailcom@64.34.205.9...
>> I would appreciate help with with the following:
>> I need to convert a text file containing several lines which have
carriage
>> returns at the end, into one long string by joining the lines. How do I
>write
>> the perl code for this please?
>>
>> Thanks in advance.
>
>
------------------------------
Date: Wed, 28 Jun 2000 23:24:45 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Keeping track of open files
Message-Id: <slrn8llgbt.2ge.tadmc@magna.metronet.com>
On Thu, 29 Jun 2000 13:51:26 +1200, Peter Sundstrom <peter.sundstrom@eds.com> wrote:
>
>Tina Mueller wrote in message <8je5eo$dmii$1@ID-24002.news.cis.dfn.de>...
>>hi,
>>Peter Sundstrom <peter.sundstrom@eds.com> wrote:
>>> What's the best way to handle keeping track of what files have been
>opened?
>>
>>> I need to make sure that I only open the file once.
>>> if (! defined $filehandle{$filename}) {
>>> open $filehandle{$filename}, ">$filename" or die "Can not write to
>>
>>how do you initialize $filehandle{$filename}?
>
>It happens after the open:
>
>$filehandle{$filename}=$filename;
>
>>you should do it like
>>$filehandle{$filename} = *FILEHANDLE;
>>unless (fileno $filehandle{$filename}) {
>> open $filehandle{$filename}, ">$filename" or die $!;
>>}
>
>I don't see how this is any better. Perhaps I'm missing something obvious.
^^^^^^^^^^^^^^^^^^^^^^^^^
I'm beginning to think that maybe you are missing the fact
that filehandles are not first-class datatypes?
(you cannot store them directly in an array)
perldoc -q filehandle
"How can I make a filehandle local to a subroutine?
How do I pass filehandles between subroutines?
How do I make an array of filehandles?"
"How can I pass/return a {Function, FileHandle, Array,
Hash, Method, Regex}?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Jun 2000 17:06:30 +1200
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Keeping track of open files
Message-Id: <8jelk0$jk8$1@hermes.nz.eds.com>
Tad McClellan wrote in message ...
>On Thu, 29 Jun 2000 13:51:26 +1200, Peter Sundstrom
<peter.sundstrom@eds.com> wrote:
>>
>>Tina Mueller wrote in message <8je5eo$dmii$1@ID-24002.news.cis.dfn.de>...
>>>hi,
>>>Peter Sundstrom <peter.sundstrom@eds.com> wrote:
>>>> What's the best way to handle keeping track of what files have been
>>opened?
>>>
>
>>>> I need to make sure that I only open the file once.
>
>>>> if (! defined $filehandle{$filename}) {
>>>> open $filehandle{$filename}, ">$filename" or die "Can not write to
>>>
>>>how do you initialize $filehandle{$filename}?
>>
>>It happens after the open:
>>
>>$filehandle{$filename}=$filename;
>>
>>>you should do it like
>>>$filehandle{$filename} = *FILEHANDLE;
>>>unless (fileno $filehandle{$filename}) {
>>> open $filehandle{$filename}, ">$filename" or die $!;
>>>}
>>
>>I don't see how this is any better. Perhaps I'm missing something
obvious.
> ^^^^^^^^^^^^^^^^^^^^^^^^^
>
>I'm beginning to think that maybe you are missing the fact
>that filehandles are not first-class datatypes?
>
>(you cannot store them directly in an array)
Yes. I realise that. But notice that the filename is being used for the
filehandle. Therefore a hash of the filenames will tell me if a filehandle
has been used.
------------------------------
Date: 29 Jun 2000 02:05:48 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Keeping track of open files
Message-Id: <slrn8llqrn.ka1.abigail@alexandra.delanet.com>
Peter Sundstrom (peter.sundstrom@eds.com) wrote on MMCDXCIII September
MCMXCIII in <URL:news:8je22q$phv$1@hermes.nz.eds.com>:
() What's the best way to handle keeping track of what files have been opened?
()
() I have a set of input data that determines what the name of the output file
() will be. The number and name of the output files will vary with each new
() set of input data.
()
() Once I've opened my output file using a variable filehandle, I'll be writing
() data to it. I need to make sure that I only open the file once.
() I was thinking of something like creating a hash of the filehandles and
() doing a check to see if I need to open the file before writing to it, eg:
()
() if (! defined $filehandle{$filename}) {
() open $filehandle{$filename}, ">$filename" or die "Can not write to
() $filename $!\n";
() }
()
() print $filehandle{$filename} "$somedata";
()
() Is there a better way to do this?
I would use IO::File by subclassing it, and then strictly use that
subclass to open and access files.
Abigail
--
perl -Mstrict -we '$_ = "goto Z.print chop;\n=rekcaH lreP rehtona tsuJ";Z1:eval'
------------------------------
Date: Thu, 29 Jun 2000 10:45:55 +0200
From: Kirill Miazine <news@fido.workone.com>
Subject: Loading modules on demand
Message-Id: <Pine.LNX.4.21.0006291039360.4239-100000@zebul.uio.no>
Hello world!
The question is: how is it possible to load perl-modules only when one
need them. Not on the top of the programm using `use module', but somehere
else like in the `if' statement: if (...) { use module }. Will the module
be loaded only if the if-thing is true, or will it be loaded anyway? Maybe
I should use `eval (use module)' instead?
Thanks
------------------------------
Date: Thu, 29 Jun 2000 09:08:02 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Loading modules on demand
Message-Id: <MPG.13c5af2fa2750de998975c@news>
Kirill Miazine writes ..
>The question is: how is it possible to load perl-modules only when one
>need them. Not on the top of the programm using `use module', but somehere
>else like in the `if' statement: if (...) { use module }. Will the module
>be loaded only if the if-thing is true, or will it be loaded anyway? Maybe
>I should use `eval (use module)' instead?
perldoc -f require
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Thu, 29 Jun 2000 11:19:18 +0200
From: Kirill Miazine <news@fido.workone.com>
Subject: Re: Loading modules on demand
Message-Id: <Pine.LNX.4.21.0006291119010.4716-100000@zebul.uio.no>
Thanks!!
#
# perldoc -f require
#
# --
# jason - elephant@squirrelgroup.com -
#
------------------------------
Date: 28 Jun 2000 23:52:30 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Lots of soft from NORMAN!!
Message-Id: <8jdvje$hhm$1@orpheus.gellyfish.com>
On Wed, 28 Jun 2000 09:00:56 GMT cdsimpl_2000@my-deja.com wrote:
> Lots of soft from NORMAN!!
> AUTOCAD 2000 ON 2 CD'S
Sounds like you are advocating theft here - I dont know about anyone else
but I would get straight on the phone to Autodesk ...
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
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 3506
**************************************