[11003] in Perl-Users-Digest
Perl-Users Digest, Issue: 4603 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 9 10:03:03 1999
Date: Sat, 9 Jan 99 07:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 9 Jan 1999 Volume: 8 Number: 4603
Today's topics:
Re: "internal server error" (Abigail)
Re: __FILE__, __LINE__ not set <gellyfish@btinternet.com>
Re: Beginner trying to figure out PERL for cgi use <gellyfish@btinternet.com>
Re: c to perl <zenin@bawdycaste.org>
Re: c to perl <gellyfish@btinternet.com>
Re: c to perl <gellyfish@btinternet.com>
cannot find tiehash.al with BerkeleyDB2.6.4/Perl5.004_4 (2n3055@usa.net)
Re: cannot find tiehash.al with BerkeleyDB2.6.4/Perl5.0 (2n3055@usa.net)
Re: Easy binary file access ? <gellyfish@btinternet.com>
Re: How to do an exact comparison? (Michael Rubenstein)
Re: Need CGI database <gellyfish@btinternet.com>
Re: Perl Criticism (Stefaan A Eeckels)
Re: Perl Criticism <gellyfish@btinternet.com>
Re: possible bug in perl format with ~~ <gellyfish@btinternet.com>
Re: regexp and broken MY reference (M.J.T. Guy)
Remove vars from a foreach loop <webpages@email.com>
replacing <BR> with a physical carriage return (Jason Q.)
Re: replacing <BR> with a physical carriage return mike@mjm.co.uk
Re: replacing <BR> with a physical carriage return (Clay Irving)
Re: replacing <BR> with a physical carriage return <due@murray.fordham.edu>
Re: replacing <BR> with a physical carriage return <due@murray.fordham.edu>
Re: Uploading PC files works - but not Mac files rupert@no.spam.leeds.ac.uk
Re: Uploading PC files works - but not Mac files (Bart Lateur)
Re: utmp / who <gellyfish@btinternet.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Jan 1999 01:15:46 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: "internal server error"
Message-Id: <776ak2$31l$1@client3.news.psi.net>
Tony Greenwood (paxton@cyberstrider.org) wrote on MCMLVI September
MCMXCIII in <URL:news:369c4ba2.4200417@news.freeserve.co.uk>:
;;
;; >Let's see.... you don't have -w, you don't have "use strict", you do
;;
;; Niether do I.. what do they do ?
RTFM
;; >everything yourself instead of using modules written by people with a
;;
;; Same here.. I still don't understand what a module is or how to use
;; them
RTFM
;; >clue, you don't supply us with an error message, nor you clarify what
;;
;; I get errors but no error messages, as I write in notepad then where
;; would I find error messages?
RTFM
Abigail
------------------------------
Date: 9 Jan 1999 13:45:25 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: __FILE__, __LINE__ not set
Message-Id: <777mhl$km$1@gellyfish.btinternet.com>
On 9 Jan 1999 06:59:28 GMT Charles R. Thompson wrote:
> Is there any common reason that __FILE__ and __LINE__ would not follow
> into &CgiDie?
>
What is &CgiDie - I have a horrible suspiscion which I wont voice ?
> I have a few library files I'm trying to debug, but since the __FILE__
> does not show up, I really can't figure out which one it is complaining
> about. I am using the $! variable, but the error given is vague and
> could apply to any of the 4-8 that load depending on a given situation.
It works fine for me in this example:
#testFILE.pl:
use testFILE;
print __FILE__,__LINE__,"\n";
testFILE::test;
#testFILE.pm
package testFILE;
sub test
{
print __LINE__,__FILE__,"\n";
}
1;
This provides the information as required. It might be that your library
files are doing something to monkey with these values but I think thats
improbable. I think a little more detail is required here.
It is most probable that instead of using the library that you are you
should consider using CGI.pm and CGI::Carp which will provide the
kind of diagnostic information you need to the browser.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 9 Jan 1999 13:29:36 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Beginner trying to figure out PERL for cgi use
Message-Id: <777lk1$ij$1@gellyfish.btinternet.com>
On Sat, 09 Jan 1999 01:08:41 -0500 Wayne wrote:
<snip stuff about bad encode/decode>
> Also I have a scaler variable that contains a total eg .
> $total =10.00
> $total = $total + 10.00
>
> Now when I send this to a web page to give a customer the total they
> spend I would see
> $10 and not $10.00 How do I force my script to keep 2 decimal places?
>
The sprintf() builtin is what you want :
perldoc -f sprintf
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 09 Jan 1999 12:56:02 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: c to perl
Message-Id: <915886609.104120@thrush.omix.com>
Expert <expert@friko.onet.pl> wrote:
: webmaster@galilnet.co.il wrote:
: >
: > Is there a utility that converts c to perl?
: > Jim
Not that I know of, but Perl's C hooks are very good. Most
people simply use XS to call the real C code from perl rather
then converting it.
: I am looking for a utility that converts perl to c .
: Jack
perldoc perlcc
perldoc B
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: 9 Jan 1999 13:32:18 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: c to perl
Message-Id: <777lp2$im$1@gellyfish.btinternet.com>
On Sat, 09 Jan 1999 06:45:50 GMT webmaster@galilnet.co.il wrote:
> Is there a utility that converts c to perl?
Pick one of :
A) Yeah its called your brain ...
or
B) No.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 9 Jan 1999 13:37:14 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: c to perl
Message-Id: <777m2a$k2$1@gellyfish.btinternet.com>
On Sat, 09 Jan 1999 09:11:31 GMT Expert wrote:
> webmaster@galilnet.co.il wrote:
>>
>> Is there a utility that converts c to perl?
>>
> I am looking for a utility that converts perl to c .
I am looking for a utility that converts perl to seaweed ...
The latest releases of Perl come with an experimental Perl compiler that
will create C code from Perl.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 09 Jan 1999 13:33:13 GMT
From: 2n3055@usa.net (2n3055@usa.net)
Subject: cannot find tiehash.al with BerkeleyDB2.6.4/Perl5.004_4/PM0.06?
Message-Id: <36975907.35546868@news.supernews.com>
I am using Redhat Linux 5.1/intel
afterdownload BerkeleyDBv2.6.4 and install it,
if I
use BerkeleyDB;
tie %h, BerkeleyDB, Filename;
untie %h;
it produce an error code "cannot find tiehash.al"
but if I use the dbmopen/dbmclose, instead of tie/untie,
the program run smoothly?
what's the problem?
anybody help?
thanks.
------------------------------
Date: Sat, 09 Jan 1999 13:53:23 GMT
From: 2n3055@usa.net (2n3055@usa.net)
Subject: Re: cannot find tiehash.al with BerkeleyDB2.6.4/Perl5.004_4/PM0.06?
Message-Id: <36985ebf.37011387@news.supernews.com>
there are NOT such problem (cannot found tiehash.al)
if I am using DB_File V1.63+ BerkeleyDB2.6.4,
it only appear with BerkeleyDB.pm V0.06+ BerkeleyDB2.6.4
On Sat, 09 Jan 1999 13:33:13 GMT, 2n3055@usa.net (2n3055@usa.net)
wrote:
>I am using Redhat Linux 5.1/intel
>afterdownload BerkeleyDBv2.6.4 and install it,
>if I
>use BerkeleyDB;
>tie %h, BerkeleyDB, Filename;
>untie %h;
>it produce an error code "cannot find tiehash.al"
>but if I use the dbmopen/dbmclose, instead of tie/untie,
>the program run smoothly?
>what's the problem?
>anybody help?
>thanks.
------------------------------
Date: 9 Jan 1999 13:21:45 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Easy binary file access ?
Message-Id: <777l59$ie$1@gellyfish.btinternet.com>
On Sat, 09 Jan 1999 01:42:45 GMT bluepuma@my-dejanews.com wrote:
> Hi folks,
>
> I have to analyse a web server log file, but the data was converted into
> a binary file using c. Is there an easy way to access the data from perl ?
> I'm not that familiar with all the object orientated "->" stuff.
>
This is eminently doable in Perl - you will have to use unpack to dismember
your C struct - now I cant give you an exact example becuase you dont
say how big your char's are but assumming your struct is like this:
struct request
{
unsigned int timestamp;
unsigned int clientID;
unsigned int objectID;
unsigned int size;
char method[4];
char status[3];
char type[6];
char server[32];
};
you could do something like this:
($time,
$client,
$object,
$size,
$method,
$status,
$type,
$server ) = unpack ( S S S S A4 A3 A6 A32, $request );
This also assumes that your timestamp is a short however most time values
are longs in my experience.
You will also have to use read() to get the correct sized bits of your file
that relate to your struct .
perldoc -f pack
perldoc -f unpack
perldoc -f read
Hope that helps.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 09 Jan 1999 13:06:33 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: How to do an exact comparison?
Message-Id: <36a253a7.474972384@nntp.ix.netcom.com>
On Sat, 09 Jan 1999 03:48:54 +0000, Craig Berbling
<craig.berbling@pobox.com> wrote:
>Bruce Chu wrote:
>>
>> if ($variable eq "test") # for string comparisons
>> if ($variable == 10) # for numerical comparisons
>>
>> "news.rogers.ca" wrote:
>>
>> > Hello,
>> >
>> > This may sound like a stupid question but I know if I do...
>> >
>> > if ( $variable =~ /test/ )
>> >
>> > it will return true if "test" is in $variable but how do I format the if
>> > statement if I want it to return true only if the string in $variable is
>> > exactly "test" and not "mytest" or "test123"...
>> >
>> > Help!
>> > Thanks,
>> >
>> > Luc Levesque
>> > luc2@travelpod.com
>
>Or
>if ( $variable =~ /^test$/ )
No. This tests something different:
$a = "test";
$b = "test\n";
print "yes\n" if $a =~ /^test$/;
print "yes\n" if $b =~ /^test$/;
This prints "yes" twice.
--
Michael M Rubenstein
------------------------------
Date: 9 Jan 1999 11:57:21 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Need CGI database
Message-Id: <777g71$7g$1@gellyfish.btinternet.com>
On 9 Jan 1999 07:01:38 GMT Charles R. Thompson wrote:
Dave Cross Wrote:
>>Depends how big this database is going to be. For smaller databases you
> can
>>get good results by tieing a hash to a DBM file. For something larger
> you
>>could look at something like MySQL.
>>
>>hth,
>>
>>Dave...
>
>
> Could you define 'large' in sort sort of relative sense? I've often
> wondered just what constitutes moving up from Flatfiles or DBM's to
> something a bit more powerful.
>
Actuall for me I think that the ease of installation of something like
MySQL might set that bar fairly low. The same might apply to the kind
of operations that are to be performed on your database. If a major
part of the operations that are to be performed are updates, inserts,
deletes etc then a RDBMS becomes attractive - that is not to say that
you cannot do these things with text files its just that you need more
code to achieve these things.
I run databases that might contain tables of less than 1000 rows on MySQL
partially I must admit because I *can* but mostly for the reason that I
can get on with the internal logic of the program and forget about the
nastiness involved with updating flat text files. I might also add that
it is a lot easier to move programs between platforms if you are using
a RDBMS (in my opinion anyway) - I altered a (admittedly simple) program
from using Win32::ODBC to MySQL in less than an hour last week - this is
largely because the interfaces are, by their nature, fairly similar - if I
had been using DBI from the outset then it might have taken a few minutes.
Anyhow if you are interested in using a flat file structure for your data
then you could do worse than look at Brent Michalski's column on this
subject on WebReview <URL:wwww.webreview.com> which is a good starting
point for this kind of thing.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 8 Jan 1999 23:20:08 GMT
From: Stefaan.Eeckels@jodokus.ecc.lu (Stefaan A Eeckels)
Subject: Re: Perl Criticism
Message-Id: <7763r8$vs4$1@justus.ecc.lu>
In article <775hso$fs9$1@nnrp1.dejanews.com>,
topmind@technologist.com writes:
> Reply to David Formosa's 1/8 message:
>
>> There are posts in this newsgroup, comments in the O'Rielly books and
>> the online documentaion. Also the decision process is carried out
>> (more or less) on the p5p mailing list. <<
>
> Bits and peices here and there? Hardly a consistant, organized approach
> to building a language.
Did you *ever* participate? Do even have a remote idea of
what a 'consistent, organised approach' is?
>> Then you don't employ stupid people in the IT dept.<<
>
> Except in isolated cases this is not going to happen.
> There is not automated way for managers to detect fools. Thus
> a *practical* language should assume there *are* plenty of idiots.
Never heard of the dictum
"Build a fool-proof system and you'll notice that
only fools will want to use it"
Arguably, COBOL is one of the most fool-proof languages
ever devised. Has it made for better COBOL programs?
Not in the least (and I've seen my fair share of them :-)
Or Pascal - so restrictive it's almost useless (ignoring
heavily mutated variants like Delphi).
Certain activities (like making sure people are fit for
the job) cannot be automated, should not be automated,
and require work from the manager. If you want to spot
an incompetent individual, you've got to be competent at
what the person's supposed to do (programming). Introducing
silly rules and restrictions designed to force people
(be they bright, stupid, honest or malicious) to fall in
line (and somehow to perform to a decent standard) is
delusional behaviour all too common in management types.
It's so silly and obvious that I always wonder why they
never seem to get it (but then that's the definition of
a delusion, right?).
>> In most cases
>> I've found its the non-unix solotions dragging down a comperney esp
>> where it is combined with stupidity. At worst such systems fool the
>> stupid people into thinking that they can mannige the system. <<
>>
> The type of OS people work on depends mostly on circumstances
> not controlled by them. Since it is tough to switch sub-specialties
> in IT, most end up using what their college or first employer
> used. Therefore, I see no mechanism in place to filter or separate
> idiots into Windows instead of Unix.
Did you even understand what he's saying?
> I suspect your statement is flame bait.
After this nonsense, I *know* you're a troll.
*PLONK*
--
Stefaan
--
PGP key available from PGP key servers (http://www.pgp.net/pgpnet/)
___________________________________________________________________
Perfection is reached, not when there is no longer anything to add,
but when there is no longer anything to take away. -- Saint-Exupiry
------------------------------
Date: 9 Jan 1999 14:43:43 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Perl Criticism
Message-Id: <777puv$ot$1@gellyfish.btinternet.com>
On Fri, 08 Jan 1999 18:13:46 GMT topmind@technologist.com wrote:
>
> The type of OS people work on depends mostly on circumstances
> not controlled by them. Since it is tough to switch sub-specialties
> in IT, most end up using what their college or first employer
> used.
>
Absolute rubbish, if this was true then I would still be programming for
CP/M or what have you and many of my colleagues would still be using
Arthur and would be looking at the dole queue as they hauled the last ICL
mainframe out of the door.
Infact as far as it goes I would suggest that a characteristic of a
*good* programmer is an ability to adapt to circumstance as required -
if this were not true then the dole queues would be full of people who
had, shall we say, dBase III programming as their primary skill.
For the majority of people here Perl is not their first programming
language or perhaps even second or third or more.
It could be suggested that programming is a 'sub-speciality in IT' as there
are many other categories of employment within the industry. Many people
switch between 'Operator','Programmer','Analyst','Trainer','Administrator'
regularly as the exigencies of the employment market require.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 9 Jan 1999 12:59:33 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: possible bug in perl format with ~~
Message-Id: <777jrl$i6$1@gellyfish.btinternet.com>
On Sat, 9 Jan 1999 02:19:14 -0500 Jon Lewis wrote:
> On Fri, 8 Jan 1999, Tad McClellan wrote:
>
>> Jon Lewis (jlewis@gnv.fdt.net) wrote:
>>
>> : $sr_notes contains any \r\n's,
>>
>> : I'm using perl 5.004 on Linux.
>>
>>
>> Why do you have Carriage Returns in your text files?
>
> The perl script in question is processing an HTML form post, and using a
> format to generate a nice looking formatted hard copy. Several textareas
> have to be printed on the hard copy, and I don't know how long each will
> be, or whether or not the user will enter line breaks (carriage returns)
> within a textarea.
>
You probably want to remove the carriage-returns from your data before
writing to the format then:
$sr_notes =~ /\r\n/ /g;
for instance.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 9 Jan 1999 14:50:31 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: regexp and broken MY reference
Message-Id: <777qbn$7qd$1@pegasus.csx.cam.ac.uk>
Ala Qumsieh <aqumsieh@matrox.com> wrote:
>Marty Landman <marty@catnmoose.com> writes:
>> my $HTML;
>> $HTML .= $_ while <Signon>;
>
>There is an easier way to do this:
>{ local $/ = <>; $HTML = scalar <Signon> }
Eh? I don't think you mean that - setting $/ to the next line from ARGV
is a very strange thing to do. And that 'scalar' is redundant -
it's in a scalar context already. So make that
{ local $/; $HTML = <Signon> };
> [ much extra quoting ]
Please restrict your quoting to the part(s) of the article you are
actually replying to.
Mike Guy
------------------------------
Date: Sat, 09 Jan 1999 15:00:46 +0100
From: Eirik Johansen <webpages@email.com>
Subject: Remove vars from a foreach loop
Message-Id: <3697610E.BF1C260C@email.com>
Hi!
I'm making a script that will take the values from the components of a
form and send them to some E-mail adress. The recipient of the E-mail
and the subject-line are defined in two hidden-fields of the form, which
is a problem when I do a foreach loop to print out all the vars in the
body of the e-mail, cause it prints out the subject-line and the
recipient as well in the body msg.
Is it possible to do a foreach loop, but to remove some vars from the
loop that you know the names of. (I do not know the names of the rest of
the components, cause the user is supposed to chose his/her own
components.
The test-form can be found at http://home.sol.no/~webpages/mailform.htm
and a *.txt-version of the script can be found at
http://home.sol.no/~webpages/mailform.txt
Thanks for any advice you can give me !
Regards
Eirik
------------------------------
Date: Sat, 09 Jan 1999 12:13:02 GMT
From: pigs_can_fly@mindless.com (Jason Q.)
Subject: replacing <BR> with a physical carriage return
Message-Id: <369c0d03.108387050@news.cyberway.com.sg>
Hi
Records in the database contains HTML codes like <P> <BR>
An example of the record would be: Jack and Jill<BR>Went up the hill
When I display the record in a <TEXTAREA> field in a html page, the
exact same line would appear:
---------------------------------------------------------------------------------
| Jack and Jill<BR>Went up the hill |
| |
| |
--------------------------------------------------------------------------------
How do I get perl to replace the <BR> with a carriage return so that
the textarea displays it like this:
--------------------------------------------------------------------------------
| Jack and Jill |
|Went up the hill |
| |
--------------------------------------------------------------------------------
I tried this:
$string =~ s/<BR>/\n/eg;
but got this result:
--------------------------------------------------------------------------------
| Jack and JillSCALAR(0xb79640)Went up the hill |
| |
| |
--------------------------------------------------------------------------------
converting it back to %0D%0A doesn't work either
Any help would be appreciated.
Thanks
Jason Q.
http://www.generationterrorists.com
------------------------------
Date: Sat, 09 Jan 1999 12:31:01 GMT
From: mike@mjm.co.uk
Subject: Re: replacing <BR> with a physical carriage return
Message-Id: <36974774.4369311@nntp.netcom.net.uk>
Try this;
$string =~ s/<BR>/\n/g;
Note the the 'e' has been removed from the operator.
I guess that you are using print $string;
where the 'e' will evaluate the expression giving the result
indicated. By using the 'e' with print "$string";
the effect is to remove the newline with the result coming out in a
single line (back to sq 1)..
Try the above, and see if it fixes the problem,
Mike
On Sat, 09 Jan 1999 12:13:02 GMT, pigs_can_fly@mindless.com (Jason Q.)
wrote:
>Hi
>
>Records in the database contains HTML codes like <P> <BR>
>
>An example of the record would be: Jack and Jill<BR>Went up the hill
>
>When I display the record in a <TEXTAREA> field in a html page, the
>exact same line would appear:
>---------------------------------------------------------------------------------
>| Jack and Jill<BR>Went up the hill |
>| |
>| |
>--------------------------------------------------------------------------------
>
>How do I get perl to replace the <BR> with a carriage return so that
>the textarea displays it like this:
>--------------------------------------------------------------------------------
>| Jack and Jill |
>|Went up the hill |
>| |
>--------------------------------------------------------------------------------
>
>I tried this:
>
>$string =~ s/<BR>/\n/eg;
>
>but got this result:
>--------------------------------------------------------------------------------
>| Jack and JillSCALAR(0xb79640)Went up the hill |
>| |
>| |
>--------------------------------------------------------------------------------
>
>
>converting it back to %0D%0A doesn't work either
>
>Any help would be appreciated.
>
>Thanks
>
>
>
>Jason Q.
>http://www.generationterrorists.com
Mike
MjM Computer Publishing
http://www.mjm.co.uk
------------------------------
Date: 9 Jan 1999 07:59:16 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: replacing <BR> with a physical carriage return
Message-Id: <777jr4$d28@panix.com>
In <369c0d03.108387050@news.cyberway.com.sg> pigs_can_fly@mindless.com (Jason Q.) writes:
>Records in the database contains HTML codes like <P> <BR>
>An example of the record would be: Jack and Jill<BR>Went up the hill
>When I display the record in a <TEXTAREA> field in a html page, the
>exact same line would appear:
>---------------------------------------------------------------------------------
>| Jack and Jill<BR>Went up the hill |
>| |
>| |
>--------------------------------------------------------------------------------
>How do I get perl to replace the <BR> with a carriage return so that
>the textarea displays it like this:
>--------------------------------------------------------------------------------
>| Jack and Jill |
>|Went up the hill |
>| |
>--------------------------------------------------------------------------------
>I tried this:
>$string =~ s/<BR>/\n/eg;
>but got this result:
>--------------------------------------------------------------------------------
>| Jack and JillSCALAR(0xb79640)Went up the hill |
>| |
>| |
>--------------------------------------------------------------------------------
>converting it back to %0D%0A doesn't work either
You have to escape the brackets -- This:
#!/usr/local/bin/perl5 -w
$string = "Jack and Jill<BR>Went up the hill";
$string =~ s/\<BR\>/\n/;
print "$string\n";
prints:
Jack and Jill
Went up the hill
--
Clay Irving
clay@panix.com
------------------------------
Date: 9 Jan 1999 13:48:33 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: replacing <BR> with a physical carriage return
Message-Id: <777mnh$oqg$0@206.165.165.137>
Clay Irving wrote in message <777jr4$d28@panix.com>...
|In <369c0d03.108387050@news.cyberway.com.sg> pigs_can_fly@mindless.com (Jason
Q.) writes:
|>Records in the database contains HTML codes like <P> <BR>
|>An example of the record would be: Jack and Jill<BR>Went up the hill
|>When I display the record in a <TEXTAREA> field in a html page, the
|>exact same line would appear:
|>----------------------------------------------------------------------------
-----
|>| Jack and Jill<BR>Went up the hill |
|>----------------------------------------------------------------------------
----
|>How do I get perl to replace the <BR> with a carriage return so that
|>the textarea displays it like this:
|>----------------------------------------------------------------------------
----
|>| Jack and Jill |
|>|Went up the hill |
|>| |
|>----------------------------------------------------------------------------
----
|>I tried this:
|>$string =~ s/<BR>/\n/eg;
|>but got this result:
|>----------------------------------------------------------------------------
----
|
[small snip]
|
You have to escape the brackets -- This:
|
| #!/usr/local/bin/perl5 -w
| $string = "Jack and Jill<BR>Went up the hill";
| $string =~ s/\<BR\>/\n/;
| print "$string\n";
|
|prints:
| Jack and Jill
| Went up the hill
so does:
$string = "Jack and Jill<BR>Went up the hill";
$string =~ s/<BR>/\n/;
print "$string\n";
It is not the escapes that solve the problem, it is the fact that you dropped
the e. I believe that the e is forcing the \n to be interpreted as a
referrence to the bareword n.
AmD
------------------------------
Date: 9 Jan 1999 13:58:08 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: replacing <BR> with a physical carriage return
Message-Id: <777n9g$pu7$0@206.165.165.137>
mike@mjm.co.uk wrote in message <36974774.4369311@nntp.netcom.net.uk>...
|Try this;
|$string =~ s/<BR>/\n/g;
|Note the the 'e' has been removed from the operator.
|I guess that you are using print $string;
|where the 'e' will evaluate the expression giving the result
|indicated. By using the 'e' with print "$string";
|the effect is to remove the newline with the result coming out in a
|single line (back to sq 1)..
I believe that the e is forcing the \n to be interpreted as a
reference to the bareword n. Hence the appearance of the SCALAR(0xb79640) in
place of the <BR>.
#!/usr/local/bin/perl -w
my $foo = 'bar';
my $n = \$foo;
my $string = "Jack and Jill<BR>Went up the hill";
$string =~ s/<BR>/$n/e;
print "$string\n";
gives:
Jack and JillSCALAR(0xbd5a08)Went up the hill
as does:
my $foo = 'bar';
my $n = \$foo;
my $string = "Jack and Jill<BR>Went up the hill";
$string =~ s/<BR>/\$n/e;
print "$string\n";
AmD
------------------------------
Date: Sat, 9 Jan 1999 11:44:14 +0000 (GMT)
From: rupert@no.spam.leeds.ac.uk
Subject: Re: Uploading PC files works - but not Mac files
Message-Id: <3697B114.1CEE@no.spam>
> I'm working on a project where we upload files using a browser.
> I have made a perl program which receives the files from the html form.
> All this works perfect when dealing with PC files, but when uploading
> Mac files the Resource Fork part is missing (a Mac file consist of a
> Resource Fork and a Data Fork).
>
> I then tried using the uploader.exe which is included with the Website
> Pro Web server but alas, same result!
>
> My fear is that is the browser which dosn't send the Resource Fork
> part, if so i'm F...
I don't think you are. Look at it as a file system problem rather
than a browser problem or a perl problem. Indeed you might have
similar difficulties with systems that make extensive use of meta
information such as the VAX or with the AFS.
Perhaps you could flatten the file down to something that can be
transferred using only a name and a series of bytes. This is
much the same problem as tranferring files through gateways or
e-mail. You could use something like MIME (check the RFC's) or a
compression format such as ZIP or gz.
Ben.
------------------------------
Date: Sat, 09 Jan 1999 12:39:25 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Uploading PC files works - but not Mac files
Message-Id: <36974d5c.18254213@news.skynet.be>
rupert@no.spam.leeds.ac.uk wrote:
>You could use something like MIME (check the RFC's) or a
>compression format such as ZIP or gz.
.BIN or .HQX would be more like it (MacBinary and BinHex). I doubt if
any browser does it by itself, so you probably need users doing it by
themself, manually. Ugh.
BTW it's natural that if you upload Mac files through a PC, that you
only get the data fork. That's all the PC sees, anyway.
Bart.
------------------------------
Date: 9 Jan 1999 12:56:57 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: utmp / who
Message-Id: <777jmp$i3$1@gellyfish.btinternet.com>
On Fri, 08 Jan 1999 13:44:32 -0800 dana watanabe wrote:
> Is there any perl function/module/way to do it that works with utmp?
>
> I'd bassically like to get the same information as doing who.
>
Just a quickish hackette put together whilst watching 'Dinosaurs' :
#!/usr/bin/perl
my $UTLENGTH = 56;
my $UTMP = '/var/run/utmp';
open(UTMP,$UTMP) || die "Cant open utmp - $!\n";
while(read(UTMP,$utdata,$UTLENGTH))
{
($type,
$pad,
$pid,
$line,
$id,
$time,
$user,
$host,
$addr
) = unpack("s A2 L A12 A4 L A8 A16 L",$utdata),"\n";
if($type == 7 )
{
print $user,"\t",$line,"\t",$host,"\t",scalar(localtime($time)),"\n";
}
}
close UTMP;
I cant guarantee that this will work on any other system as mine (Linux 2.034)
as there seems to be a slight discontinuity between the manpage and what is
actually in the utmp file but there you go...
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 V8 Issue 4603
**************************************