[13896] in Perl-Users-Digest
Perl-Users Digest, Issue: 1340 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 10 14:05:35 1999
Date: Wed, 10 Nov 1999 11:05:19 -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: <942260719-v9-i1340@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 10 Nov 1999 Volume: 9 Number: 1340
Today's topics:
Re: "Cross-device link" *error* <emschwar@rmi.net>
Re: 'dup'ing filehandles <aqumsieh@matrox.com>
Re: Batch Program Execution (Kragen Sitaker)
calling my own modules <tom.kralidis@ccrs.nrcanDOTgc.ca>
Re: create a folder and after a file... <jeff@vpservices.com>
Re: create a folder and after a file... (Kragen Sitaker)
Re: Don't know how to grep ... help! <emschwar@rmi.net>
Re: Example of forking without waiting it's child ..... (Sam Holden)
Re: Example of forking without waiting it's child ..... (Kragen Sitaker)
Form that writes to file, emails, sends attachments <dontspamon@me.net>
Function that can change it's parameter (Ryan Ngi)
Re: Function that can change it's parameter (Kragen Sitaker)
grep problem <nobody@logica.com>
Re: Help Needed in Win32::API <tye@metronet.com>
Help woth perl <chris@chrismail.connectfree.co.uk>
Re: Help woth perl (Kragen Sitaker)
Re: how to convert <br> to "newline" <koharik@primenet.com>
Re: how to convert <br> to "newline" <bholdren@NOSPAMMY.linkohio.com>
Re: how to parse dir recursively for files? (Kragen Sitaker)
Re: I guess this should not happen (M.J.T. Guy)
Re: Is $$variable allowed like in PHP ? (M.J.T. Guy)
Re: Is $$variable allowed like in PHP ? (Tad McClellan)
Re: MP3.pm - play/control your mpeg music via perl (Chris Nandor)
Re: Multiple cookies question with CGI.pm? <shmooth@yahoo.com>
Re: Multiplexing Server <aqumsieh@matrox.com>
OO question again <schmickl@magnet.at>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Nov 1999 10:20:20 -0700
From: Eric The Read <emschwar@rmi.net>
Subject: Re: "Cross-device link" *error*
Message-Id: <xkfpuxi9sbv.fsf@valdemar.col.hp.com>
"Steve Protopapas" <steve@corp.airmedia.com> writes:
> Elton <elton_taupinNOelSPAM@altavista.net.invalid> wrote in message
> news:054f0654.8297b8f7@usw-ex0108-062.remarq.com...
> > The die message indicated Cross-device link. What does this
> > error mean and how do I fix it. When I do this at the prompt
> > using the mv command I don't get this error.
>
> You can call "system" with the "mv" command. Be sure to check its return
> code.
Ack! Don't encourage needless use of the "system" command.
#!/usr/bin/perl -w
use strict;
use File::Copy;
my $source = '/some/file/path';
my $dest = '/some/other/path';
move($source, $dest) or die "couldn't move: $!";
__END__
And File::Copy is in the standard distribution, so there's no excuse for
not using it. :)
-=Eric
--
"Cutting the space budget really restores my faith in humanity. It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
-- Johnny Hart
------------------------------
Date: Wed, 10 Nov 1999 10:52:36 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: 'dup'ing filehandles
Message-Id: <x3yemdyz6m3.fsf@tigre.matrox.com>
Frank Sweetser <rasmusin@erwin.wpi.edu> writes:
> the dup stuff should go in here
>
> exec(...)
>
> now, i've already verified that the socket io is working fine - i can read
> and write to it no problem... however, i just can't seem to redirect
> STDIN/STDOUT/STDERR to go through the socket, so that the child process
> inherits them. any pointers?
The FAQs (again!). From perlfaq5:
How do I dup() a filehandle in Perl?
HTH,
--Ala
------------------------------
Date: Wed, 10 Nov 1999 18:57:35 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Batch Program Execution
Message-Id: <zejW3.64451$23.2528021@typ11.nn.bcandid.com>
In article <382929A9.D43CA73A@sfsws1.de.lucent.com>,
Vijay N Rao <vn8@sfsws1.de.lucent.com> wrote:
>Yes David, you are right. I don't need a contionous connection. I need to do FTP
>only frequently. I tried Net::FTP but that works only in unix environment. I am
>using perl on win95.
What happens when you try to use Net::FTP on Win95?
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 10 Nov 1999 12:45:47 -0500
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: calling my own modules
Message-Id: <3829AF4B.E66753E7@ccrs.nrcanDOTgc.ca>
How can I call my own modules, in cases where I do not want them in the
default lib?
..Tom
-----------------------------------------------------------------------------------------
Tom Kralidis Geo-Spatial Technologist
Canada Centre for Remote Sensing Tel: (613) 947-1828
588 Booth Street , Room 241 Fax: (613) 947-1408
Ottawa , Ontario K1A 0Y7 http://www.ccrs.nrcan.gc.ca
-----------------------------------------------------------------------------------------
------------------------------
Date: 10 Nov 1999 17:13:54 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: create a folder and after a file...
Message-Id: <3829A78C.3967F0FC@vpservices.com>
"Frédérick Giasson" wrote:
> i jsut need to create a folder and after a file in this folder
>
> $BaseDir = "../logo/$Entreprise/";
This is a relative path. What is it relative to? Do you know where
your script is actually executing?
> mkdir($BaseDir, 0777);
You have no error checking to find out if this works or to find out if
it fails, why it fails.
> open(FILEHANDLE,"+>$BaseDir/index.html)
Ditto.
--
Jeff
------------------------------
Date: Wed, 10 Nov 1999 18:02:45 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: create a folder and after a file...
Message-Id: <9riW3.64271$23.2522643@typ11.nn.bcandid.com>
In article <38298A6D.8B980093@decatomb.com>,
Frédérick Giasson <fred@decatomb.com> wrote:
>this don't work!!!
How do you know?
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 10 Nov 1999 11:01:41 -0700
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Don't know how to grep ... help!
Message-Id: <xkfiu3a9qey.fsf@valdemar.col.hp.com>
"Mark E. Drummond" <drummond-m@rmc.ca> writes:
> Hi all. Tring to use perl's built in grep to search some emails for a
> particular "to" or "cc". Here's my, wrong, code:
You say that, but I don't see any calls to grep below.
> #!/usr/bin/perl -w
Good start, but you're missing a "use strict;" as well.
Also, you might want to look into the module File::Find, as I think it
has some features to do what you want here.
> opendir(SINGLE,"/var/mail/mailbox/.s0000") ||
> die "Could not open single copy store volume: $!";
> chdir "/var/mail/mailbox/.s0000";
>
> # I specify on the command line the number of days "old" for
> # the find command's -ctime value (below).
> ($old) = @ARGV;
Why are you doing this assignment in list context? Why not a simple
"$old = $ARGV[0];"?
> foreach (sort readdir(SINGLE)) {
> # for each dir we want to see if a message is a) directed
> # to staff or student master and b) if it is older than
> # $old days.
> next if ($_ =~ /^\./);
> chdir $_;
This chdir is unnecessary; you could just pass the current directory into
the find command. But that's just being picky.
> print "Processing $_:\n";
> open (FIND,"/usr/bin/find . -name \".blk\" -prune -o -name
> \"__*__\" -prune -o -ctime +$old -print|") ||
> die "Could not open pipe from find: $!";
It's a good start to check the open, but you don't check the close, which
is even more important with piped opens. In fact, you don't even *DO* a
close. This is generally a Bad Thing(tm).
> while (<FIND>) {
So you read the name of a file in the current directory into $_, and then
> if (/(staff|student)\.master/i) { print };
You try to match the string "staff.master" or "student.master" in the
filename. This doesn't match your problem description, unless I'm
reading it wrong. You'll need to actually open the file to read its
contents, no?
> }
> chdir "..";
See above comment on chdir; these are only really necessary when you're
callingi yourself recursively, which you ain't.
> }
>
> So basically, there are subdirs under /var/mail/mailbox/.s0000
> corrensponding to each user, I am going to cd into each dir, find all
> the file older than 30 days and grep them for the strings "staff.master"
> and "student.master".
I presume by this you mean grep the contents of the file, not the
filenames, otherwise, my comments aren't relevant.
> But this ain't working. I figure my regex is wrong but I can't see how.
The regex looks fine, though I wonder if the /i is really needed.
-=Eric
--
"Cutting the space budget really restores my faith in humanity. It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
-- Johnny Hart
------------------------------
Date: 10 Nov 1999 18:17:56 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Example of forking without waiting it's child .....
Message-Id: <slrn82jdmv.ghl.sholden@pgrad.cs.usyd.edu.au>
On Wed, 10 Nov 1999 16:50:20 GMT, jcamron@my-deja.com wrote:
>when general forking a new child process, the child will stick to it's
>parent......
>
>Is there any way to make the child disconnect from it's parent?
>
>----- i've already seen perlIPC, but it's not help much, Tom said
>================================================================ In some
>cases (starting server processes, for instance) you'll want to complete
>dissociate the child process from the parent. The easiest way is to use:
>
> use POSIX qw(setsid);
> setsid() or die "Can't start a new session: $!";
>================================================================
>
>he doesn't show how to implement,
That is an implementation...
>I don't understand "setsid()".........
You don't have too, you just use it.
>
>it's so vague.............................................
It seems very specific to me. So specific in fact, you can just
cut and paste the code.
>
>anyone have an example of this case,...... please help!
Here's one:
use POSIX qw(setsid);
defined ($pid = fork()) || die "Can't fork: $!";
unless ($pid)
{
setsid() || die "Can't start a new session: $!";
}
--
Sam
Just don't create a file called -rf. :-)
--Larry Wall
------------------------------
Date: Wed, 10 Nov 1999 18:21:16 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Example of forking without waiting it's child .....
Message-Id: <wIiW3.64343$23.2491875@typ11.nn.bcandid.com>
In article <80c7o9$3m8$1@nnrp1.deja.com>, <jcamron@my-deja.com> wrote:
>when general forking a new child process, the child will stick to it's
>parent......
what do you mean stick to................................................................................................................................................................................................................................................
>Is there any way to make the child disconnect from it's parent?
what do............................................................................................................................................you..............................mean by disconnect......................................................................
> use POSIX qw(setsid);
> setsid() or die "Can't start a new session: $!";
>
>he doesn't show how to implement,
that looks....................like.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
............................................................!
............................................................................................................a code sample there..............................
>I don't understand "setsid()".........
maybe... you should......................... read the man page
for......................... the C function............... setsid?
are you........................................................................................................................................................................................................sure it's what you....................want?
>it's so vague.............................................
>
>anyone have an example of this case,...... please help!
your question is too...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................vague to answer.....properly....
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 10 Nov 1999 13:53:33 -0300
From: Jacky Childs <dontspamon@me.net>
Subject: Form that writes to file, emails, sends attachments
Message-Id: <3829A308.550@me.net>
Greetings:
As the subject states, I need a form that writes to file, emails, and
can send file attachments. Two out of three would be good.
Am I looking for miracles?
Does such a thing exist?
Does a partial thing exist?
Please help.
Sincerely,
Jacky (haven't got a clue) Childs
------------------------------
Date: Wed, 10 Nov 1999 16:58:58 GMT
From: ryanngi@hotmail.com (Ryan Ngi)
Subject: Function that can change it's parameter
Message-Id: <3829a29e.99615928@news.inet.co.th>
the return style function make my code more spagehttier,
how to implement a function that can change it's parameter variables,
for example chop, shift, etc.?
--- in C ,we can pass the pointer variable so we can do that job ,but
perl we can't, is it possible?
------------------------------
Date: Wed, 10 Nov 1999 18:27:23 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Function that can change it's parameter
Message-Id: <fOiW3.64359$23.2525522@typ11.nn.bcandid.com>
In article <3829a29e.99615928@news.inet.co.th>,
Ryan Ngi <ryanngi@hotmail.com> wrote:
>
>the return style function make my code more spagehttier,
>
>how to implement a function that can change it's parameter variables,
>for example chop, shift, etc.?
>
>--- in C ,we can pass the pointer variable so we can do that job ,but
>perl we can't, is it possible?
Here's what perldoc perlsub says:
The Perl model for function call and return values is
simple: all functions are passed as parameters one single
flat list of scalars, and all functions likewise return to
their caller one single flat list of scalars. Any arrays or
hashes in these call and return lists will collapse, losing
their identities--but you may always use pass-by-reference
instead to avoid this. Both call and return lists may
contain as many or as few scalar elements as you'd like.
(Often a function without an explicit return statement is
called a subroutine, but there's really no difference from
the language's perspective.)
Any arguments passed to the routine come in as the array @_.
Thus if you called a function with two arguments, those
would be stored in $_[0] and $_[1]. The array @_ is a local
array, but its elements are aliases for the actual scalar
parameters. In particular, if an element $_[0] is updated,
the corresponding argument is updated (or an error occurs if
it is not updatable). If an argument is an array or hash
element which did not exist when the function was called,
that element is created only when (and if) it is modified or
if a reference to it is taken. (Some earlier versions of
Perl created the element whether or not it was assigned to.)
Note that assigning to the whole array @_ removes the
aliasing, and does not update any arguments.
. . .
Use array assignment to a local list to name your formal
arguments:
sub maybeset {
my($key, $value) = @_;
$Foo{$key} = $value unless $Foo{$key};
}
This also has the effect of turning call-by-reference into
call-by-value, because the assignment copies the values.
Otherwise a function is free to do in-place modifications of
@_ and change its caller's values.
upcase_in($v1, $v2); # this changes $v1 and $v2
sub upcase_in {
for (@_) { tr/a-z/A-Z/ }
}
You aren't allowed to modify constants in this way, of
course. If an argument were actually literal and you tried
to change it, you'd take a (presumably fatal) exception.
For example, this won't work:
upcase_in("frederick");
HTH.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 10 Nov 1999 18:57:11 -0000
From: "Nobody" <nobody@logica.com>
Subject: grep problem
Message-Id: <80cf68$jkk@romeo.logica.co.uk>
I am using the following command in two versions of perl :
$results = grep (!/^#/, $output);
where $output is a string
In perl 4 it runs but in perl 5 it doesn't seem to work ...
Any ideas ???
------------------------------
Date: 10 Nov 1999 10:38:48 -0600
From: Tye McQueen <tye@metronet.com>
Subject: Re: Help Needed in Win32::API
Message-Id: <80c72o$8qv@beanix.metronet.com>
[Posted and e-mailed.]
Ismail Mohideen <Ismail_Mohideen@amsinc.com> writes:
)
) $setMRT = new Win32::API("D:/Program Files/Microsoft Visual
) Studio/MyProjects/mrtdll/Debug/mrtdll","RSSetMRTName",[P,N],N);
Win32::API calls C<LoadLibrary> and the Microsoft documentation
for that function says:
If the string specifies a path but the file does not exist in
the specified directory, the function fails. When specifying a
path, be sure to use backslashes (\), not forward slashes (/).
If a path is not specified and the filename extension is
omitted, the default library extension .DLL is appended.
However, the filename string can include a trailing point
character (.) to indicate that the module name has no extension.
So change your C<"/">s to C<"\\">s and add C<".dll"> [the above is
not completely clear, but I infer that if you include a path then
the default C<".dll"> is not appended for you].
Be a good citizen and add this information to the documentation
for the module and forward your changes as a patch to the module's
author to save the next person some grief.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Wed, 10 Nov 1999 17:09:16 -0000
From: "Chris" <chris@chrismail.connectfree.co.uk>
Subject: Help woth perl
Message-Id: <3829b4ad.0@news2.cluster1.telinco.net>
I have made some changes to the help I was last given like putting html in
and it dosen't work plus the other file hasn't been helped with the files
are below ( I have maked my changes) HELP ME PLEASE!!
sign_up.pl ----
#########################
#!/usr/bin/perl -wT
use strict;
use CGI qw(:standard);
use Fcntl qw(:flock);
$ENV{qw(PATH IFS)} = '' x 2;
my $url = param('url');
my $forward = param('forward');
my $email = param('email');
open(success,"success.fil")
{
flock(success,LOCK_SH) || die "Can't lock 'success.fil - $!\n"; #
opening a html file in fil form
my $success= do { local $/; <success> }; # and putting in to $success
close(success);
}
open(taken,"taken.fil")
{
flock(taken,LOCK_SH) || die "Can't lock 'taken.fil - $!\n"; # same but
with different
my $unvailible= do { local $/; <taken> }; # file and putting into
$unvailible
close(taken);
}
open(message,"message.fil")
{
flock(message,LOCK_SH) || die "Can't lock 'fils/$url.fil - $!\n"; # same
again
my $message= do { local $/; <message> };
close(message);
}
if ( open(UINFO,"fils/$url.fil") )
{
flock(UINFO,LOCK_SH) || die "Can't lock 'fils/$url.fil - $!\n";
my $test= do { local $/; <UINFO> };
close(UINFO);
if ($test eq ":-:\n$forward")
{
print"$unvailible"; # printing what read from file above
}
}
else
open(URLS,">fils/$url.fil") || die "Can't open 'fils/$url.fil - $!\n";
flock(URLS,LOCK_EX) || die "Can't flock 'fils/$url.fil - $!\n";
print URLS ":-:\n$forward";
close(URLS);
my $from = 'kieran@bl-soft.com';
my $sub = 'Your Exclamation website is up and running';
email($email,$from,$sub,$message);
print "$success"; # printing from file above
}
sub email
{
my ($to,$from,$sub,$message) = @_;
open(MAIL, "|/var/qmail/bin/qmail-inject -t") || die
"Content-type: text/plain\n\nCan't open
qmail-inject -$!\n";
print MAIL <<EOMAIL;
To: $to
From: $from
Subject: $sub
$message
EOMAIL
return close(MAIL);
}
forward.pl --------
#####################
#!/usr/local/bin/perl
&readparse;
###############################################
$forsite=$value[0];
open(BOOK,"</fils/$forsite.fil");
$redir=<BOOK>;
close(BOOK);
if ($redir eq "") {
print '
<HTML>
<HEAD>
<TITLE>EXCLAMATION!</TITLE>
</HEAD>
<BODY BGCOLOR="BLACK">
<center>
<FONT COLOR="ORANGE">
EXCLAMATION!<p>
<H1>Sorry page not found</H1><p>
To register this domain with EXCLAMATION <A
HREF="http://blsoftpart.hypermart.net/sign_up.html">Click Here</A><p>
<A HREF="exclamation.html">Click Here</A> to go to exclamations main
site.<p>
<A HREF="http://www.bl-soft.com/">Click Here</A> to visit Bl-Soft (The
company who made this).<p>
<A HREF="http://www.free-address.com/">Click Here</A> to visit free-address
(Another part of the company).
</FONT>
</BODY>
</HTML>
';
}
else {
print "Location: $redir\n\n";
}
###############################################
sub readparse {
read(STDIN,$user_string,$ENV{'CONTENT_LENGTH'});
if (length($ENV{'QUERY_STRING'})>0) {$user_string=$ENV{'QUERY_STRING'}};
$user_string =~ s/\+/ /g;
@name_value_pairs = split(/&/,$user_string);
foreach $name_value_pair (@name_value_pairs) {
($keyword,$value) = split(/=/,$name_value_pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge;
push(@value, "$value");
$user_data{$keyword} = $value;
if ($value=~/<!--\#exec/) {
print "Content-type: text/html\n\nNo SSI permitted";
exit;
};
};
};
--
Chris
chris@chrismail.connectfree.co.uk
www.bl-soft.com/chrissite
------------------------------
Date: Wed, 10 Nov 1999 17:48:13 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Help woth perl
Message-Id: <xdiW3.64093$23.2520922@typ11.nn.bcandid.com>
In article <3829b4ad.0@news2.cluster1.telinco.net>,
Chris <chris@chrismail.connectfree.co.uk> wrote:
>I have made some changes to the help I was last given like putting html in
>and it dosen't work
You mean you say:
$ perl sign_up.pl
and it says:
sign_up.pl: sign_up.pl doesn't work. Compilation aborted.
$
?
>plus the other file hasn't been helped with the files
>are below ( I have maked my changes) HELP ME PLEASE!!
I don't have time to read 150 lines of somebody else's code and guess at what's wrong.
>open(success,"success.fil")
> {
Hmm, you left out a semicolon after the ), and you have a spurious {} block.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 10 Nov 1999 10:04:49 -0700
From: Chris <koharik@primenet.com>
Subject: Re: how to convert <br> to "newline"
Message-Id: <Pine.BSI.3.96.991110100137.9430A-100000@usr06.primenet.com>
> Date: Wed, 10 Nov 1999 17:03:28 GMT
> From: Samadhi <samadhi@latinmail.com>
>
> Hi, I want to convert a string like
> this:"sample_lin_01<br>sample_lin_02<br>etc" in this other (to send a
> e-mail):
> sample_lin_01
> sample_lin_02
> etc
>
> can you help me please please please please?
>
> many many many thanks, I am despaired...
This should be fairly simple. Here is an example:
#!/bin/perl -w
use strict;
my $string = "sample_lin_01<BR>sample_lin_02<BR>etc";
$string =~ s/<BR>/\n/g;
print $string;
Cheers,
-Chris
------------------------------
Date: Wed, 10 Nov 1999 13:45:48 -0500
From: "Thomas B. Holdren" <bholdren@NOSPAMMY.linkohio.com>
Subject: Re: how to convert <br> to "newline"
Message-Id: <a6jW3.13$Wt1.464@wdc-read-01.qwest.net>
Samadhi,
> Hi, I want to convert a string like
> this:"sample_lin_01<br>sample_lin_02<br>etc" in this other (to send a
> e-mail):
> sample_lin_01
> sample_lin_02
> etc
Look up the docs on matching and substitution. Or, look here for the simple
answer:
my $string = "hi<BR>what<BR>do you mean?";
$string =~ s/<BR>/\n/gi;
produces
hi
what
do you mean?
I figured since I just asked a newbie question I'd help this one :-)
----------
Thomas B. Holdren, Systems Administrator
Linux/OSS Advocate
RMS Fan (GO RMS LINUX!)
"If you can't beat 'em, emulate 'em!"
-JLL
------------------------------
Date: Wed, 10 Nov 1999 17:51:56 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: how to parse dir recursively for files?
Message-Id: <0hiW3.64137$23.2521294@typ11.nn.bcandid.com>
In article <3829832E.5E8C447C@home.com>,
Darrin H <dthusma@home-del.com> wrote:
>mirranda@my-deja.com wrote:
>> guys,
>> I need to get every file in every directory uner "my directory" that has
>> ".abc" extension and store it into an array.
>>
>> This is how far i got. But I just get the directory names and not the
>> files.
>>
>> @ARGV = qw(.) unless @ARGV;
>> use File::Find ();
>
>Try readdir. Here is a two-level deep example:
This is bad advice.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 10 Nov 1999 17:53:14 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: I guess this should not happen
Message-Id: <80cbea$gve$1@pegasus.csx.cam.ac.uk>
Friedrich Dominicus <Friedrich.Dominicus@inka.de> wrote:
>It's just a guess and I just found out by accident. I was running a
>recursive
>version of the fibonacci numbers. And between 25 and 30 on my computer
>Perl seems to get a bit confused or so. The memory consumption raises
>above 100!!! MB and that is quite much. I do know that this is as
>inefficient as can be but Perls consumes a bunch of time
>
>Here's the source:
>
> sub fib {
> local($n)=@_;
> if( $n<2 ){
> return $n;
> } {
> return fib($n-2)+ fib($n-1)
> }
> }
>
> print &fib(29), "\n";
>
>Please don't tell me that I have to use another implementation I know
>that I have to I just want to ask if this is a known problem or not.
The space leak doesn't happen in versions of Perl 5.005+. It does
happen in all versions of 5.004, including 5.004_05.
So it's probably not a known problem (or it would have been fixed
in perl5.004_05). OTOH since it doesn't occur in the Perl which has
been current for more than a year, I doubt anyone will be interested.
Just upgrade to the current Perl.
Mike Guy
------------------------------
Date: 10 Nov 1999 17:26:47 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Is $$variable allowed like in PHP ?
Message-Id: <80c9sn$ffg$1@pegasus.csx.cam.ac.uk>
Ben Evans <bene@chiark.greenend.org.uk> wrote:
>
>Why are soft references considered a Bad Idea?
http://www.plover.com/~mjd/perl/varvarname.html
http://www.plover.com/~mjd/perl/varvarname2.html1
Mike Guy
------------------------------
Date: Wed, 10 Nov 1999 05:50:59 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Is $$variable allowed like in PHP ?
Message-Id: <slrn82ijgj.r3f.tadmc@magna.metronet.com>
On Wed, 10 Nov 1999 04:19:31 -0500, Tad McClellan <tadmc@metronet.com> wrote:
> $string =~ s/\$(.*)/$xref{dog}/; # look ma, no global variables :-)
^^^
Uhhh, errr, that is Not So Good.
$string =~ s/\$(.*)/$xref{$1}/;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 10 Nov 1999 17:27:45 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: MP3.pm - play/control your mpeg music via perl
Message-Id: <pudge-1011991227490001@192.168.0.77>
In article <38285FFB.5DEBD0C2@sietec.de>, Murat Uenalan
<murat.uenalan@sietec.de> wrote:
# But unfortunately not a win32 version ?! Could someone help me ?
Start writing one!
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Wed, 10 Nov 1999 17:41:04 GMT
From: Shmooth <shmooth@yahoo.com>
Subject: Re: Multiple cookies question with CGI.pm?
Message-Id: <3829AEEF.A85E57@yahoo.com>
I haven't figured out the CGI.pm/multiple cookies problem, but I've got a
workaround - I generate the cookies using CGI.pm and send then out myself
manually (print "Set-cookie: $myCookie\n").
On a somewhat related topic, I've learned that Netscape browser (version
4.7 on WinNT) doens't recognize multiple 'set-cookie' headers when they
originate from 'localhost'.
Shmooth wrote:
> I've been using the function-oriented call of CGI.pm to send multiple
> cookies back to the browser/client, but it seems to chop the 1st cookie
> and only sends the second. This remains true whichever order I put the
> cookies in. I've verified they're definitely there. I've tried
> alternate syntaxes but nothing seems to go. I don't really understand
> the CGI.pm/Cookie.pm code, else I'd try to troubleshoot it myself. Any
> ideas on what I could be doing wrong? Maybe I *have* to use the object
> interface?? I'm on Win32 (more build info at bottom).
>
> #Here's my call - only $cookie2 gets spit out
> # I've also tried using multiple '-cookie' headers, '-set_cookie'
> headers, etc.
> print header(-cookie=>[$cookie1,$cookie2]);
>
> Thanks. (build info below)
>
> -------------------------------------------------------------------
> This is perl, version 5.005_03 built for MSWin32-x86-object
> (with 1 registered patch, see perl -V for more detail)
>
> Binary build 518 provided by ActiveState Tool Corp.
> http://www.ActiveState.com
> Built 13:14:00 Jun 24 1999
> -------------------------------------------------------------------
------------------------------
Date: Wed, 10 Nov 1999 10:50:15 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Multiplexing Server
Message-Id: <x3yg0yez6q1.fsf@tigre.matrox.com>
Curtis Jones <curtisj@BannerFusion.com> writes:
> I had a piece of server software written in Perl, which used forks to
> allow for multiple simultaneous connections, but after a while, I
> realized I really needed a multiplexing server. It now uses IO::Select to
> check for an incoming connection, and process it without blocking other
> processes.
Good. I really like IO::Select. It makes life much simpler.
> Anyway - I need to be able to get the IP address of the client
> who is connecting to the server, and I can't seem to figure it out.
I stole the idea of the following little subroutine from perlfaq9:
How do I find out my hostname/domainname/IP address?
Here's the subroutine:
sub get_host_info {
my $socket = shift;
my $hersockaddr = getpeername $socket;
my ($port, $heraddr) = unpack_sockaddr_in($hersockaddr);
my $herhostname = gethostbyaddr($heraddr, AF_INET);
my $herstraddr = inet_ntoa($heraddr);
return ($herhostname, $herstraddr);
}
HTH,
--Ala
------------------------------
Date: Wed, 10 Nov 1999 19:01:49 +0100
From: "Thomas Schmickl" <schmickl@magnet.at>
Subject: OO question again
Message-Id: <80cc22$3do$2@newsmaster01.magnet.at>
I have mixed OO / Tk question:
I have now written Get/Set methods instead of direct attribute access.
But some Tk widgets need references to variables passed in their constructors.
Before restructuring I had used ... -textvariable=>\$self->{'filename'} ...
but now I have $self->filename() which returns the value of $self->{'filename'}.
How can I handle this thing.
Of course I could make a second method called $self->ref_filename() which deals with the reference, but this seems silly to me. So
..... do you have any ideas ???
Thanx again, thomas.
----------------------------------------------------
Thomas Schmickl,
Department for zoology
Karl Franzens University Graz, Austria.
----------------------------------------------------
Visit the GPL e:doc-project on http://members.magnet.at/hfbuch/edoc
or mail me at schmickl@magnet.at
----------------------------------------------------
------------------------------
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 1340
**************************************