[12945] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 355 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 3 21:07:18 1999

Date: Tue, 3 Aug 1999 18:05:13 -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           Tue, 3 Aug 1999     Volume: 9 Number: 355

Today's topics:
    Re: [was]Re: reg expression (Abigail)
    Re: Adding time (elephant)
    Re: Adding time (Larry Rosler)
        Autovivification? <neal@nsdev.org>
    Re: beginners question on comma delimeted files - (Abigail)
        Can I use a variable as a file descriptor ? <dja7@jps.net>
    Re: can Perl send e-mail with attached files? <makarand_kulkarni@my-deja.com>
    Re: Can perl use if control statement in other if contr (Abigail)
        DBM: delete hash but the file size doesn't decrease <zeng@stat.Berkeley.EDU>
        download available <dalleyjo@pilot.msu.edu>
    Re: formular data problem with Active Perl/NT (elephant)
    Re: Getting Date from HTTP::Response <gisle@aas.no>
    Re: Good method of "locking" (Jon Bell)
    Re: help with find command <makarand_kulkarni@my-deja.com>
    Re: help with find command (Martien Verbruggen)
    Re: How can I know what modules are installed on server (Abigail)
    Re: How can I know what modules are installed on server (Malcolm Ray)
    Re: How can I trap/block a kill -9 signal (Abigail)
    Re: How to compare two files and get the differences ? (Abigail)
    Re: how to remove cr/lf ??? (elephant)
    Re: how to remove cr/lf ??? (elephant)
    Re: how to remove cr/lf ??? (elephant)
    Re: how to remove cr/lf ??? (Larry Rosler)
    Re: how to remove cr/lf ??? (elephant)
    Re: How? (Bob Trieger)
    Re: looking for XML comments (elephant)
    Re: mySql & Perl -> Something simple <makarand_kulkarni@my-deja.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 3 Aug 1999 19:16:15 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: [was]Re: reg expression
Message-Id: <slrn7qf1hb.s67.abigail@alexandra.delanet.com>

llornkcor (llornkcor@llornkcor.com) wrote on MMCLXIII September MCMXCIII
in <URL:news:7o7n7c$k8o$1@oak.prod.itd.earthlink.net>:
&& 
&& > Way too many. Got any solutions for exterminating those pesky people
&& > that ask questions that trigger rude responses?
&& 
&& well, you COULD ignore them...
&& why not try that for a change?


Do you have any suggestions as what to put in my killfile that ignores
them? Because, due to lack of a timemachine, first reading the posting
and then ignoring them doesn't work.



Abigail
-- 
perl -wlne '}for($.){print' file  # Count the number of lines.


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Wed, 4 Aug 1999 10:05:38 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Adding time
Message-Id: <MPG.12122ee13f64801a989bd2@news-server>

Murali V writes ..
>How do I add 2 hours to the epoch time with perl.

I think another poster may have missed the word 'epoch' in there

but I'm not sure if you know what epoch means .. but assuming you do you 
can return a date string 2 hours past the epoch with one of these 
(depending on whether you want the GMT or your local time adjusted for 
your timezone)

  my $gmtime = gmtime( 60 * 60 * 2);
  my $localtime = localtime( 60 * 60 * 2);

strictly speaking - to my knowledge - there's no way to add time to the 
epoch .. ie. there's no builtin variable called $EPOCH that you can 
adjust in order to affect all generated times

-- 
 jason - elephant@squirrelgroup.com -


------------------------------

Date: Tue, 3 Aug 1999 17:46:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Adding time
Message-Id: <MPG.12112d4e4019b18c989dab@nntp.hpl.hp.com>

In article <MPG.12122ee13f64801a989bd2@news-server> on Wed, 4 Aug 1999 
10:05:38 +1000, elephant <elephant@squirrelgroup.com> says...
> Murali V writes ..
> >How do I add 2 hours to the epoch time with perl.
> 
> I think another poster may have missed the word 'epoch' in there
> 
> but I'm not sure if you know what epoch means .. but assuming you do you 
> can return a date string 2 hours past the epoch with one of these 
> (depending on whether you want the GMT or your local time adjusted for 
> your timezone)
> 
>   my $gmtime = gmtime( 60 * 60 * 2);
>   my $localtime = localtime( 60 * 60 * 2);

Well, you have chosen to be pedantic, so you might as well be correct.  
I'm not sure if you know what 'epoch' means.

The term '[Unix] epoch time' means time relative to the [Unix] Epoch.  
The Unix Epoch is 1970-01-01 00:00:00 UTC.  The 'epoch time' is now 
about 933727500 seconds.

To add 2 hours, you do this:

    $new_time = 2 * 60 * 60 + time;

Got it?

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Wed, 04 Aug 1999 00:34:27 +0000
From: Neal Sanche <neal@nsdev.org>
Subject: Autovivification?
Message-Id: <37A78A93.783DD88E@nsdev.org>

Hi All,

I'm running perl 5.004_04, which may be somewhat behind the times, but I
think this 'effect' still exists. It is similar to some entries in the
FAQ, but I'm still not sure why this is happening. Can someone explain
it to me?

#!/usr/bin/perl -w

  if (defined $OOPS{test}{notthere}) {
                print "OOPS!\n";
  } elsif (defined $OOPS{test}{notthere}{really}) {
                print "OOPS! Not again!\n";
  } elsif (defined $OOPS{test}{notthere}) {
                print "You're not going to believe this!\n";
  }

Thanks for any replies. Please courtesy copy me, since I am a very
infrequent newsgroup reader. Thanks!

-Neal

--
+-------- Neal Sanche +----+ [ neal@nsdev.org ] +------ ICQ 5516171 ------+

 I am a deeply superficial person.
                -- Andy Warhol





------------------------------

Date: 3 Aug 1999 19:18:11 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: beginners question on comma delimeted files -
Message-Id: <slrn7qf1kv.s67.abigail@alexandra.delanet.com>

Alec Kelingos (akelingos@petrosys-usa.com) wrote on MMCLXIII September
MCMXCIII in <URL:news:01beddbc$8dbe4640$0664a8c0@psusa6.petrosys-usa.com>:
== 
== Records will look like the following:
== 
== 12345,"string data","string data with a , in it",6875,"another, string"\n
== 
== Notice that commas bounded by double quotes are actual data and not
== delimiters.  Are there any prebuilt functions or will I have to write
== something?


I suggest writing something yourself. After all, you don't read the
documents that will explain things to you, so you aren't that interested
in using prebuilt functions. Else, you would have read that long time ago.

Good luck writing, and don't bother to ask here if you get stuck.



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Tue, 03 Aug 1999 17:06:40 -0700
From: dja7 <dja7@jps.net>
Subject: Can I use a variable as a file descriptor ?
Message-Id: <37A78410.8D710E2F@jps.net>

If so, do I have to do anything more than define the variable ?

e.g. local($fd);  ??


Here is a paraphrased snippet of code from 
"Programming Perl" by Wall, Schartz 
published by O'Reilly & Assoc 1992

This is supposed to be a server daemon that listens on sockets and
spawns services as client connections come in

sub spawn{
local($service)=@_;
local($fd);
accept($fd,$service);
$pid=fork;
 ..
 ..
}

It always fails on the accept statement.   Carp says, "Bad symbol for
filehandle" 

What gives ?   Can I get away with using a literal here or would I have
to fork first ?  should I or can I localize a literal filehandle ?  
like, local(FD) ?   wouldn't that literal be pointing to the same
filehandle everytime the spawn subroutine is called ?


Why do they publish an example that doesn't work ?  Can anyone recommend
some books on using Perl to implement socket connections ?


------------------------------

Date: Tue, 03 Aug 1999 23:44:13 GMT
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
Subject: Re: can Perl send e-mail with attached files?
Message-Id: <7o7usb$b8a$1@nnrp1.deja.com>


>But is there a way to
> attach a separate file (ascii or binary) to an e-
> mail sent using Perl?

yes. This topic has been covered to death
in an excellent article in the lastest
issue or The Perl Journal (summer 1999).
Buy it.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: 3 Aug 1999 19:19:45 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Can perl use if control statement in other if control statement?
Message-Id: <slrn7qf1nt.s67.abigail@alexandra.delanet.com>

Carfield Yim (c8133594@comp.polyu.edu.hk) wrote on MMCLXIII September
MCMXCIII in <URL:news:37A6EA56.2C743DE5@comp.polyu.edu.hk>:
 .. Can perl use if control statement in other if control statement?
 .. i.e.: if (...) {
 ..  if (...){...}
 ..  else (...){...}
 ..  } elsif ....
 .. 
 .. I think it should be okay,

It is.

 .. but I have compile time error of this, then I take a look of perlman,
 .. there are no example of this. Is it illegal in perl?

You probably have some kind of error.



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Tue, 3 Aug 1999 17:00:30 -0700
From: Bin Zeng <zeng@stat.Berkeley.EDU>
Subject: DBM: delete hash but the file size doesn't decrease
Message-Id: <Pine.SOL.4.10.9908031650380.11041-100000@sauron.Berkeley.EDU>

A question about a DBM:

Create a DBM file, so I got file.dir and file.pag with a nonzero size. In
a second program, I call up this DBM, use the function 'delete' to delete
every pair from the hash. I suppose the DBM should be empty by now. Two
methods have been used to verify this. In a third program, I call up the
DBM, no key or value is found. I also use a command in UNIX, called
'makedbm -u file > newfile', the newfile is empty.

Now is the surprising part. When I use the 'ls -l', I found the size of
the file.dir and file.pag is still the same as before I do any 'delete'.

What gives?

Thanks.

Z.



------------------------------

Date: Tue, 03 Aug 1999 19:30:23 -0400
From: Joel <dalleyjo@pilot.msu.edu>
Subject: download available
Message-Id: <37A77B8E.BB9DC05B@pilot.msu.edu>

The Goods is a cool web application that runs on UNIX systems.  It comes

with an installer script to basically automate the install process,
which
is very painless.  I wrote it in Perl, so you can always go into the
program file and make any changes you desire.  Overall, i think it's
pretty
cool. it's kind of like .htaccess on hyper-steroids.  It has some cool
features .htaccess lacks, particularly flexibilty and centralized
management via web interface.  The program can be downloaded from

       http://dalleyjo.user.msu.edu/cgi-bin/goods/goods_home.cgi

- Joel Dalley,   wannabe Perl hacker



------------------------------

Date: Wed, 4 Aug 1999 10:12:29 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: formular data problem with Active Perl/NT
Message-Id: <MPG.1212307b5b1696d5989bd3@news-server>

Andre Probst writes ..
>read( STDIN, $buf, $ENV{'CONTENT_LENGTH'} );
>%FELDER = &parse_cgi( $buf );

for a start this is not the best way to do this .. you should be using 
the CGI module which came with your distribution .. for more information 
- at the command prompt run

  perldoc CGI

>I am using Apache 1.3.6. Is it misconfigured ?
>What could I change ?

assuming that there was no other change from moving your script from 
Linux to NT - it would seem like the obvious conclusion .. but this 
newsgroup has no expertise in apache

you are lucky though .. because the ActiveState people were at their 
mind-reading best when they wrote the documentation that you have on your 
computer .. I suggest you read perlwin32faq6 (Web Server Config) in which 
this very question is asked and answered

-- 
 jason - elephant@squirrelgroup.com -


------------------------------

Date: 04 Aug 1999 01:33:46 +0200
From: Gisle Aas <gisle@aas.no>
Subject: Re: Getting Date from HTTP::Response
Message-Id: <m3d7x4782t.fsf@eik.g.aas.no>

lr@hpl.hp.com (Larry Rosler) writes:

> In article <m3n1w87f3x.fsf@eik.g.aas.no> on 03 Aug 1999 23:01:54 +0200, 
> Gisle Aas <gisle@aas.no> says...
> ...
> >    print localtime($response->date), "\n";
>           ^
>           scalar ??? 

Probably a good idea.

-- 
Gisle Aas


------------------------------

Date: Tue, 3 Aug 1999 23:11:21 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Good method of "locking"
Message-Id: <FFwwEx.28v@presby.edu>

  <kirk@kaybee.org> wrote:
>I have a program and I need to make sure that only one instance is ever
>run at the same time.  
[snip]
>I was thinking of (on Linux primarilly) opening the program's config
>file and then calling 'flock' on it.  If I get an exclusive lock, then
>all is good and I unlock it on exit.  I assume that if the program exits
>abnormally, the lock will also be released.  If I don't get a lock, I
>quit because it means another process is running.
>
>Does this sound like a good way of doing it? 

Yes.  It's so good, in fact, that Perl has a built-in 'flock' function
that calls Linux flock for you (and does something similar on other
platforms, too).  For details, do a 

   perldoc perlfaq5

and look for the entry "How can I lock a file?"; and a

   perldoc perlfunc

and look for the entry on 'flock'.

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA
        [     Information about newsgroups for beginners:     ]            
        [ http://www.geocities.com/ResearchTriangle/Lab/6882/ ]


------------------------------

Date: Tue, 03 Aug 1999 23:48:18 GMT
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
Subject: Re: help with find command
Message-Id: <7o7v3v$bav$1@nnrp1.deja.com>


> I can put it in my perl script?  Thanks in advance...

Better still..use File::Find;


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Wed, 04 Aug 1999 00:27:07 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: help with find command
Message-Id: <vNLp3.107$m62.5124@nsw.nnrp.telstra.net>

In article <7o7nvu$692$1@nnrp1.deja.com>,
	mr_potato_head@my-deja.com writes:

>    Can anyone tell me how to convert this csh command line into perl so

That is not a csh command.

> I can put it in my perl script?  Thanks in advance...
> 
> find /u1 -name "*99*" -mtime +3 -exec rm -r {} \;

You can use system, or qx() or backticks, but even better: Have a look
at the File::Find module and the find2perl script. Both should have
been installed with perl.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd.       | password?
NSW, Australia                      | 


------------------------------

Date: 3 Aug 1999 18:10:20 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How can I know what modules are installed on server?
Message-Id: <slrn7qetlo.s67.abigail@alexandra.delanet.com>

99% Energy (Spam@IsBadForTheInternet.com) wrote on MMCLXIII September
MCMXCIII in <URL:news:fEIp3.3575$k8.158356@newscene.newscene.com>:
&& I don't think is such a bad idea to quote the entire article when replying
&& in newsgroups. A lot of NNTP servers don't get all the messages so its nice
&& to see what the reply is about when you don't get the whole thread.

I suggest everyone mails the entire content of comp.lang.perl.misc to
99% Energy, cause NNTP servers don't get all the messages, so it's nice
he can read the threads.

There's still no point in quoting the sig and advertisement. You're just
dumb and lazy.

&& I also always put the reply before the quote because its a nuisance to have
&& to scroll to the bottom, specially in long messages, for both replying and
&& seeing the message. The quote is mostly for the benefit of those who haven't
&& seen the whole thread as I explained in the first paragraph.

That's why people with an IQ over 20 (not you!) interweave their replies
with the parts they reply to. 


You're just a moron. On top of that, you munge your address. Which makes
you a wussie as well.


*ploink*



Abigail
-- 
sub J::FETCH{Just   }$_.='print+"@{[map';sub J::TIESCALAR{bless\my$J,J}
sub A::FETCH{Another}$_.='{tie my($x),$';sub A::TIESCALAR{bless\my$A,A}
sub P::FETCH{Perl   }$_.='_;$x}qw/J A P';sub P::TIESCALAR{bless\my$P,P}
sub H::FETCH{Hacker }$_.=' H/]}\n"';eval;sub H::TIESCALAR{bless\my$H,H}


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: 3 Aug 1999 23:44:30 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: How can I know what modules are installed on server?
Message-Id: <slrn7qevmu.1ao.M.Ray@carlova.ulcc.ac.uk>

On 3 Aug 1999 15:53:06 -0500, 99% Energy <Spam@IsBadForTheInternet.com> wrote:
>I don't think is such a bad idea to quote the entire article when replying
>in newsgroups. A lot of NNTP servers don't get all the messages so its nice
>to see what the reply is about when you don't get the whole thread.

How thoughtful.  Perhaps you could consider including the text of the
previous half-dozen messages too, when they help to establish context.

>I also always put the reply before the quote because its a nuisance to have
>to scroll to the bottom, specially in long messages, for both replying and
>seeing the message. The quote is mostly for the benefit of those who haven't
>seen the whole thread as I explained in the first paragraph.

The quality of the trolls certainly is declining around here.  Bring
back topmind!

Then again, maybe you're for real.  I recently replied (by mail) to a
query from a user, quoting the appropriate parts of his message in
the sensible way.  He didn't reply for more than a week, though it was
supposedly an urgent matter.  When he did so, he said "sorry for not
replying sooner, but I didn't see your reply because I'd have had to
scroll".  That's the danger of this ridiculous arse-about-face quoting
style.  The lusers become conditioned to regard quoted text as something
they can ignore.  As soon as they see it, they think "duh, I can stop
reading now", and both their neurons shut down.  I wonder whether this
could be exploited for subliminal advertising?
-- 
Malcolm Ray                           University of London Computer Centre


------------------------------

Date: 3 Aug 1999 19:48:44 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How can I trap/block a kill -9 signal
Message-Id: <slrn7qf3e7.s67.abigail@alexandra.delanet.com>

Ming (fungs@logica.com) wrote on MMCLXIII September MCMXCIII in
<URL:news:7o6cqr$k3b@romeo.logica.co.uk>:
;; Hello all
;; 
;; Does anyone out there know how to trap/ignore a 'kill -9' signal for a Perl
;; process.


Sure. Get the sources of your kernel, and change the way signals are handled.

The fact that kill -9 is untrappable is a _feature_.



Abigail
-- 
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: 3 Aug 1999 18:14:45 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How to compare two files and get the differences ?
Message-Id: <slrn7qetu0.s67.abigail@alexandra.delanet.com>

Yeong Mo/Director Hana co. (factory@factory.co.kr) wrote on MMCLXIII
September MCMXCIII in <URL:news:7o7pjc$3ht$1@news1.kornet.net>:
,, Thank you and sorry for bother all you guys.
,, Unfortunatly, It is too hard for me. I can't handle this through your
,, directions.
,, Let me get more advice for this , please.

Here's some more advice, specially for you:

    - Hire professional help!
    - Hire someone with a clue!
    - Step away from the keyboard!



Abigail
-- 
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Wed, 4 Aug 1999 09:06:20 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: how to remove cr/lf ???
Message-Id: <MPG.121220f580561b73989bcd@news-server>

Philip 'Yes, that's my address' Newton writes ..
>elephant wrote:
>> 
>> Dan Wilga writes ..
>> >(This assumes your machine treats \n as CR-LF. This is the case if
>> >you're on a PC.)
>> 
>> a PC ? .. so you mean if I run Linux or NT on my PC then my line
>> endings are still the same as DOS ?
>
>If you run NT, then yes. Of course. NT, Win9* and DOS all use crlf for
>line endings.

if you have any documentation supporting your CRLF claim for NT then I'd 
like to see it .. in the absence of any I did some tests - have you 
tested this yourself ? .. it appears to use LF only

in fact .. it does use LF only .. it understands CR+LF .. but if you open 
something with Notepad on NT and type some lines and hit your Return key 
at the ends of them .. then check the files .. they've only got LFs

-- 
 jason - elephant@squirrelgroup.com -


------------------------------

Date: Wed, 4 Aug 1999 09:14:41 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: how to remove cr/lf ???
Message-Id: <MPG.121222f092ade7fd989bce@news-server>

Bart Lateur writes ..
>elephant wrote:
>
>>>(This assumes your machine treats \n as CR-LF. This is the case if you're
>>>on a PC.)
>>
>>a PC ? .. so you mean if I run Linux or NT on my PC then my line endings 
>>are still the same as DOS ? .. oh man - what a ripoff - I'm taking this 
>>thing back
>
>You're easily disturbed, if a change in definition of line endings
>bothers you that much.

I hope you're joking as much as I was

my disappointment was feigned in order to bring humour into the comment - 
with the noble hope of making Dan Wilga think about what they write a bit 
more before writing it .. inaccuracies are useless

-- 
 jason - elephant@squirrelgroup.com -


------------------------------

Date: Wed, 4 Aug 1999 09:23:23 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: how to remove cr/lf ???
Message-Id: <MPG.121224f8c1c08fa6989bcf@news-server>

S Jagadish writes ..
>> $outbuffer =~ s/\n/;/g;
>> print FILETO $outbuffer;
>> 
>> (This assumes your machine treats \n as CR-LF. This is the case if you're
>> on a PC.)
>
>my machine seems to treat cr-lf as \r so i guess
>s/\r\n/\n/g; would be ok too

I doubt that any machine treats CRLF as "\r" .. machines talking DOS will 
map "\n" to CRLF .. and other machines map "\n" to other things .. this 
makes the use of "\n" to match one character a dangerous thing if the 
script is EVER going to be used on another platform

you can see that your substitution

  s/\r\n/\n/g;

will change any CRLFs into LFs on a UNIX machine .. but on a DOS machine 
will only match CRCRLFs

now .. this may actually be what you want .. because clearly then the 
CRLFs will be left alone on DOS .. but as long as you are away of the 
different circumstances .. I think on Macintosh it will match CRLFCRs .. 
in which case it will leave the CRLFs which are NOT the Macintosh line 
endings (to my knowledge)

>interestingly this seems to happen most when i use a textarea field
>to get input

most network communication will end lines with CRLFs .. because the 
textarea field is being transmitted across the network then the line 
endings that a user enters in that field will be transmitted as CRLFs .. 
the best way to get rid of these is something like this

  s/\cM\cJ/\n/g;

or numerically as

  s/\015\012/\n/g;

this will substitute the known CRLF character sequence in the stream for 
the unknown (and dynamic) line ending sequence for the machine that the 
code is running on

-- 
 jason - elephant@squirrelgroup.com -


------------------------------

Date: Tue, 3 Aug 1999 16:54:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how to remove cr/lf ???
Message-Id: <MPG.1211211c83b97db7989daa@nntp.hpl.hp.com>

In article <MPG.121220f580561b73989bcd@news-server> on Wed, 4 Aug 1999 
09:06:20 +1000, elephant <elephant@squirrelgroup.com> says...
 ...
> if you have any documentation supporting your CRLF claim for NT then I'd 
> like to see it .. in the absence of any I did some tests - have you 
> tested this yourself ? .. it appears to use LF only
> 
> in fact .. it does use LF only .. it understands CR+LF .. but if you open 
> something with Notepad on NT and type some lines and hit your Return key 
> at the ends of them .. then check the files .. they've only got LFs

That is contrary to my experience and expectation.  How did you check 
the files?  If you used a Perl program, unless you binmode()ed the 
files, the I/O system will convert CR+LF to LF.

You might also compare the size of the file with the length of a string 
into which the whole file is read (using 'local $/;').  If they are the 
same, you are right.  But they won't be.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Wed, 4 Aug 1999 10:41:43 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: how to remove cr/lf ???
Message-Id: <MPG.1212374efd7b559c989bd5@news-server>

Larry Rosler writes ..
>That is contrary to my experience and expectation.  How did you check 
>the files?  If you used a Perl program, unless you binmode()ed the 
>files, the I/O system will convert CR+LF to LF.

excellent .. my own stupid mistake .. thanks for that (it was also 
contrary to my expectation - but I thought I'd tested it *8^)

however .. I'm still confused by my second test .. because isn't perl 
meant to map "\n" to whatever line ending character sequence it is that 
the operating system uses ?

if so then the following code confuses me

  my $x = "one\ntwo\nthree\n";

  $x =~ s/\cJ/\\cJ/g;
  $x =~ s/\cM/\\cM/g;

  print $x, "\n";

outputs

one\cJtwo\cJthree\cJ

or have I completely misunderstood perlop all these years ? .. just to 
clarify - in my brain - on a DOS machine - when you code

  print "one\n";

what is output is

one\015\012

is that not correct ?

don't worry .. I've just experimented myself out of my black hole .. the 
transformation is only done on the read/write to a textual filehandle .. 
and the transformation is not done on "\n" but rather on the LF character 
itself .. so that even

  print TEXTFILEHANDLE "one\015\012";

will output

one\015\015\012

to the file in question .. in which case - I'd have to say that the 
perlop section is lacking - probably ActiveState's fault more than 
anyone's - there's no mention of line ending characters in the win32 FAQs

time for an apology methinks

-- 
 jason - elephant@squirrelgroup.com -


------------------------------

Date: Tue, 03 Aug 1999 23:23:13 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: How?
Message-Id: <7o7t6o$1hq$1@ash.prod.itd.earthlink.net>

[ courtesy cc sent by mail if address not munged ]
     
Robert Ho <rho@hns.com> wrote:
>I have a file which contains expressions:    "(contents", and
>"(contents)"
>
>I want to substitute "(contents)" with a blank space but I'm finding
>it's not
>so easy due to the parentheses.  Can someone help me with a perl trick?

You have to escape the parentheses or use the \Q operator.

s/\Q(contents)/ /;

        or

s/\(contents\)/ /;


Good Luck,



------------------------------

Date: Wed, 4 Aug 1999 09:46:45 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: looking for XML comments
Message-Id: <MPG.12122a6fcbade26c989bd1@news-server>

[ item posted to comp.lang.perl.misc and CCed to Chris Denman ]

Chris Denman writes ..
>As I understand it, isn't XML just another way of storing information?  What
>benifits should I expect if I change the way I store data?  Should I bother
>at all, and only supply clients with XML generated documents from their
>existing data as and when they need it?

oh I SEEEEEEEEEEEE .. you're not trying to write some perl code that 
searches for XML comments .. you're actually looking for comments on 
[insert anything other than perl here] in a perl newsgroup

stop it

-- 
 jason - elephant@squirrelgroup.com -


------------------------------

Date: Wed, 04 Aug 1999 00:38:35 GMT
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
Subject: Re: mySql & Perl -> Something simple
Message-Id: <7o822a$db5$1@nnrp1.deja.com>



[ your code...]
while (my @data = $sth->fetchrow_array)
     {
      print "<tr>";
      foreach $col (@data)
         {
          print "<td align=left>$col</td>";
          }
       print "</td>\n"; # @@
}
[ your code ends..]

Don't you want to print </TR> tag in the last print stmt marked
with @@ ?


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 355
*************************************


home help back first fref pref prev next nref lref last post