[17260] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4682 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 21 06:05:27 2000

Date: Sat, 21 Oct 2000 03:05:10 -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: <972122710-v9-i4682@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 21 Oct 2000     Volume: 9 Number: 4682

Today's topics:
    Re: Comments <jeff@vpservices.com>
    Re: Comments <bart.lateur@skynet.be>
    Re: Comments <uri@sysarch.com>
    Re: Comments <jdb@wcoil.com>
    Re: coran??? <harrisr@bignet.net>
    Re: coran??? <jeff@vpservices.com>
    Re: coran??? <tony_curtis32@yahoo.com>
    Re: EOF character in middle of file? erion3457@my-deja.com
    Re: EOF character in middle of file? <nospam.newton@gmx.li>
    Re: FedEx and CanadaPost Modules? <dale@emmons.dontspamme.com>
    Re: Finding two words in any order in string? (Andrew N. McGuire)
    Re: Finding two words in any order in string? <godzilla@stomp.stomp.tokyo>
        Help with array concatenation <Jodyman@usa.net>
    Re: Help with array concatenation <uri@sysarch.com>
    Re: Help With Split... I think... :) (Martien Verbruggen)
    Re: Hexadecimal-to-Text (ASCII) converter <nospam.newton@gmx.li>
    Re: how can I get data from a file into variable? <lr@hpl.hp.com>
    Re: how can I get data from a file into variable? (Martien Verbruggen)
    Re: lenght of query string??? <dsimonis@fiderus.com>
    Re: Looking For Ways To Branch To HTML Links (Gwyn Judd)
    Re: make doesn't make <dale@emmons.dontspamme.com>
    Re: Need help again with my script <mtaylorlrim@my-deja.com>
        Perl objects: functions for getting and setting hash va <bruce_phipps@my-deja.com>
    Re: Perl objects: functions for getting and setting has <uri@sysarch.com>
    Re: perldoc equivalent <res06q83@gte.net>
    Re: perldoc equivalent <calle@lysator.liu.se>
        Problem in installing Bundle::DBD::mysql <N.O.S.P.A.M.ctt@N.O.S.P.A.M.usa.net>
    Re: renaming files w/wildcards console unix (Gwyn Judd)
    Re: Rijndael in Perl (Sam Trenholme)
        should be easy, but not working - help ! <none@nospam.com>
    Re: should be easy, but not working - help ! (Gwyn Judd)
    Re: Subroutine reference/undef/redefine anomaly <mauldin@netstorm.net>
        Win32::OLE ??? <kdl@softhome.net>
    Re: Writing multiple files to a particular directory <jeff@vpservices.com>
    Re: Writing multiple files to a particular directory <krahnj@acm.org>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 20 Oct 2000 18:05:00 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Comments
Message-Id: <39F0EBBC.D4C79393@vpservices.com>

Corey French wrote:
> 
> I know that you can comment out a line or end of line with the # key, but is
> there a way to comment out an entire section.  For those of you that are
> familiar with c/c++ what I'm looking for is something like the /* */
> commands.

perldoc -q comment

-- 
Jeff


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

Date: Sat, 21 Oct 2000 01:23:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Comments
Message-Id: <8mr1vskh36t29721e0td1pdkdi307amaj8@4ax.com>

Corey French wrote:

>I know that you can comment out a line or end of line with the # key, but is
>there a way to comment out an entire section.  For those of you that are
>familiar with c/c++ what I'm looking for is something like the /* */
>commands.

See here the first part of a transcript of Larry Wall's speech, only
last week, on the future of Perl (6).

    <http://archive.develooper.com/perl6-meta@perl.org/msg00427.html>

Search for "multiline". Oh, I'll just spoil your fun and quote it here.

   Multiline comments in Perl.  I'm sorry, I was brainwashed by the Ada
   rationale.  Ada has comments to the end of the line and I think that
   if your editor can't put a row of sharps down the left, then you need
   a better editor.

-- 
	Bart.


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

Date: Sat, 21 Oct 2000 01:31:09 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Comments
Message-Id: <x74s27q8tg.fsf@home.sysarch.com>

>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:

  BL> Search for "multiline". Oh, I'll just spoil your fun and quote it here.

  BL>    Multiline comments in Perl.  I'm sorry, I was brainwashed by the Ada
  BL>    rationale.  Ada has comments to the end of the line and I think that
  BL>    if your editor can't put a row of sharps down the left, then you need
  BL>    a better editor.

i am so glad he made that decision. it had it own stupid list on perl6.

i have a single emacs keystroke to comment a region. and with a prefix
arg it uncomments it. DUH!!

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 21 Oct 2000 02:42:29 GMT
From: "Josiah" <jdb@wcoil.com>
Subject: Re: Comments
Message-Id: <8sqvql$822$0@206.230.71.35>

Corey French <blah.xyathn@yahoo.com> wrote in message
news:o05I5.16369$cO4.396072@nntp3.onemain.com...
> I know that you can comment out a line or end of line with the # key, but
is
> there a way to comment out an entire section.  For those of you that are
> familiar with c/c++ what I'm looking for is something like the /* */
> commands.

multiline comment? well, don't try this in production code, (often), but
this works:

__CODE__

print "Hahaha!";

=begin comment

print "you can't see me!";

=cut

print "boo!"

__END__

Everything between a =begin and =cut pair is commentted out, the perl
compiler ignores it.

hth,

--
$from = <$josiah>;








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

Date: Fri, 20 Oct 2000 21:46:36 -0400
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: coran???
Message-Id: <sv1taoaj3heta4@corp.supernews.com>

Jeff Zucker <jeff@vpservices.com> wrote in message
news:39F0D961.FE35E0B4@vpservices.com...
> pape_98@my-deja.com wrote:
> >
> > Has anyone heard of coran????
> > My boss just told me to read about it and said that it was designed
to
> > make scripts run themselves.
>
> Coran ... that's the French spelling of The Holy Koran.  And, yes,
> believers say it can make scripts run themselves, among other things.
>
> Is there any chance you mean "cron", the Unix utility?
>
> --
> Jeff


>Clay Irving <clay@panix.com> wrote
>
>s/o//;
>s/a/o/;
--

You guys must be psychic.




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

Date: Fri, 20 Oct 2000 18:52:34 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: coran???
Message-Id: <39F0F6E2.B495662E@vpservices.com>

Randy Harris wrote:
> 
> Jeff Zucker <jeff@vpservices.com> wrote in message
> news:39F0D961.FE35E0B4@vpservices.com...
> > pape_98@my-deja.com wrote:
> > >
> > > Has anyone heard of coran????
> > > My boss just told me to read about it and said that it was designed
> to
> > > make scripts run themselves.
> >
> > Coran ... that's the French spelling of The Holy Koran.  And, yes,
> > believers say it can make scripts run themselves, among other things.
> >
> > Is there any chance you mean "cron", the Unix utility?
> >
> > --
> > Jeff
> 
> >Clay Irving <clay@panix.com> wrote
> >
> >s/o//;
> >s/a/o/;
> --
> 
> You guys must be psychic.

I can't speak for Clay, but that works for me, with this mod:

s/h/hot/;

:-)

-- 
Jeff


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

Date: 20 Oct 2000 20:58:46 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: coran???
Message-Id: <87y9zjx8dl.fsf@limey.hpcc.uh.edu>

>> On Fri, 20 Oct 2000 21:46:36 -0400,
>> "Randy Harris" <harrisr@bignet.net> said:

> You guys must be psychic.

We knew you'd post that.

-- 
Eih bennek, eih blavek.


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

Date: Sat, 21 Oct 2000 02:14:17 GMT
From: erion3457@my-deja.com
Subject: Re: EOF character in middle of file?
Message-Id: <8squ5m$92j$1@nnrp1.deja.com>

In article <39F09770.A35A78C3@home.com>,
  Michael Carman <mjcarman@home.com> wrote:
> p_erion@yahoo.com wrote:
> > Is there someway that I can get around having ^Z in the middle
> > of a text file?
>
> Yes, by using binmode:
>
> #!/usr/local/bin/perl -w
> use strict;
>
> my $file = 'somefile.txt';
>
> open(IN, $file) or die "Couldn't open '$file' [$!]\n";
> binmode(IN);
> while (<IN>) {
>     s/\015\012/\012/;
>     print ("$_");
> }
>
> print "\nCount: $.\n";
> close(IN);

Thanks this works great!

Then I made a big mistake ... I tried to figure out what was going on.
I assumed that, since we're reading the file in binary mode, the input
record separator would be "\015\012" [to match the actual physical
contents of the file].  However, that doesn't appear to be the case.
If it were, chomp should take off the "\015\012" and it doesn't.  A
pointer to some documentation that would explain where my thinking
process has gone wrong would be most appreciated.

Thanks,

:Paul


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 21 Oct 2000 10:08:56 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: EOF character in middle of file?
Message-Id: <bif2vs4i84cbrfnf4kvfqdql6tniav7s3j@4ax.com>

On Sat, 21 Oct 2000 02:14:17 GMT, erion3457@my-deja.com wrote:

> I assumed that, since we're reading the file in binary mode, the input
> record separator would be "\015\012" [to match the actual physical
> contents of the file].  However, that doesn't appear to be the case.

But you can make it so. It's as simple as $/ = "\015\012".

> If it were, chomp should take off the "\015\012" and it doesn't.

After you change $/, chomp should work fine. (Though chop will still do the
wrong thing.)

Cheers,
Philip


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

Date: Fri, 20 Oct 2000 20:54:49 -0500
From: "Dale Emmons" <dale@emmons.dontspamme.com>
Subject: Re: FedEx and CanadaPost Modules?
Message-Id: <sv1tqmo1ktji5c@corp.supernews.com>

search.cpan.org


<bluearchtop@my-deja.com> wrote in message
news:8spq27$a8u$1@nnrp1.deja.com...
> I know there is a UPS shipping calculation module, but does anyone have
> one for FedEx or Canada Post?  Or some scripts?
> Thanks in advance.
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: 21 Oct 2000 02:44:03 -0500
From: anmcguire@ce.mediaone.net (Andrew N. McGuire)
Subject: Re: Finding two words in any order in string?
Message-Id: <87zojyvdto.fsf@hawk.ce.mediaone.net>

"Godzilla!" <godzilla@stomp.stomp.tokyo> writes:

> Stephane Barizien wrote:
> 
> > I have a big multiline (embedded \n's) string in $str.
>  
> > I want to check if $str contains two (or more, but that's next) words,
> > in any order...
>  
> > What's better than:
>  
> > foo.*bar|bar.*foo

> $counter = 1;
> while (<DATA>)
>  {
>   $_ = " $_ ";
>   $_ =~ s/-/ /g;
>   $_ =~ s/\W+/ /g;
>   if (index ($_, " this ") > -1)
>    {
>     if (index ($_, " that ") > -1)
>      { print "This and That found at line $counter\n"; }
>    }
>   $counter++;
>  }
> print "\n\n     Search Finished";

I am not even going to comment on this, except to say that
I hope nobody listens to your advice, because you CAN'T be
serious.  Your solution is akin saying:

perl -e 'printf +sprintf(substr(q|hello, world|, 0 => 12)) . "\n" if rand()'

is better than:

perl -wMstrict -e 'print "hello, world\n"'

anm

-- 
perl -wMstrict -e '
$a=[[qw[J u s t]],[qw[A n o t h e r]],[qw[P e r l]],[qw[H a c k e r]]];$.++
;$@=$#$a;$$=[reverse sort map$#$_=>@$a]->[$|];for$](--$...$$){for$}($|..$@)
{$$[$]][$}]=$a->[$}][$]]}}$,=$";$\=$/;print map defined()?$_:$,,@$_ for @$;
'


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

Date: Sat, 21 Oct 2000 01:47:08 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Finding two words in any order in string?
Message-Id: <39F1580C.F44BDAC7@stomp.stomp.tokyo>

Andrew N. McGuire, his mind being wasted by Mind Maggots, screams:
 
> Godzilla! wiggles a wee finger and devastates his ego:
> > Stephane Barizien wrote a troll article:


> I am not even going to comment on this, except to say that
> I hope nobody listens to your advice, because you CAN'T be
> serious.  Your solution is akin saying:


Your mental condition will only worsen, rest unassured.
Jealousy undermines your self-confidence. Ego drives you
to self-deprecation and humiliation. Anger with yourself,
will continue to force you to utter foolish statements
which only serve to exasperate your worsening condition
and, serve to feed my most insidious of feminine weapons,
a weapon of my talented intellectual making, Mind Maggots.

Hedious and infectious, pervasively subtle, so very powerful
and so invisible, there is no defense against, yourself. My
Mind Maggots are of your own making, are your own demons and,
will follow you to your grave, just as thoughts of me will
romp, play and chase around in your mind, till your very
last breath, which will be wasted, cursing me.

You see, long ago I sprinkled your mind with seeds of
self-doubt. These seeds have germinated, have sprouted.
These seeds of self-loathing, have blossomed, have been
pollinated by your insects of Envy. Their cyclic progeny,
Mind Maggots.

There is no cure for what I have done. You will never recover.


Kira


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

Date: Sat, 21 Oct 2000 03:53:45 -0400
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Help with array concatenation
Message-Id: <8sri9d$r4f$1@plonk.apk.net>

I have the following program, the object is to get the
julian dates in an array for the form selected month
and year from a webpage.  My problem is that @dates
end up with only the last 3 days of the month instead of
the whole month.  I also would need the array to have
null or spaces in variables that are blank.  i.e.  For
September 2000, the 1st is a Friday date would be
, , , , , 1,2,
3,4,5,6,7,8,9,
10,11,12,13,14,15,16,
17,18,19,20,21,22,23,
24,25,26,27,28,29,30

after the line:
foreach $dates(@dates) { $dates += $jdmi; }

@dates would contain:
244,244,244,244,245,246,
247,248,249,250,251,252,
253,254,255,256,257,258,
259,260,261,262,263,264,  etc etc

Any help would be appreciated.

Jody


#!/usr/bin/perl -w

$calendar = `/usr/bin/cal` ;

$yr = "2000"; # Hard code for testing
@days = (31,28,31,30,31,30,31,31,30,31,30,31);
if ($yr%4 == 0) {$days[1] = 29} else {$days[1] = 28};

#$jdm = $in{'month'}; # Retrieve requested month from form
$jdm = "10"; # Fixed month for testing
if ($jdm) {&jmdate;}
print "Content-type: text/html\n\n";

print "Julian date for 1st of the month: $jdmi<br><br>\n\n";  #for debug

@clines = split(/\n/,$calendar);
$title = shift(@clines);
 print "\$title = $title<br>\n";  # for debug
$tdays = shift(@clines);
 print "\$tdays = $tdays<br>\n";  # for debug

foreach $cline(@clines)
 {
 @dates = unpack(A3 x ((length($cline)/3)+1), $cline);
 foreach $dates (@dates) {print "$dates ";}    # for debug
 print "<br>\n";  #for debug
 }

foreach $dates(@dates) { $dates += $jdmi; } # add julian date to cal date
foreach $dates (@dates) {print "$dates<br>\n";}  #for debug
exit;

sub jmdate {
 $jdmi=0;
 for ($i=0; $i < $jdm - 1; $i++)
  {#print "i= $i jdm= $jdm days= $days[$i] jdmi= $jdmi<br>\n";
  $jdmi = ($jdmi + $days[$i])}
 }





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

Date: Sat, 21 Oct 2000 08:18:09 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Help with array concatenation
Message-Id: <x71yxar4jj.fsf@home.sysarch.com>

>>>>> "JF" == Jody Fedor <Jodyman@usa.net> writes:

  JF> I have the following program, the object is to get the
  JF> julian dates in an array for the form selected month
  JF> and year from a webpage.  My problem is that @dates
  JF> end up with only the last 3 days of the month instead of
  JF> the whole month.  I also would need the array to have
  JF> null or spaces in variables that are blank.  i.e.  For
  JF> September 2000, the 1st is a Friday date would be
  JF> , , , , , 1,2,
  JF> 3,4,5,6,7,8,9,
  JF> 10,11,12,13,14,15,16,
  JF> 17,18,19,20,21,22,23,
  JF> 24,25,26,27,28,29,30

  JF> after the line:
  JF> foreach $dates(@dates) { $dates += $jdmi; }

  JF> @dates would contain:
  JF> 244,244,244,244,245,246,
  JF> 247,248,249,250,251,252,
  JF> 253,254,255,256,257,258,
  JF> 259,260,261,262,263,264,  etc etc

  JF> Any help would be appreciated.

  JF> Jody




  JF> #!/usr/bin/perl -w

-w is good. why no use strict?


  JF> $yr = "2000"; # Hard code for testing
  JF> @days = (31,28,31,30,31,30,31,31,30,31,30,31);
  JF> if ($yr%4 == 0) {$days[1] = 29} else {$days[1] = 28};

DUH!! that code is seriously broken. it will fail in 2100, 2200,
etc. you are lucky that 2000 is divisible by 400 or it would have failed
this year.

and why reassign 28 when it is 28 by default?

  JF> @clines = split(/\n/,$calendar);

  JF> foreach $cline(@clines)
  JF>  {
  JF>  @dates = unpack(A3 x ((length($cline)/3)+1), $cline);

put quotes around A3. 

also since cal is a fixed format, why not just use 7 for the multiplier?

check this out:
perl -e 'for (`cal`) {@d = unpack "A3" x 7, $_; print join( "|", @d), "\n"}'
|Oct|obe|r 2|000||
 S| M|Tu| W|Th| F| S
 1| 2| 3| 4| 5| 6| 7
 8| 9|10|11|12|13|14
15|16|17|18|19|20|21
22|23|24|25|26|27|28
29|30|31||||
||||||

you should shift off the first 2 lines and pop the last before doing
that.

as for blanks, just run it thru map and replace and non-numeric values
with what ever you want.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 21 Oct 2000 10:57:26 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Help With Split... I think... :)
Message-Id: <slrn8v1mv6.fji.mgjv@martien.heliotrope.home>

[Crosspost to itialian newsgroup removed. aren't you supposed to talk
itialian there?]

On Wed, 18 Oct 2000 15:31:00 -0500,
	TEst <mezmoria@hotmail.com> wrote:
> Ok, I admit it I suck as a programmer. I guess thats why I dont program full
> time :). Anyway I need help from you experts out there.
> 
> I am trying to create an array from a line of text that has no formatting
> and I cannot figure out how to seperate the fields.
> 
> 
> Here is the original text.. (including spaces)
> 1111111111        00000011111110000001111111TEST COMPANY
> 11111111111636459802000101700
> 
> This is how I want it to look...
> 1111111111,0000001111111,0000001111111,TEST
> COMPANY,11111111111,63645980,2000101700

The only way you can get that result back is if you have more
information than you have told us. Is this a fixed format? As in: Are the
numbers of characters always the same? In that case I would use unpack
or substr. (I am assuming that the two lines oyu posted are actually one
line, and that there is a space separating COMPANY and 1111).

my @f = unpack "A18 A13 A13 A13 A11 A8 A10", $line;
print join(',', @f), "\n";

If there is no fixed length format, you will have to provide more
details. A split is not going to work, because you have no separators.
Instead of making us guess, maybe you should have tried to figure out
some more information about the format first.

> PS... I am posting this to three perl groups cuz I am not sure which one is
> correct for this type of question.......

clp.misc would have been most appropriate.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd.   | crops where there ain't no crops.
NSW, Australia                  | 


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

Date: Sat, 21 Oct 2000 07:35:10 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: Hexadecimal-to-Text (ASCII) converter
Message-Id: <iu72vssgu8r0u0ic8h9dpihjfje77cb2pp@4ax.com>

On Wed, 18 Oct 2000 08:42:40 -0500, Michael Carman <mjcarman@home.com> wrote:

> Jean-Claude JEHIN wrote:
> > 
> > Is anybody know where can I find the PERL solution for Hex-to-Text
> > (ASCII) conversion?
> 
> If I understand you correctly, you want the chr() function and its
> brother ord().

Either that, or pack 'H*'.

Cheers,
Philip


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

Date: Fri, 20 Oct 2000 23:10:01 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: how can I get data from a file into variable?
Message-Id: <MPG.145ad3119813a12498ae53@nntp.hpl.hp.com>

In article <slrn8v1nhl.fji.mgjv@martien.heliotrope.home>, 
mgjv@tradingpost.com.au says...
+ On Fri, 20 Oct 2000 14:12:19 -0700,
+ 	Larry Rosler <lr@hpl.hp.com> wrote:
+ > In article <slrn8v06in.fji.mgjv@martien.heliotrope.home> on Fri, 20
+ > Oct 2000 21:11:35 +1100, Martien Verbruggen
+ > <mgjv@tradingpost.com.au> says...

 ...

+ > > chomp $line;
+ > 
+ > Compulsive use of chomp()!
+ >
+ > > my $val = (split /\t/, $line)[-1];
+ 
+ The OP's question was:
+ 
+ >>>How can I retreive the number 2000 into a variable
+ 
+ Not removing the newline would leave the newline in $val. I know that
+ for numerical operations that doesn't matter, but it also doesn't
+ answer the question. The OP might very well call this a number, and
+ continue to use it as a string. I could have split on whitespace, with
+ ' ', but that also wasn't according to spec. Specified was that data
+ was separated by a tab. I can't assume that other pieces of data won't
+ have embedded whitespace.
+ 
+ The chomp was used with deliberation, not compulsively. But I might be
+ missing something? How do you suggest I fremove it, if not with a
+ chomp?

Splitting with ' ' and indexing with -1 would isolate the last field and 
trim the trailing newline, regardless of whitespace in earlier fields.

BTW, is 'fremove' (see your last sentence above) a C function, like 
fopen or fprintf or fseek or ftell or fclose?  :-)

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


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

Date: Sat, 21 Oct 2000 19:49:42 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: how can I get data from a file into variable?
Message-Id: <slrn8v2m56.fji.mgjv@martien.heliotrope.home>

On Fri, 20 Oct 2000 23:10:01 -0700,
	Larry Rosler <lr@hpl.hp.com> wrote:
> In article <slrn8v1nhl.fji.mgjv@martien.heliotrope.home>, 
> mgjv@tradingpost.com.au says...
>
> + continue to use it as a string. I could have split on whitespace, with
> + ' ', but that also wasn't according to spec. Specified was that data
> + was separated by a tab. I can't assume that other pieces of data won't
> + have embedded whitespace.
> + 
> + The chomp was used with deliberation, not compulsively. But I might be
> + missing something? How do you suggest I fremove it, if not with a
> + chomp?
> 
> Splitting with ' ' and indexing with -1 would isolate the last field and 
> trim the trailing newline, regardless of whitespace in earlier fields.

Yes, I know. I alluded to that in the paragraph above. It's just that
the OP had specified tab-separation, and I didn't want to assume that
there wasn't going to be any other white-space anywhere.  I've been in
enough trouble lately for assuming things on this newsgroup. :)

Of course, it is very likely that split ' ' would have worked just as
well. :)

> BTW, is 'fremove' (see your last sentence above) a C function, like 
> fopen or fprintf or fseek or ftell or fclose?  :-)

void *fremove(size_t size, size_t n_elem, FILE *stream);

fremove attempts to remove n_elem elements of size bytes long from the
stream pointed to by stream, backwards and retrospectively. Always
returns NULL, except when it returns a pointer to nowhere in particular.
This function has never been observed to work.

I thought you were involved in the ANSI C standardisation process? How
can you not know about fremove? Whaddayamean, not standard? It works on
my DeathStation 2000 with the Zog compiler, and..

wait, wrong newsgroup.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | We are born naked, wet and hungry.
Commercial Dynamics Pty. Ltd.   | Then things get worse.
NSW, Australia                  | 


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

Date: Fri, 20 Oct 2000 14:38:26 -0400
From: Drew Simonis <dsimonis@fiderus.com>
Subject: Re: lenght of query string???
Message-Id: <39F09122.321EAE10@fiderus.com>

nobull@mail.com wrote:
> 
> Stefan Glimne <Glimne@gmx.net> writes:
> 
> > Does anyone know how long the "query string" can be.
> 
> I think that URLs are limited to about 1024.
> 
> > I have problem when
> > I write to much in a TEXTAREA. The "query string" is just cut. Is there
> > a solution for this problem.
> 
> Stop using method=GET and start using method=POST in your HTML forms.
> 

I didn't see where he specified what method he was using.


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

Date: Sat, 21 Oct 2000 02:22:46 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Looking For Ways To Branch To HTML Links
Message-Id: <slrn8v1vfj.7rg.tjla@thislove.dyndns.org>

I was shocked! How could Mike Mercurio <mmercurio88@my-deja.com>
say such a terrible thing:
>Hi,
>
>I'm new to Perl.  I'm looking for a way for a Perl script to:
>1) Spin through links of a given HTML page.
>2) When I hit certain links, I want to follow that link to the new page.
>3) When I get to the new page, I want to save the page to my hard drive.
>4) After I save it, I want to return to the original page.
>(...then repeat the process)
>
>Are there modules written to do this?  If so, what ones are they and
>where can I get them?  Any extra hints on how to do each of these steps
>(like what methods to use, etc.) are greatly appreciated!!!

This is almost certainly difficult to do correctly. I would use the
'wget' utility which can correctly mirror sites. have you asked the
administrators permission to do this? Failing that I expect you could
use the HTML::Parser and LWP to do what you want. I hope this helps.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
God said it, I believe it and that's all there is to it.


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

Date: Fri, 20 Oct 2000 20:58:42 -0500
From: "Dale Emmons" <dale@emmons.dontspamme.com>
Subject: Re: make doesn't make
Message-Id: <sv1u1vo4lhgua6@corp.supernews.com>

> I am running Windows NT (I know...) I am trying to make the HTML::template
> module. I got borland version 5.2 of "make" (by the way it is the first
> module I install, ever). the instructions are quite clear:

use the perl package manager:

C:\>ppm install HTML-Template

-dale




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

Date: Sat, 21 Oct 2000 02:03:06 GMT
From: Mark <mtaylorlrim@my-deja.com>
Subject: Re: Need help again with my script
Message-Id: <8sqtgn$8kn$1@nnrp1.deja.com>

The script is doing exactly what you are telling it to. You are getting
4 lines output because you have 4 unique entries....Silver, Titanium,
Platinum, and Gold.

the first time through the script it builds the %silver associative
array. Then, the 6th time through it re-writes that %silver associative
array again. So you lose the results of the first match.

You need to rethink this a little. You may not want to use associative
arrays here. But that is just a thought.

Mark



In article <qO3I5.9830$Fe4.255520@typhoon.austin.rr.com>,
  "Seth" <sbearden@houston.rr.com> wrote:
> check out the datae file:
> |10/20/2000|18:32:21|nothing[aTm]|In Flames|31|21|silver|lpb|
> |10/20/2000|18:32:21|nothing[aTm]|In Flames|32|22|titanium|lpb|
> |10/20/2000|18:32:21|nothing[aTm]|In Flames|33|23|platinum|lpb|
> |10/20/2000|18:32:21|nothing[aTm]|In Flames|34|24|gold|lpb|
> |10/20/2000|18:32:21|nothing[aTm]|In Flames|35|25|titanium|lpb|
> |10/20/2000|18:32:21|nothing[aTm]|In Flames|36|26|silver|lpb|
> |10/20/2000|18:32:21|nothing[aTm]|In Flames|37|27|gold|lpb|
> |10/20/2000|18:32:21|nothing[aTm]|In Flames|38|28|silver|lpb|
> |10/20/2000|18:32:21|nothing[aTm]|In Flames|39|29|platinum|lpb|
>

<snip>

> You'll notice that it only outputs 4 entries.  I want it to output
all the
> datafile entries.
>

--
Please reply to this newsgroup as my Deja mail
is used as a spam catcher only!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 21 Oct 2000 09:27:30 +0100
From: "Bruce Phipps" <bruce_phipps@my-deja.com>
Subject: Perl objects: functions for getting and setting hash values
Message-Id: <8srk2s$qpm$1@sshuraac-i-1.production.compuserve.com>

I am learning up on Perl objects and have a hash in my constructor:

sub new {

my $classname = shift;
my $self = {
 NAME=>'Bruce',
 %AIRPORTS = {
 LON=>'London',
 MAD=>'Madrid',
 JFK=>'New York'}
 };

bless ($self, $classname);
return $self);
}
===================

Is there a standard way of "getting and setting" hashes? Here is what I have
so far but if there is a more elegant method I see no reason to reinvent the
wheel! With scalar values (such as NAME in my example) I can usually set and
get the value using a single function.


sub show_airports {

my $self = shift;
return %{$self->{AIRPORTS}}; #not very elegant
}

sub add_airport {
 ......
}

TIA Bruce




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

Date: Sat, 21 Oct 2000 08:40:27 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl objects: functions for getting and setting hash values
Message-Id: <x7wvf2poxw.fsf@home.sysarch.com>

>>>>> "BP" == Bruce Phipps <bruce_phipps@my-deja.com> writes:

  BP> my $self = {
  BP>  NAME=>'Bruce',
  BP>  %AIRPORTS = {

wrong. that should just be a plain key, no need for the %. 

  BP>  LON=>'London',
  BP>  MAD=>'Madrid',
  BP>  JFK=>'New York'}
  BP>  };

and indent that mess.

  BP> Is there a standard way of "getting and setting" hashes? Here is
  BP> what I have so far but if there is a more elegant method I see no
  BP> reason to reinvent the wheel! With scalar values (such as NAME in
  BP> my example) I can usually set and get the value using a single
  BP> function.

there are many modules to help you with this. search cpan. buy and read
object oriented perl.

  BP> sub show_airports {

  BP> my $self = shift;
  BP> return %{$self->{AIRPORTS}}; #not very elegant

what do you mean not elegant? 

you grab the hash ref and dereference it.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 21 Oct 2000 07:47:32 GMT
From: "res06q83" <res06q83@gte.net>
Subject: Re: perldoc equivalent
Message-Id: <oSbI5.11782$v52.432341@dfiatx1-snr1.gtei.net>


"James Taylor" <james@NOSPAM.demon.co.uk> wrote in message
news:ant202335d07fNdQ@oakseed.demon.co.uk...
>
> Oh good, I'll seek it out and decipher the intended behaviour from the
> source then modify it to work with the HTML docs. Can I assume there
> is no reason why this would not be possible, such as for instance
> there not being the same material in the HTML docs as is accessible
> using perldoc?

I'm not sure I follow.  Are you running perdoc at a command line on your
UNIX or Wintel box?  It doesn't work with HTML, but with POD.  This
gives the added benefit that modules can contain their own embedded
documentation.

Have you tried typing 'perldoc perldoc' into a command prompt?

Lauren
--
Yay!  Web access at home now!  No more surfing from work.




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

Date: 21 Oct 2000 10:51:56 +0200
From: Calle Dybedahl <calle@lysator.liu.se>
Subject: Re: perldoc equivalent
Message-Id: <86aeby8tlf.fsf@tezcatlipoca.algonet.se>

>>>>> "James" == James Taylor <james@NOSPAM.demon.co.uk> writes:

> This has long been a frustration to me because I do not have perldoc
> on my RISC OS machine or my EPOC device, even though I have Perl for
> both.

Why don't you have perldoc on them? The program is just 800 lines of
Perl that grovels trough POD documentation, picks out a good bit and
displays it through a pod2foo converter. At least pod2text should be
portable to anything Perl is ported to. 

EPOC is rather small platform, come to think of it. The problem might
be that the PODs simply aren't there, to save memory. README.epoc in
the Perl dist indicates that the EPOC port is quite limited.

I can't see why the POD-handling stuff (including perldoc) shouldn't
run on RISC OS, though. Ask Richard Proctor about it (if it's still
him who handles the Acorn port).

And in any case, handling POD will be easier than handling HTML on
*any* platform.
-- 
 Calle Dybedahl, Vasav. 82, S-177 52 Jaerfaella,SWEDEN | calle@lysator.liu.se
             Try again. Try harder. -*-  Fail again. Fail better.


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

Date: Thu, 19 Oct 2000 20:55:43 +0800
From: root <N.O.S.P.A.M.ctt@N.O.S.P.A.M.usa.net>
Subject: Problem in installing Bundle::DBD::mysql
Message-Id: <39EEEF4F.C2F707B7@N.O.S.P.A.M.usa.net>

Hello, when I install the above package, I get the following error:

 .......
>perl -MCPAN -e 'install Bundle::DBD::mysql'
 ........
gcc -c -I/usr/lib/perl5/site_perl/5.6.0/i386-linux/auto/DBI
-I/usr/include/mysql -I../dbd
-I/usr/lib/perl5/site_perl/5.6.0/i386-linux/auto/DBI
-I/usr/lib/perl5/5.6.0/i386-linux -fno-strict-aliasing -O2 -march=i386
-mcpu=i686     -DVERSION=\"2.0415\" -DXS_VERSION=\"2.0415\" -fPIC
-I/usr/lib/perl5/5.6.0/i386-linux/CORE -DDBD_MYSQL dbdimp.c
dbdimp.c: In function `mysql_dr_connect':
dbdimp.c:583: Internal error: Segmentation fault.
Please submit a full bug report.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
make[1]: *** [dbdimp.o] Error 1
make[1]: Leaving directory
`/root/.cpan/build/Msql-Mysql-modules-1.2215/mysql'
make: *** [subdirs] Error 2
  /usr/bin/make  -- NOT OK
 ........

anyone has any idea of what's happening? thanks

(I'm using the Redhat 7.0 and perl 5.6.0)



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

Date: Sat, 21 Oct 2000 02:47:58 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: renaming files w/wildcards console unix
Message-Id: <slrn8v20ur.7rg.tjla@thislove.dyndns.org>

I was shocked! How could Lance Hoffmeyer <vibrato@my-deja.com>
say such a terrible thing:
>How can I rename a group of files in linux using Perl?  I wish to use
>perl from a command line and not in a script.  I want to find all files
>with - and change to :
>
>> perl -e 'rename *\-* *\:*'      possible answer?

Sounds like you want to use the glob() function:

perl -we '($new = $_) =~ tr/-/:/ && rename $_, $new or warn "Cant
rename $_ $new: $!" for (<*-*>)'

Not quite one line though.

>There may be an easier way than Perl but I generally use Perl for most
>of my console activities.  As an aside what are some other available
>methods in linux (I know this is not the right group to make this post
>on but this is primarily a Perl question and most people will be able to
>help me with any other methods)?

Well in bourne shell I'd do:

for i in *-* ; do mv $i `echo $i | sed -e 's/-/:/'` ; done

Which is one line. Anyone do better?

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
A "No" uttered from deepest conviction is better and greater than a
"Yes" merely uttered to please, or what is worse, to avoid trouble.
		-- Mahatma Ghandi


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

Date: 21 Oct 2000 07:00:11 GMT
From: kiwi-oo7rlcj@koala.samiam.org (Sam Trenholme)
Subject: Re: Rijndael in Perl
Message-Id: <8sretq$i3m$1@dfw-ixnews3.ix.netcom.com>

>http://home.pacific.net.ph/~dido/Crypt-Rijndael-0.01.tar.gz

I noticed that a script called makertbls.pl is referred to in the code,
but is not part of this archive.

I would like to look at this script, so I can get a better picture of
Rijndael in my mind.  I am slowly but surely "getting" how it works.

- Sam

-- 
"Reality is the most perfect vision of God's will" -- Orson Scott Card
Note that this email address times out in two weeks
http://www.samiam.org/ssi/mailme.shtml has my email address


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

Date: Sat, 21 Oct 2000 01:41:08 -0400
From: "none" <none@nospam.com>
Subject: should be easy, but not working - help !
Message-Id: <YQ9I5.410$bM2.1047@newsfeed.slurp.net>

I have the following code, basically all I need to do is from a form that
allowed multiple checkboxes, is count the number of boxes that were checked.
Here are the chunks of code involved - any idea why it won't work - it just
keeps showing 1 as the topping total. There's a space after each value in
the checkbox list.
-------------------------
 Which toppings would you like? (All pizzas include cheese and tomato
sauce)<p></td></tr>
      <tr><td><input type="checkbox" name="toppings" value="X-Cheese ">Extra
Cheese<br>
              <input type="checkbox" name="toppings" value="Pepperoni
">Pepperoni<br>
              <input type="checkbox" name="toppings" value="Sausage
">Sausage<br>
              <input type="checkbox" name="toppings" value="Onion
">Onion<br>
              </td></tr>
 .
 .
 .
 .
 .
@line = qw($input{toppings});
$toppingtotal = @line;
------------------
$toppingtotal shows as a value of 1, even when checking them all.
I also tried it without the qw and it didn't work.






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

Date: Sat, 21 Oct 2000 07:27:14 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: should be easy, but not working - help !
Message-Id: <slrn8v2haf.clf.tjla@thislove.dyndns.org>

I was shocked! How could none <none@nospam.com>
say such a terrible thing:
>I have the following code, basically all I need to do is from a form that
>allowed multiple checkboxes, is count the number of boxes that were checked.

>@line = qw($input{toppings});
>$toppingtotal = @line;
>------------------
>$toppingtotal shows as a value of 1, even when checking them all.
>I also tried it without the qw and it didn't work.

You mean, I think:

@line = @{$input{toppings}};
$toppingtotal = @line;

$input{toppings} is a *scalar* value, so I guess it is a reference to an
array, therefore you need to dereference it. The 'qw($input{toppings})'
thing is just wrong. If you did a 'print @line' after doing that, you
would know what it actually does, which I think is different from what
you think it does. I think.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Psychiatry enables us to correct our faults by confessing our parents'
shortcomings.
		-- Laurence J. Peter, "Peter's Principles"


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

Date: Sat, 21 Oct 2000 01:30:40 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Subroutine reference/undef/redefine anomaly
Message-Id: <39F0F156.8FFAFB2C@netstorm.net>

nobull@mail.com wrote:
> 
> Undefining and then redefining a subroutine creates an anomalous state
> in references to the old subroutine.
> 
> #!/usr/bin/perl -w
> use strict;
> 
> sub foo { 2 };
> my $old_foo = \&foo;
> undef &foo;
> *foo = sub { 3 };
> print 0 + defined &$old_foo;
> print $old_foo->();
> 
> This prints '03'.  This is of course nonsense. How can I call an
> undefined function and have it return 3?
> 
> If I comment out the undef it correctly prints '12' and correctly
> warns about the redefinition of &main::foo.
> 
> If I put back the undef and comment out the redefinition it correctly
> prints '0' and correctly dies when it tries to call the undefined
> function.
> 
> Not exactly a serious bug, but it caused me some great confusion
> trying to debug a program.

Wow!  What a situation.  I think the answer is that a Perl reference is
not a pointer, it's something like a C struct with supporting functions
that maintains a variety of information including a pointer to the data
or the entry point of the subroutine code (an actual location in
memory), the data type (scalar, array, hash, code), a reference count -
the total number of references to the code or data that are still
extant, wherever they may be - and the status of the variable or code,
such as whether it is undef.

When you declare:
  my $old_foo = \&foo;

a new Perl reference (with a different reference ID) is created that
contains the same pointer to the sub as the one in the symbol table for
&foo, and the reference count is increased to 2.  When you undef &foo,
the reference count of $$old_foo decreases to 1 and the status of both
references are set to undef, even though the code continues to exist.

Perl continues to maintain the memory allocated to the code until the
reference count decreases to 0, which won't happen unless you also
destroy the reference in $old_foo.  As well, the foo typeglob continues
to exist in the symbol table.  So when you redefine &sub by assigning to
*foo, perl knows that another reference to it still exists and
duplicates the pointer in $$old_foo in $foo reference in the symbol
table, increments the reference count in both reference, and sets their
status to defined. Then it it makes no difference if you change the
subroutine code, because both pointers in both references still point to
it.

I could be wrong in some of the details, but I think that's about
right.  Nifty question, and counter-intuitive, as you suggest.  I'd be
glad to hear from anyone who has more insight or a better
understanding.  I'm sure they're out there.

HTH,

-- Jim


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

Date: Sat, 21 Oct 2000 12:29:05 +0300
From: "Denys Kotseba" <kdl@softhome.net>
Subject: Win32::OLE ???
Message-Id: <8srnep$2g99$1@app0.visti.net>

Hello,

I have faced the following problem after upgrading ActiveState Perl 5.22 to
6.18.
Here is the code:

#$rs is a recordset resulted from the query to SQL server

$Response->Write($rs->Fields('DateCreated')->Value);
$a=$rs->Fields('DateCreated')->Value;
$Response->Write($a);
$Response->Write($a.$a);

And here is the output (I inserted '|' for readability):

21.10.2000 12:17:19 | 21.10.2000 12:17:19 |
Win32::OLE::Variant=SCALAR(0x4a2f870)Win32::OLE::Variant=SCALAR(0x4a2f870)

The old version produced normal output (i.e. real value instead of
Win32::OLE::Variant=SCALAR(0x4a2f870) thingy). What has changed? Could
anyone please advise?

Thank you.

Denys Kotseba





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

Date: Fri, 20 Oct 2000 18:04:11 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Writing multiple files to a particular directory
Message-Id: <39F0EB8B.19A9F9C8@vpservices.com>


"John W. Krahn" wrote:
> 
> Jeff Zucker wrote:
> >
> > "John W. Krahn" wrote:
> > >
> > > or
> > > open (FIXEDLOG, '>c:\baalogs\fixeddirectory\' . $fixed) ...
> >
> > Did you try that one? :-)
> 
> I'm running on Linux so I don't have a c: drive or \ directory
> separators. :-)

Then try this:  

print 'c:\baalogs\fixeddirectory\';

-- 
Jeff


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

Date: Fri, 20 Oct 2000 19:45:57 -0700
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Writing multiple files to a particular directory
Message-Id: <39F10365.EC05567D@acm.org>

Jeff Zucker wrote:
> 
> "John W. Krahn" wrote:
> >
> > Jeff Zucker wrote:
> > >
> > > "John W. Krahn" wrote:
> > > >
> > > > or
> > > > open (FIXEDLOG, '>c:\baalogs\fixeddirectory\' . $fixed) ...
> > >
> > > Did you try that one? :-)
> >
> > I'm running on Linux so I don't have a c: drive or \ directory
> > separators. :-)
> 
> Then try this:
> 
> print 'c:\baalogs\fixeddirectory\';

Oops. Forgot about that.

John


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

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


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