[15687] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3100 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 19 18:05:45 2000

Date: Fri, 19 May 2000 15:05:21 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958773920-v9-i3100@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 19 May 2000     Volume: 9 Number: 3100

Today's topics:
    Re: "Breakthrough" Perl compiler? (Bart Lateur)
    Re: "If" Not Being Evaluated - Vars Are Being Subsitute (Abigail)
    Re: "If" Not Being Evaluated - Vars Are Being Subsitute (Bart Lateur)
    Re: [ CGI ] Can you know how long someone stayed connec <heinrich@chello.fr>
    Re: a PS to Perl - MySQL - Notify using sendmail <megan@aracnet.com>
    Re: Array Question (Abigail)
    Re: converting packed and zoned decimals using perl <bert@scanlaser.nl>
    Re: count the number of lines <lr@hpl.hp.com>
    Re: credit card validation.....isn't working <bert@scanlaser.nl>
        ctime.pl problem <samay1NOsaSPAM@hotmail.com.invalid>
    Re: Data Structures (complex) <lr@hpl.hp.com>
    Re: Does WARN have a reset?? <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: Formmail without using @referers? <Tony@hypertony.co.ukNOSPAM>
        Forum for 'how to do it' questions? <ra.jones@NO_UCE*cwcom.net>
    Re: Forum for 'how to do it' questions? <bmb@dataserv.libs.uga.edu>
    Re: Forum for 'how to do it' questions? <lauren_smith13@hotmail.com>
    Re: Forum for 'how to do it' questions? (Tad McClellan)
    Re: Forum for 'how to do it' questions? <ra.jones@NO_UCE*cwcom.net>
    Re: glueing a scalar onto a variable (Abigail)
        How can I change a few lines of a text file in perl eas <amy@wirespeed.com>
    Re: How can I change a few lines of a text file in perl (Tad McClellan)
    Re: How can I change a few lines of a text file in perl <lauren_smith13@hotmail.com>
    Re: How do I use substitute from the command line? <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: How to convert a long integer into hex <bert@scanlaser.nl>
        HTML output from MS Word (Was: Re: alphabeticalize a pe <lr@hpl.hp.com>
    Re: Manipulate all *values* using CGI.pm? <lr@hpl.hp.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 19 May 2000 21:36:39 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: "Breakthrough" Perl compiler?
Message-Id: <3926b26c.3493889@news.skynet.be>

glauber wrote:

>>With the new Activestate Perl 5.6 REQUIRING that Internet
>Explorer is
>>installed, I pretty much doubt it.
>[...]
>
>
>This is not true. (Kinda hard to test, given that IE is already
>everywhere.)

I'm not making this up. I quote their website:

http://www.activestate.com/ActivePerl/docs/faq/Windows/Install.html


  Requirements

  Windows 98

     Microsoft Windows Installer 1.1+ (available from

http://download.microsoft.com/download/platformsdk/wininst/1.1/W9X/EN-US/InstMsi.exe)

     Internet Explorer 5 (available from
     http://windowsupdate.microsoft.com) 
     DCOM for Windows 98 (available from
     http://www.microsoft.com/com/resources/downloads.asp) 


One can only honestly hope that this is just for the Unicode support
(IE5 can display Chinese, Arabic, etc., and may also allow other Windows
programs to do the same.)

I downloaded the bugger. 27Mb, 3 full hours.

-- 
	Bart.


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

Date: 19 May 2000 19:28:58 GMT
From: abigail@foad.org (Abigail)
Subject: Re: "If" Not Being Evaluated - Vars Are Being Subsituted?
Message-Id: <slrn8ib5fp.vii.abigail@ucan.foad.org>

On Thu, 18 May 2000 21:22:03 GMT, Bart Lateur <bart.lateur@skynet.be> wrote:
++ NoSpam wrote:
++ 
++ >if ($number eq "3") {
++ >  <IMG SRC="test.jpg"  BORDER=0 ALT="Test">
++ >  }
++ 
++ Do you honestly believe that this is valid Perl?

You mean, you *don't*?

The about *IS* valid Perl. It just doesn't do much.



Abigail


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

Date: Fri, 19 May 2000 21:28:46 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: "If" Not Being Evaluated - Vars Are Being Subsituted?
Message-Id: <3925b16b.3236620@news.skynet.be>

Abigail wrote:

>You mean, you *don't*?
>
>The about *IS* valid Perl. It just doesn't do much.

I can't believe this. I tried this:

	#!/usr/local/bin/perl -w
	$number = 3;
	if ($number eq "3") {
	  <IMG SRC="test.jpg"  BORDER=0 ALT="Test">
	}


And it DOESN'T give any error messages. Not even a warning. Why not? How
does Perl interpret this... junk?

-- 
	Bart.


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

Date: Fri, 19 May 2000 18:17:26 GMT
From: Gregory Heinrich <heinrich@chello.fr>
Subject: Re: [ CGI ] Can you know how long someone stayed connected?
Message-Id: <39258723.657F65CF@chello.fr>

Tom Phoenix wrote:

> On Thu, 18 May 2000, Charles Henry wrote:
>
> > I really hoped such a module existed since my browser apparently knows
> > when I am connected and when I am not. Indeed it never prompts me to
> > relogin once I have successfully authenticated, until I close the
> > browser ... But I guess this is done internally by the browser ...
>
> Almost certainly, your browser is re-authenticating you with a remembered
> username/password combination, and hiding that fact from you. Of course,
> this would be better discussed in a forum about browsers, servers,
> authentication, and maybe even CGI programming. Cheers!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/

Well I think this is because the website tells your browser to store a
session cookie (a cookie that stays on your disk until the browser is shut
down).
Greg.



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

Date: Fri, 19 May 2000 13:21:19 -0700
From: "Megan Garrison" <megan@aracnet.com>
Subject: Re: a PS to Perl - MySQL - Notify using sendmail
Message-Id: <CihV4.1019$NX3.26397@typhoon.aracnet.com>

Thanks!! - This looks like what I was looking for but was too ignorant to
know about. And yes, it IS installed -  Will let you know how it goes :o)
appreciatively, ~Megan


"Jeff Helman" <jhelman@wsb.com> wrote in message
news:392558D8.2EEE5B13@wsb.com...
> You might consider using the Net::SMTP module (part of the libnet
> package on CPAN).  Chances are that it is probably already installed if
> you have a halfway decent sysadmin.  Basically, this module allows you
> to interact with a mail server from within a script.  An example from
> the documentation:
>
>     #!/usr/local/bin/perl -w
>
>     use Net::SMTP;
>
>     $smtp = Net::SMTP->new('mailhost');
>
>     $smtp->mail($ENV{USER});
>     $smtp->to('postmaster');
>
>     $smtp->data();
>     $smtp->datasend("To: postmaster\n");
>     $smtp->datasend("\n");
>     $smtp->datasend("A simple test message\n");
>     $smtp->dataend();
>
>     $smtp->quit;
>
>
> To read the full docs, get to a command prompt and type:
>
>     perldoc Net::SMTP
>
> It's fairly straightforward, but it you need some help with a piece, let
> me know.  Good luck,
> JH
>
> ----------------------------------------------------------------
> Jeff Helman                 Product Manager -- Internet Services
> jhelman@wsb.com                    CCH Washington Service Bureau
> ----------------------------------------------------------------
>
> 99 little bugs in the code, 99 bugs in the code.
> Fix one bug, compile again, 100 little bugs in the code.
> 100 little bugs in the code, 100 bugs in the code.
> Fix one bug, compile again, 101 little bugs in the code...
>
> ----------------------------------------------------------------




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

Date: 19 May 2000 19:36:35 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Array Question
Message-Id: <slrn8ib5u3.vii.abigail@ucan.foad.org>

On Thu, 18 May 2000 22:13:02 GMT, Arthur Merar <amerar@unsu.com> wrote:
++ 
++ Hello,
++ 
++ I am been playing with multidimentional associative arrays.  I am
++ getting the hang of it, but cannot figure out one thing:  How the heck
++ do you add rows to the array?  For example, if I have this array:
++ 
++ %pers_record=('Bogdan'=>{'Address'=>'C1605','Phone'=>'x7869','College'=>'BMC'})

I don't seen an array here.

++ Now, I want to add another row, with another persons name, how do I do
++ it?  I cannot seem to find a way without destroying the original
++ element..........
++ 
++ Any ideas?

Yeah, a few. The first idea that comes in mind is that you should read
the documentation.



Abigail


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

Date: Fri, 19 May 2000 23:39:57 +0200
From: Bert IJff <bert@scanlaser.nl>
Subject: Re: converting packed and zoned decimals using perl
Message-Id: <3925B4AD.5105BDB0@scanlaser.nl>



"Alan J. Flavell" wrote:
> 
> On Thu, 18 May 2000 brianbear@my-deja.com wrote:
> 
> > Today is my first ever day coding in Perl
> 
> So it's a pretty sure bet that you haven't been reading the group for
> the reasonable period considered appropriate before posting to it,
> 
> > as I need a quick and
> > flexible way to convert data in a file,
> 
> And usenet needs people who are willing to play their part before
> appealing to the worldwide resources...  (I'm afraid you're going to
> find that anyone who blusters in saying that they "need" something
> "quick" is likely to set people's teeth on edge...)
> 
> > I ahve some data from a pesky IBM mainframe that is stored in EBCDIC
> > and has fields that are packed decimal, and soe that are zoned decimal.
> 
> http://www.deja.com/=dnc/getdoc.xp?AN=506034675
> and the associated thread seems to be relevant to the issues.
> 
> > I beleive I am going to to have to use an ebcdic2ascii function to
> > convert the data
> 
> That'll be fine for character data, but it's hardly going to do much
> good to your packed-decimal.
> 
> > but I need to interpret packed fields correctly into
> > numeric strings for ascii. I know that I can pull out the hex data
> > using unpack but am not quite sure of the syntax yet
> 
> As Uri said (and you could have easily found out before starting to
> alert the group to your problem):
> 
>  this fails as they are decimal numbers, not hex. you have to grab
>  each nibble (maybe with some unpack template) and do a *= 10, +=
>  digit loop on it.

Actually the packed format is neither decimal nor hex, but, if you
convert
the packed format byte by byte to string with

# assume @bytes contains the bytes for this packed number

my $str = "";
foreach (@bytes) {
    $str .= sprintf("%02X", $byte);
}

#	Then the $str contains the number (as a str)
#	Check the last character of this string to be a 
#	C for positive (Credit) or a
#	D for negative (Debit)
#	and adjust the numerical value accordingly

$str =~ m/(\d+)/;
my $num = 0 + $1;
$num = -$num if ($str =~ m/D$/);



> 
> good luck, though I'm glad I got out of IBM mainframes when I did, and
> it's been a while now.


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

Date: Fri, 19 May 2000 12:44:02 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: count the number of lines
Message-Id: <MPG.138f395b1873c0e298aa9c@nntp.hpl.hp.com>

In article <7aln17lth5.fsf@Merlin.i-did-not-set--mail-host-address--so-
shoot-me> on Thu, 18 May 2000 16:21:25 GMT, Ala Qumsieh 
<aqumsieh@hyperchip.com> says...
> 
> Cure <cure@texas.net> writes:
> 
> > how do would I beable to count the number of lines in a file that
> > start with a specified string?
> 
> Is that all you need?
> 
> 	$count = grep /^pattern/, <FH>;
> 
> or
> 
> 	while (<FH>) {
> 		$count++ if /^pattern/;
> 	}

Just to flesh out this choice a bit:

The grep requires the entire file to be in memory at once, but is likely 
to be faster than the while loop, because there are so many perl ops to 
be executed in the latter.

As for the best search mechanism, I would expect that the index function 
is faster for finding a literal pattern without metacharacters.

      $count = grep index($_, 'pattern') == 0 => <FH>;

Another possibility:

      my $pattern = 'pattern';
      my $length = length $pattern;
      $count = grep substr($_, 0, $length) eq $pattern => <FH>;

Anyone who feels inclined to benchmark these is welcome to, of course.  
:-)

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


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

Date: Fri, 19 May 2000 21:19:01 +0200
From: Bert IJff <bert@scanlaser.nl>
To: babylon93 <babylon93@ariannaoils.com>
Subject: Re: credit card validation.....isn't working
Message-Id: <392593A5.579FFE17@scanlaser.nl>



Dennis Marti wrote:
> 
> In article <OFETy6Ew$GA.249@cpmsnbbsa02>, "babylon93"
> <babylon93@ariannaoils.com> wrote:
> 
> > the cards aren't being processed real-time.  I have been working with
> > something I thought would work for 16-digit card numbers, but it doesn't
> > really do that well.........
> >
> > I have converted it into actionscript for Flash, and it just doesn't make
> > any sense, now, why it would work.  First the perl I'm speaking of....
> 
> Did it work in Perl, but not in actionscript?
> 
> Either way, the perl you posted was pretty ugly. Making better use of
> arrays and subroutines would make it more readable, and probably easier
> to port (or debug).
> 
> This is just a translation of your 90+ line subroutine (card16). I have
> no idea if it does anything meaningful with credit card numbers.
> 
> sub two_mod_ten {
>     my $i = shift;
>     my $j = $i * 2;
>     ($j < 10) ? $j : int($j/10) + $j%10;

Or speed up things (save two divisions and a subroutine call)
with
      ($j < 10) ? $j : $j -9;

which does the same thing 
(here $j will be an even number in the range [ 0 .. 18 ]
and the purpose is to add the two digits if the number is 
a two-digit number....

> }
> 
> sub card16_b {
>     my @cc = split //, shift;
>     my $val = 0;
>     for (my $i=0; $i<@cc; $i++) {
>         if ($i % 2) {
>             $val += $cc[$i];
>         } else {
>             $val += two_mod_ten($cc[$i]);
>         }
>     }
>     if (substr($val,1,1) != 0) {
>         &invalid_cc;
>     }
> }

Who says $val has length 2?

A cardnumber like 4563 0099 9999 9992 gives a $val == 102.
and 4563 0099 9999 9994 adds up to 104
BTW, numbers starting with 4563 are VISA numbers  ;-)
According to the code above both are correct numbers.
In reality they aren't. Based on some years of experience with 
checkdigits I guess the last digit of $val should be a zero, so

       &invalid_cc if (($val % 10) || (@cc != 16));

should do the trick (it has to be a 16-digit number in the first
place).

> 
> I don't know actionscript, but one thing I did notice was that all the
> Substring calls except one in the last While loop started indexing at 1.
> 
> >   Substring ( Eval ("cc"&i&"a"), 0, 1 )
> 
> Dennis


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

Date: Fri, 19 May 2000 11:40:24 -0700
From: Samay <samay1NOsaSPAM@hotmail.com.invalid>
Subject: ctime.pl problem
Message-Id: <10658e62.681f4afc@usw-ex0104-087.remarq.com>

I am trying to print something on webpage via perlscript.
And I get error/warning on the webpage along with other stuff..

Prototype mismatch: sub main::ctime (;$) vs none
at /usr/local/lib/perl5/ctime.pl line 50.

I am using: 5.004_04 built for sun4-solaris

How I can prevent this error coming to webpage..?? or do I need
to update perl or ctime.pl??

Thanks
Sa Ma Y



* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Fri, 19 May 2000 13:43:20 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Data Structures (complex)
Message-Id: <MPG.138f47436f846dd998aa9e@nntp.hpl.hp.com>

In article <8g3te5$h9f$0@216.155.33.26> on 19 May 2000 17:25:25 GMT, The 
WebDragon <nospam@devnull.com> says...
> In article <slrn8ia7d8.7pd.tadmc@magna.metronet.com>, tadmc@metronet.com (Tad 
> McClellan) wrote:
> 
>  | >if I read in the database.txt file like this:
>  | >
>  | >open(IN, "<database.txt");
>  | 
>  | 
>  | Except your real code will check the return value from open(), right?
>  | 
>  | :-)
> 
> heehee good point.. My next questions is, how do I handle things, if the 
> database file has been *cleared* at the start of a new week? 

Clear the file by truncating it to length 0, not by deleting it.  Then 
all your code should work fine (i.e., do nothing).

>  | >    chomp(@database = <IN>);
>  | >close IN;
>  | >
>  | >foreach (@database) {
>  | >    my($type, $reviewer, $map) = split /\|/;
>  | >    $masterlist{$type}{$reviewer} = $map;
>  | >}

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


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

Date: Fri, 19 May 2000 13:09:59 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Does WARN have a reset??
Message-Id: <39259F97.1EB403C1@jpl.nasa.gov>

Tom Turton wrote:
> In a subroutine, I have an if block, and in one branch, I use warn to
> print a warning (warn "WARNING:: Outside of allowable limits.\n";)
> 
> The first time through this branch, I get the warning, but subsequent
> passes fail to display the warning.  Yet I follow the 'warn' with a
> debug print statment, and I see that each time, so I know I'm exercising
> the branch of the if block.
> 
> Does 'warn' have a flag I need to clear or reset?

Can you reduce you script to a minimal test case that produces the
problem?  The following is a quick test to show that warn can be called
multiple times:

  $ perl -e 'for(1..10){warn "$_\n"}'

Jon
-- 
Knowledge is that which remains when what is
learned is forgotten. - Mr. King


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

Date: Fri, 19 May 2000 19:11:35 +0100
From: "Tony Sutton" <Tony@hypertony.co.ukNOSPAM>
Subject: Re: Formmail without using @referers?
Message-Id: <8g404q$qas$1@sshuraaa-i-1.production.compuserve.com>

Yes, I am very aware that someone could use it to spam. However, you don't
know what's my plans with it. <g>

Thanks for the suggestion, I'll try it.

--

- Tony Sutton
- http://www.midtownmadness2.co.uk
- http://www.hypertony.co.uk/easymoney.htm - Make Easy Money!
-------------------------------------------------------------
How many of you believe in telekinesis? Raise MY hand!
-------------------------------------------------------------


"Tom Phoenix" <rootbeer@redcat.com> wrote in message
news:Pine.GSO.4.10.10005181427120.25459-100000@user2.teleport.com...
> On Thu, 18 May 2000, Tony Sutton wrote:
>
> But if that's what you want, just use this line of code to set @referers,
> and I think you'll get what you deserve. :-) Remember, though, to
> paraphrase Matt, "By using this code you agree to indemnify Tom Phoenix
> and everyone else in the world from any liability that might arise from
> its use." :-)
>
>     @referers = '';
>
>




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

Date: Fri, 19 May 2000 20:36:42 +0100
From: jones <ra.jones@NO_UCE*cwcom.net>
Subject: Forum for 'how to do it' questions?
Message-Id: <l+GobsAKfZJ5Ewjp@cwc.com>

Simple question: are the comp.lang.perl.misc or alt.perl forums suitable 
for novice perl students to ask 'how do I do that' questions? I am stuck 
trying to do probably a simple task, and would like advice, but would 
like to use the appropriate forum. Thanks,
-- 
Richard Jones, Leeds, UK
rajones (at) mail.com
or remove NO_UCE* from 'reply to' email


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

Date: Fri, 19 May 2000 15:57:15 -0400
From: Brad Baxter <bmb@dataserv.libs.uga.edu>
Subject: Re: Forum for 'how to do it' questions?
Message-Id: <Pine.GSO.4.21.0005191552280.17334-100000@dataserv.libs.uga.edu>

On Fri, 19 May 2000, jones wrote:

> Simple question: are the comp.lang.perl.misc or alt.perl forums suitable 
> for novice perl students to ask 'how do I do that' questions? I am stuck 
> trying to do probably a simple task, and would like advice, but would 
> like to use the appropriate forum. Thanks,

If you mean 'how do I do that with Perl', then yes.  Please, please,
please, for your sake and hundreds of others, look up your question in the
faqs first.  If you're a novice, there is a very high likelihood you'll
find the answer there.  They will be the right answers, too, unlike what
you sometimes encounter here. :-)

See perldoc perlfaq (usually)

Cheers!

-- 
Brad



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

Date: Fri, 19 May 2000 13:31:49 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Forum for 'how to do it' questions?
Message-Id: <8g48cg$hak$1@brokaw.wa.com>


jones <ra.jones@NO_UCE*cwcom.net> wrote in message
news:l+GobsAKfZJ5Ewjp@cwc.com...
> Simple question: are the comp.lang.perl.misc or alt.perl forums suitable
> for novice perl students to ask 'how do I do that' questions? I am stuck
> trying to do probably a simple task, and would like advice, but would
> like to use the appropriate forum. Thanks,

For many 'how do I do that' questions, the FAQ is a great place to start.

Type 'perldoc perlfaq' into a command window for that documentation.

If you ask a question that is covered in the FAQ here in clpm, you'll
usually get a terse redirect to the FAQ.  If you ask more than once, you run
the risk of having all your questions ignored.

Familiarize yourself with the documentation.  The perldoc utility is
indispensible for finding information.

Type 'perldoc perldoc' into a command window for documentation on perldoc.

Then try these:
perldoc perl
perldoc perlfunc

If you have done your homework and still can't figure something out, the
kind folks of comp.lang.perl.misc are a great resource.  Here's a template
for posting:

1) Clear title
2) Clear explanation of the problem
    - What you expect
    - What is actually happening
3) Short snippet of code that exhibits the unexpected behavior


That will usually get you a few good responses.

Lauren





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

Date: Fri, 19 May 2000 15:59:00 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Forum for 'how to do it' questions?
Message-Id: <slrn8ib784.920.tadmc@magna.metronet.com>

On Fri, 19 May 2000 15:57:15 -0400, Brad Baxter <bmb@dataserv.libs.uga.edu> wrote:
>On Fri, 19 May 2000, jones wrote:
>
>> Simple question: are the comp.lang.perl.misc or alt.perl forums suitable 
>> for novice perl students to ask 'how do I do that' questions? I am stuck 
>> trying to do probably a simple task, and would like advice, but would 
>> like to use the appropriate forum. Thanks,
>
>If you mean 'how do I do that with Perl', then yes.  Please, please,
>please, for your sake and hundreds of others, look up your question in the
>faqs first.  If you're a novice, there is a very high likelihood you'll
>find the answer there.  They will be the right answers, too, unlike what
>you sometimes encounter here. :-)
>
>See perldoc perlfaq (usually)


If you have:

   1) checked the Perl FAQs (as Brad suggests)

   2) word searched the other standard Perl docs

   3) tried finding a previous answer to your question on deja.com


and still haven't found the answer to your question, please
feel free to post it here.

(the alt.* hierarchy is a wasteland. Seldom worth the time)



We do not object to newbie questions here.

We DO object to questions whose answers are already installed
on your hard disk.


So, just look for yourself a bit first, and post if that
doesn't work.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 19 May 2000 21:46:46 +0100
From: jones <ra.jones@NO_UCE*cwcom.net>
Subject: Re: Forum for 'how to do it' questions?
Message-Id: <A9ZRrHB2gaJ5Ew3U@cwc.com>

On Fri, 19 May 2000 at 15:57:15, Brad Baxter <bmb@dataserv.libs.uga.edu> 
wrote:
>If you mean 'how do I do that with Perl', then yes.  Please, please,
>please, for your sake and hundreds of others, look up your question in the
>faqs first.  If you're a novice, there is a very high likelihood you'll
>find the answer there.  They will be the right answers, too, unlike what
>you sometimes encounter here. :-)
>
>See perldoc perlfaq (usually)
>
>Cheers!
>
I tried perldoc perlfaq at the telnet command line and received a very 
user-unfriendly screen giving me one line at a time. I then found a 
PerlFaq at www.perl.com spanning PerlFaq1 to PerlFaq 9. Is this the 
document you referred to?
-- 
Richard Jones, Leeds, UK
rajones (at) mail.com
or remove NO_UCE* from 'reply-to' address


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

Date: 19 May 2000 19:34:23 GMT
From: abigail@foad.org (Abigail)
Subject: Re: glueing a scalar onto a variable
Message-Id: <slrn8ib5pv.vii.abigail@ucan.foad.org>

On Thu, 18 May 2000 21:54:29 GMT, Daniel van den Oord <danielxx@bart.nl> wrote:
++ I want to glue a number I get from a outside variable to another variable..
++ like I have the variable $number and I wanna glue 12 onto it making it
++ $number12
++ this is supposed to be an easy way for a huge list of selections
++ to make the right $number<xx> = "selected";

Really? And how would you do it in C? Or Python? Or Java?

Right. 

You should do so in Perl as well.



Abigail


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

Date: Fri, 19 May 2000 15:38:54 -0500
From: "Amy" <amy@wirespeed.com>
Subject: How can I change a few lines of a text file in perl easily?
Message-Id: <sib9gs87ius136@corp.supernews.com>

I know by using sed, we can easily edit an exiting file and change part of
them.  Can somebody tell me how to do the same thing in Perl (I can't
install sed on my current system due to memory problem).  Right now I did
was
save all the lines to an array, then change some elements(lines). Open the
file again and save the array back to file.

Thank you very much.

Amy




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

Date: Fri, 19 May 2000 16:07:31 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How can I change a few lines of a text file in perl easily?
Message-Id: <slrn8ib7o3.94u.tadmc@magna.metronet.com>

On Fri, 19 May 2000 15:38:54 -0500, Amy <amy@wirespeed.com> wrote:

>I know by using sed, we can easily edit an exiting file and change part of
                                                             ^^^^^^
>them.  Can somebody tell me how to do the same thing in Perl


You have Asked a Frequent Question.

You are expected to check the Perl FAQ *before* posting to the
Perl newsgroup you know.


   perldoc -q change


finds:


   "How do I change one line in a file/
    delete a line in a file/
    insert a line in the middle of a file/
    append to the beginning of a file?"


Take particular note of any mention of the "-i" switch.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 19 May 2000 13:53:38 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: How can I change a few lines of a text file in perl easily?
Message-Id: <8g49ld$hu1$1@brokaw.wa.com>


Amy <amy@wirespeed.com> wrote in message
news:sib9gs87ius136@corp.supernews.com...
> I know by using sed, we can easily edit an exiting file and change part of
> them.  Can somebody tell me how to do the same thing in Perl (I can't
> install sed on my current system due to memory problem).  Right now I did
> was
> save all the lines to an array, then change some elements(lines). Open the
> file again and save the array back to file.
>

I'd do it that way too, but for more ideas see the FAQ:

perlfaq5:  How do I change one line in a file/delete a line in a file/insert
a line in the middle of a file/append to the beginning of a file?

Lauren





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

Date: Fri, 19 May 2000 12:32:16 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: How do I use substitute from the command line?
Message-Id: <392596C0.CE4FA08D@jpl.nasa.gov>

shmuelik wrote:
> I need a simple command to substiute exprestions in a file,
> using the perl command s/// , and get the changes at the original file.

Perhaps you are interested in the -i switch and the example of its use
found in perlrun.

Jon
-- 
Knowledge is that which remains when what is
learned is forgotten. - Mr. King


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

Date: Fri, 19 May 2000 22:35:56 +0200
From: Bert IJff <bert@scanlaser.nl>
To: Andrew Goode <a.goode@qut.edu.au>
Subject: Re: How to convert a long integer into hex
Message-Id: <3925A5AC.C982FBF6@scanlaser.nl>



Andrew Goode wrote:
> 
> I have a long integer which I want to convert into hex.
> 
> e.g.
>     $value = 9969772182300;
>     the hex value should be 44BABB1C
> 
> But with any of these conversions, I get an integer overflow error, or a
> value of FFFFFFFF:
> 
>     1) $hexValue = hex($value);
>     2) $hexValue = sprintf ("%X", $value);
>     3) $hexValue = sprintf ("%lX", $value);
> 
> I have read Math::BigInt, but am unsure of the usage.
> 
> I hope someone can offer a simple solution to this seemingly simple problem.
> 
> Thanks
> Andrew

The hex value should actually be 91144BABB1C or do you only need the 
lowest 32 bits ?? (this number needs 44 bits)


Maybe this script helps (tested with perl5 on HP-UX).
It first stores 4 bit chunks in an array, and then
maps this to an array of hex chars, that then is turned
into a string.

You (may) get the 32 bit answer 44BABB1C if you replace the
indicated line in the script below by
        $v >>= 4;
because then the variable $v will first be set to a 32 bit long
(or whatever size long int your perl runs in)
before bitshifting the value by 4 to the right.

#!/usr/local/bin/perl -w
use strict;

sub l2h
{
    my $v = shift;
    my @i ;
    while($v) {
        @i = ($v%16, @i);
        $v = int($v/16);    # <-- indicated line
    }
    join('', map (sprintf("%X", $_), @i));
}

print l2h(9969772182300) . "\n";


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

Date: Fri, 19 May 2000 14:21:41 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: HTML output from MS Word (Was: Re: alphabeticalize a perl array)
Message-Id: <MPG.138f504413b774e998aa9f@nntp.hpl.hp.com>

In article <39287233.12035605@news.skynet.be> on Fri, 19 May 2000 
17:07:06 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Ilmari Karonen wrote:
> 
> >  line 1034 column 248 - Warning: missing </font> before </p>
> >  line 1034 column 252 - Warning: discarding unexpected </font>
> 
> That smells like "tag soup".
> 
> HTML documents should be tree-shaped; tag soup interconnects between
> branches. Example of tag soup:
> 
> 	plain <b> bold <i> bold and italic </b> italic only </i> plain
> 
> MS Word is one notorious program producing tag soup.

Even though the specific file referred to at the beginning of this 
thread was pulled from Uri Guttman's web site, I am the one who chose 
the tools to use to create the documentation set, including the HTML 
file being savaged here.

The primary choice was to use MS Word, which was made because the 
requirements for printed publication in the Perl Conference proceedings 
specified two columns with specified width and separation.  I know how 
to do that with MS Word, so that's what I chose to use.

I processed the output (sorting.doc) with Adobe Acrobat to produce 
sorting.pdf, which is also at my web site 
<URL:http://www.hpl.hp.com/personal/Larry_Rosler/sort/>.  I used the 
HTML output capability of MS Word to produce the HTML file in question, 
sorting.html .

Well aware of the vagaries of MS Word's HTML output, I wrote a minimal 
filter needed to produce correct output on the Nutscrape and Exploder 
browsers.  At no time was any concern or interest given to HTML 
validation.  To put it bluntly, who the hell cares?  My task was to 
produce viewable HTML; I did it.  If I addressed only 99% of the world's 
browsers, I guess I should apologize, but I won't.

Because this newsgroup is about Perl, not HTML, I append the filter 
used.  You will note that it includes some snippets from the de-moron-
izer, just enough to get the job done.

The last modification date on the file is June 25, 1999, which is about 
when the submission of the materials to O'Reilly & Associates was 
accomplished.  I could have done the file handling more transparently 
using the command line and appropriate switches; the rest I stand by 
unabashedly.


#/usr/local/bin/perl -w
use strict;

my $in_file  = 'e:/sorting/sorting0.html';
my $out_file = 'e:/sorting/sorting.html';

open IN,  $in_file     or die "Couldn't open '$in_file'. $!\n";
open OUT, ">$out_file" or die "Couldn't open '$out_file'. $!\n";

{ local $/; $_ = <IN> }

tr/\x91/`/;
s/\x92/&acute;/g;
s/\x96/--/g;

# This handles mis-nested bolds and italics.
s%(?<!<[BI]>)(<[BI]>)(<FONT SIZE=2>)%$2$1%gis;

# This replaces their absurd handling of typewriter text.
s{<FONT FACE="Courier New" SIZE=2><P>(.*?)</FONT>}
 {my $x = $1; $x =~ s%</P>\n<P>?%\n%gi; $x =~ s%</P>%%i;
    $x =~ s%<BR>\n%\n%gi; "<TT><PRE>$x</PRE></TT>"}egis;
s%(</DIR>)\s*(</PRE></TT>)%$2$1\n%gi;

# This left-adjusts all the tables.
s%(<P) ALIGN="CENTER"><CENTER(><TABLE.*?)</CENTER>%$1$2%gis;

# This fixes a complete botch of table borders.
s%(<TABLE .*? BORDER)=0%$1%gi;

print OUT;


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


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

Date: Fri, 19 May 2000 13:23:57 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Manipulate all *values* using CGI.pm?
Message-Id: <MPG.138f42ba263a480998aa9d@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <x73dnfgfe5.fsf@home.sysarch.com> on Fri, 19 May 2000 
07:36:50 GMT, Uri Guttman <uri@sysarch.com> says...
> >>>>> "CW" == Christian Winter <thepoet1@arcormail.de> writes:
> 
>   CW> map { ($paramhash{$_} = $_) =~ tr/[0-9]/[A-J]/ } $new_query->param;
> 
> huh? you are storing the param name as the value AND the key. and map in
> a void context is a no-no around here. this would be better on both
> counts:
> 
> 
> 	( $paramhash{$_} = param($_) ) =~ tr/[0-9]/[A-J]/ for param() ;
> 
> or (values now returns lvalues):
> 
> 	%paramhash = map { $_, param($_) } param() ;
> 	tr/[0-9]/[A-J]/ for values %paramhash ;

I know you just copied and pasted that tr() operation.  Next time, look 
at it.  Around here, translating'[' to '[' and ']' to ']' is considered 
to be gauche, at best!  :-)

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


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

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 3100
**************************************


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