[12812] in Perl-Users-Digest
Perl-Users Digest, Issue: 222 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 22 02:07:21 1999
Date: Wed, 21 Jul 1999 23: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)
Perl-Users Digest Wed, 21 Jul 1999 Volume: 9 Number: 222
Today's topics:
Re: ****Perl tutorials!!!!**** (elephant)
Appending to a file under NT (WeAreScott)
Array problem (Jimtaylor5)
Re: Array problem <swiftkid@bigfoot.com>
Re: finding last created files in a directory (Larry Rosler)
GD module usage problem.... prasad@chetana.com
Re: Help Please Anyone....... <kenhirsch@myself.com>
Re: index.cgi script help <swiftkid@bigfoot.com>
Re: Kinda FORK <Ch1ckEn@hotmail.com>
Re: LWP and frame <swiftkid@bigfoot.com>
Re: Need Help with Virtual Avenue (elephant)
Re: newbie question: how put files from dir in array <uri@sysarch.com>
Opne3 on Win32? Really nobody knows? Or primitive probl <pkotala@logis.cz>
Re: problem with hash of arrays (Anno Siegel)
Re: recursive anonymous functions -- problem (elephant)
Re: regular Expression <dgris@moiraine.dimensional.com>
Re: regular Expression <dgris@moiraine.dimensional.com>
Re: regular Expression <dgris@moiraine.dimensional.com>
Re: Scrollback perldoc in DOS-window? <swiftkid@bigfoot.com>
Re: Shortening the length of a string <uri@sysarch.com>
Re: Shortening the length of a string <surgie@bellsouth.net>
Re: special case : split this string... <bwalton@rochester.rr.com>
Re: special case : split this string... <swiftkid@bigfoot.com>
SSI in Perl CGI output <alcaron@espresso.wustl.edu>
Re: SSI in Perl CGI output <swiftkid@bigfoot.com>
Re: STDIN redirection (Anno Siegel)
Re: TIe::IxHash (Andrew M. Langmead)
Re: waitpid crashes perl (Anno Siegel)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 22 Jul 1999 15:09:26 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: ****Perl tutorials!!!!****
Message-Id: <MPG.1201528e3eb5000c989b69@news-server>
Floyd Morrissette writes ..
>In article <1dvb92n.4s4d519ccu2oN@p37.tc17.metro.ma.tiac.com>,
> rjk@linguist.dartmouth.edu (Ronald J Kimball) wrote:
>
>> I'm using Netscape Navigator 4.04. I turned on Images, Java, and
>> JavaScript. It's *still* a blank page.
>
>Works with IE. Obviously one of those pages for IE only. They have
>alienated about half the Internet world.
hmm .. ears pricked from use of the word 'Obviously' I went over to this
site .. the page is downloading in Navigator - same as it does in IE ..
but it seems that there's a simple HTML error on the page (often happens
with that many nested tables) .. IE takes it's best guess and displays
what it can .. Navigator falls over and shows nothing
this is typical behaviour for Navigator .. I like to think of IE (here it
comes .. the whole reason for this post *8^) as the Perl of web browsers
.. because irrespective of the input - it always tries to do something
flame suit on .. goggles down .. Bill's cheque in my pocket .. and ..
exit - stage left
--
jason - remove all hyphens for email reply -
------------------------------
Date: 22 Jul 1999 05:58:30 GMT
From: wearescott@aol.com (WeAreScott)
Subject: Appending to a file under NT
Message-Id: <19990722015830.05677.00001503@ng-ch1.aol.com>
Hi,
This question was asked about 3 weeks ago, and I have the exact same problems.
I also checked everything each person said to check and nothing worked.
unless (open(WRITE, ">>file.txt")) {
die (print "FAILED ON APPEND");
}
I moved files from UNIX to NT, and am unable to append to a flat text file i
have in my cgi-bin directory. I am almost positive it has to do with the file
system not recognizing the ">>" in front of the file.txt.
I made sure the file was in the same directory. I have also put in the full
path from the root drive. I checked permissions. I took out the unless / die
part, i put it back on. Nothing works. This is frustrating. Can anyone
help?
Scott Clothier:)
No SIG!
------------------------------
Date: 22 Jul 1999 04:44:24 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: Array problem
Message-Id: <19990722004424.05853.00001231@ng-ce1.aol.com>
If someone could help me with this, I'd be grateful.
I want to have an array of information all on one line. I know how to do this
when I know how many items there will be, as
($Item1, $item2, $item3) = split(/\|/,$line);
But I want to add and take away from the array line and there may be 5 or
sometimes 6 items. How would I get those items from the array line in my
program without knowing how many there are?
------------------------------
Date: Thu, 22 Jul 1999 10:16:53 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Array problem
Message-Id: <7n7cqp$elf6@news.cyber.net.pk>
: ($Item1, $item2, $item3) = split(/\|/,$line);
:
: But I want to add and take away from the array line and there may be 5 or
: sometimes 6 items. How would I get those items from the array line in my
: program without knowing how many there are?
@items = split '\|' , $line;
foreach ( @items ) ... blah
$total = @items; # count
etc
------------------------------
Date: Wed, 21 Jul 1999 22:53:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: finding last created files in a directory
Message-Id: <MPG.1200519a3251baa4989d17@nntp.hpl.hp.com>
In article <slrn7pcspt.oqh.abigail@alexandra.delanet.com> on 21 Jul 1999
20:26:59 -0500, Abigail <abigail@delanet.com> says...
> Larry Rosler (lr@hpl.hp.com) wrote on MMCL September MCMXCIII in
> <URL:news:MPG.11ffb1f63386bf23989d10@nntp.hpl.hp.com>:
> ** Assuming the 'changed' date is what you want, you must stat all the
> ** files (or use the '-C' operator, which does the same thing). Then sort
> ** by it and slice the extreme five that you want from the sorted list. Be
> ** sure to use a sorting method that stats each file once only, not in the
> ** sortsub.
>
> How inefficient!
...
SNIP of extremum sort
...
> This is O (n), while sorting takes Omega (n log n).
In fact, a few months ago I published a function 'extremes' in the Perl
Function Repository that works like that. It turned out -- because of
the constant factors in the slow Perl code -- to be slower than simple
sort-and-slice for N < many thousands. When I posted my response I
didn't think that kind of sort applied to this kind of situation, and I
still don't think it does.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Jul 1999 05:42:03 GMT
From: prasad@chetana.com
Subject: GD module usage problem....
Message-Id: <7n6ava$iek$1@nnrp1.deja.com>
Hello,
I am trying to write a script which will take a 13 digit EAN13 no. and
convert it to a barcode using GD library. The encoding of the 13 digits
to
the string to be printed works fine. i.e. the 13 dig are converted to a
series of 0 and 1 which indicate light and dark bars respectively.
But the code which I use to draw a barcode from this encoded string
seems
to be acting weird. The EAN13 encoding has a stop mark and a start mark
of '101'. When checked visually, the generated gif properly draws the
dark-light-dark combination at the extreme left properly but somehow
draws the very last dark bar of the width of 2 consecutive dark bars.
I later tried to just print half of the encoded string and found that
again
the last bar to be printed a dark bar in this case was of the width of
2 consecutive dark bars as earlier. I am using a for loop which I think
has no problems. I am really puzzled. Can somebody help me ?
I have appended the part of script that gives this problem below,
-------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use diagnostics;
use GD;
my $eancode = '9788173660320';
##convert the encoded string into a gif image my $left_margin = 11; my
$right_margin = 7; my $encoded_str =
'1010111011000100100010010011001001000101111010101010100001010000111001010000
1011011001110010101';
my @encoding = split //,$encoded_str;
my $n = scalar(@encoding); # width of encoded string
my $x = $n + $left_margin + $right_margin;
my $y = 40;
my $image = new GD::Image($x, $y+20) or
die "Unable to create $x x $y GIF image";
my $grey = $image->colorAllocate(0xCC, 0xCC, 0xCC);
my $white = $image->colorAllocate(0xFF, 0xFF, 0xFF);
my $black = $image->colorAllocate(0x00, 0x00, 0x00);
$image->transparent($grey);
$image->fill(6, 6, $white);
#$image->rectangle(0, 0, $x-1, $y-1, $black); #orig
for (my $i = 0; $i < $n; ++$i)
{
my $pos = $left_margin + $i; #new
my $color = $encoding[$i] eq '1' ? $black : $white;
#print "pos is $pos, color is $color, digit $encoding[$i]\n";
$image->rectangle($pos, 0, $pos+1, $y-1, $color); #new
}
$image->string(gdLargeFont, 2, $y+2, $eancode, $black);
print STDOUT $image->gif();
-------------------------------------------------------------------
,regards
prasad.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 21 Jul 1999 22:04:52 -0400
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: Help Please Anyone.......
Message-Id: <7n6524$dub$1@oak.prod.itd.earthlink.net>
Bill <formula@idirect.com> wrote:
> <input NAME="file" TYPE="file"><br>
Perhaps this is your problem. You probably meant TYPE="text"
------------------------------
Date: Thu, 22 Jul 1999 10:34:20 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: index.cgi script help
Message-Id: <7n7dqr$elf9@news.cyber.net.pk>
: I am on a server that uses an index.cgi file that redirects all requests
: for my main domain (http://customautotrim.com) to
: http://customautotrim.com/index.html with this command:
:
: if($url eq "") {$url="http://www.customautotrim.com/index.html"}
:
: I want it to be
: if($url eq "") {$url="http://www.customautotrim.com/"}
:
: The problem is that the index.html always shows up in the address bar.
: My host says I can't change the script like that, and there is not a
: scipt anywhere that I can use to achieve my goal.
If its Apache ... create a .htaccess and put
DirectoryIndex index.html
it should be there :)
Or, to do it in script way...
DirectoryIndex index.cgi
index.cgi
==========
$url ||= 'index.html';
print `cat $url`; #if unix!
------------------------------
Date: Thu, 22 Jul 1999 04:12:41 +0000
From: GiN <Ch1ckEn@hotmail.com>
Subject: Re: Kinda FORK
Message-Id: <37969A38.87EB50CA@hotmail.com>
David Cassell wrote:
> GiN wrote:
> >
> > i have one question:
> >
> > i opened a filehandle: <S>
> >
> > the program will read a line ($line) from <S> and work with it
> > function($line)
> >
> > so this will do: while (<S>) {
> > function($line);
> > }
> >
> > but function() has to be finished to read another line.
> >
> > how can i read another line and do a function($line) without waiting
> > for function($line) to finish?
>
> I'm not really sure what you want. Mike Eiringhaus has posted
> a response assuming you really want a fork() here. But it
> sounds more to me like you just want to be able to read the
> next line in, inside your while loop [perhaps some of the time].
> If that is the case, then you'll want to look up more examples
> of the angle operator <>, since anywhere you use <S> in scalar
> context, the operator will snag one more line for you [unless
> you've hit eof, of course].
>
> BTW, your code as listed won't work, since you read a line
> from S and store it in $_, then you throw the undefined
> variable $line into your &function. But you knew that, right?
>
> HTH,
> David
> --
> David Cassell, OAO cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician
thanks for the replies, i know the code won't work :)
what i wanted was: keep reading lines and work with it, without having to
wait for the function() to finish.
so i can handle many lines at once.
Gin
------------------------------
Date: Thu, 22 Jul 1999 09:38:16 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: LWP and frame
Message-Id: <7n7aho$eva4@news.cyber.net.pk>
: Hi,
: I tried to use LWP to fetch some web pages, but if the web pages
: contain frame, I get "Your browser does not support frame.". Can I get
: around this so that I can grab the informations inside each frame? Your
: help is really apprecialted.
"your browser doesn't support frames" .... thats actually nothing, frame
capable browsers download the same thing, but they don't process
<noframe>...</noframe> tag. Thus they aren't shown in frame-capable
browsers.... And yes, you can fetch each <frame src=...>
------------------------------
Date: Thu, 22 Jul 1999 14:59:35 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: Need Help with Virtual Avenue
Message-Id: <MPG.1201504087a94158989b68@news-server>
Rich writes ..
>...I found out I had to upload
>the perl script file as an ASCII instead of a binary (I use WS_FTP).
<deletia>
>...It really sucks that I would
>have to find out by this roundabout way and it wasn't mentioned in any
>of the Virtual Avenue FAQs or my Perl book.
... sorry .. I was going to respond .. but I just can't find the words
--
jason - remove all hyphens for email reply -
------------------------------
Date: 22 Jul 1999 00:13:54 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: newbie question: how put files from dir in array
Message-Id: <x7yag9e2yl.fsf@home.sysarch.com>
>>>>> "JO" == Jerome O'Neil <jeromeo@atrieva.com> writes:
JO> In article <MPG.11ffe3568dfb7cb7989d14@nntp.hpl.hp.com>,
JO> lr@hpl.hp.com (Larry Rosler) writes:
>> In article <37963E6A.6A71A59F@mail.cor.epa.gov> on Wed, 21 Jul 1999
>> 14:40:58 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
>>> Repeat after me: "I am Tiger Woods!"
>>
>> Repeat after me: "I am not Jean Van de Velde!"
JO> Van de Veld, when translated to english, means "Bill Buckner."
may you program in python for the rest of your life for bringing up that
name.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Thu, 22 Jul 1999 07:10:31 +0200
From: "Pavel Kotala" <pkotala@logis.cz>
Subject: Opne3 on Win32? Really nobody knows? Or primitive problem?
Message-Id: <932620299.801572@gate.logis.cz>
I tried to ask yesterday. But I received no answer. Now I don't know, if it
is because the problem is so difficult or because it is so primitive. So I
try ask once more. Thank to anybody very much form his time and any answer.
I need use pgp on Windows NT. I tried to use open3 similar to this one:
use FileHandle;
use IPC::Open3;
use strict;
my ( $pid, $got, $save, $errortext);
undef $/;
open3(\*IN, \*OUT, \*ERR, 'cmd');
print IN "dir c:\\\n";
close(IN);
$got = <OUT>;
close(OUT);
$errortext = <ERR>;
close(ERR);
open FILE, '>test2.txt';
print FILE $got;
close FILE;
However, this scripts stands frozen at line $got = <OUT>;
Does open3 work on Win32? If not, has anybody experience how to accomplish
this task?
Thank You
Pavel Kotala
------------------------------
Date: 22 Jul 1999 04:05:31 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: problem with hash of arrays
Message-Id: <7n65ab$tsc$1@lublin.zrz.tu-berlin.de>
badri <badri@wpi.edu> wrote in comp.lang.perl.misc:
>Anno Siegel wrote:
>
>[snipped]
>
>
>> >--- Code starts here ----
>> >
>> >#!/usr/bin/perl -w
>> >
>> ># Initialization of the variables ;
>> >
>> >$pos = 0;
>> >$number = 0;
>> >
>> >use MLDBM 'DB_File';
>> >use Fcntl;
>> >
>> >tie (%hash, 'MLDBM', 'testfile.db', O_CREAT|O_RDWR, 0660) or die $!;
>>
>> [more code snipped]
>>
>> You can't store references in a tied hash, not without extra
>> gymnastics like Storable, Data::Dumper or friends. Looking
>> at cpan, I see a module MLDBM::Serializer::Data::Dumper, which
>> may be specially suited for use with MLDBM.
>>
>
>But I was able to do it as long as the size of the array size did not exceed
>126. No segmentation faults or anything at all. Works just fine. Also when I
>had a look at the raw 'testfile.db' file, it looked ok. It contained all
>the elements = 0 except the number modified and also the key. And further
>modifications to any of the numbers got reflected in the file properly.
>Using MLDBM seems to be enough for the purpose.
I don't know about MLDBM, but any the modules I know that tie
hashes to a database will stringify references before storing
them away, which makes them useless. The following bit demonstrates
this:
#!/usr/bin/perl -w
use strict;
use DB_File;
my %hash;
# tie %hash, 'DB_File', '/tmp/x.db', O_CREAT|O_RDWR;
for ( my $i = 0; $i < 10; $i++ ) {
$hash{ $i} = [ $i ];
}
foreach my $i ( sort keys %hash ) {
print "$i => [ ", $hash{ $i}->[ 0], "]\n";
}
__END__
This runs fine, unless you uncomment the tie line, in which case
you get
Can't use string ("ARRAY(0x80fab74)") as an ARRAY ref while "strict refs"
in use at ./ttt line 14.
Unless the MLDBM documentation explicitly says otherwise, I wouldn't
trust it to handle references correctly.
[snip rest]
Anno
------------------------------
Date: Thu, 22 Jul 1999 14:51:47 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: recursive anonymous functions -- problem
Message-Id: <MPG.12014e6f1281fa0f989b67@news-server>
[ item posted to comp.lang.perl.misc and CCed to Tramm Hudson ]
Tramm Hudson writes ..
>Yes, but why do it that way when you can do it in a pure functional
>fashion?
a precursor .. I wasn't doing it "that way" .. I was correcting someone
else's misuse of a my declaration .. "that way" was inherited from them -
so perhaps you should CC them
allow me to answer your question with one of my own (albeit a little
smart) .. apart from impressing your friends - what advantage does your
method have ? .. the difference in benchmark was fairly trivial .. I only
ask because your language seems to suggest that this is universally
accepted as superior .. why ?
>So, go study your Friedman books some more and be amazed.
Friedman books ? .. you really do assume WAY too much
>print "7! = ", $f->(7), "\n";
>print "9! = ", $f->(9), "\n";
print "0! = ", $f->(0), "\n"; # prints 0 - oops
let me have a try at a factorial function
#--begin
sub factorial
{
my $res = 1;
for (1..$_[0]) { $res *= $_ }
$res;
}
#--end
Benchmark: timing 10000 iterations of Flashy, Original, Perl...
Flashy: 1 wallclock secs ( 1.12 usr + 0.00 sys = 1.12 CPU)
Original: 1 wallclock secs ( 1.34 usr + 0.00 sys = 1.34 CPU)
Perl: 1 wallclock secs ( 0.41 usr + 0.00 sys = 0.41 CPU)
now there's a benchmark improvement .. so adjust your reading list away
from Harvey and toward Larry - the boring solution is usually the best
(just in case it's not clear - I'm not implying that Larry Wall said that
- although he very well might have)
--
jason - remove all hyphens for email reply -
------------------------------
Date: 21 Jul 1999 22:34:40 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: regular Expression
Message-Id: <m3lnc9uwtb.fsf@moiraine.dimensional.com>
Tom Christiansen <tchrist@mox.perl.com> writes:
> [courtesy cc of this posting mailed to cited author]
>
> In comp.lang.perl.misc, Daniel Grisinger
> <dgris@perrin.dimensional.com> writes:
> :The perlfaq* documents are primarily political pieces
>
> I cannot believe that you believe that. But if they are, they should
> be deleted from the distribution. Before we do that, do you consider
> Larry's TMTOWTDI a political statement, or not?
I do, I think they should, and don't be ridiculous.
dgris
--
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 21 Jul 1999 22:41:48 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: regular Expression
Message-Id: <m37lntuwhf.fsf@moiraine.dimensional.com>
Tom Christiansen <tchrist@mox.perl.com> writes:
> And perlre (that's 5.005_57, mind you) also brands these "very
> experimental". I don't think it's fair to chastise someone
> for not using a "very experimental" feature.
No, _you_ branded them very experimental (and even posted the patch to
prove it). They seem to be reasonably stable to me and IIRC, both
Hugo and Ilya are using them fairly heavily.
I certainly don't worry about errors in the new core features nearly
so much as I worry about errors in any of the dozens (perhaps hundreds)
of CPAN modules that I have installed.
dgris
--
Train of thought derailed. 6 dead. Film at 11
------------------------------
Date: 21 Jul 1999 22:47:02 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: regular Expression
Message-Id: <m3yag9tho9.fsf@moiraine.dimensional.com>
Tom Christiansen <tchrist@mox.perl.com> writes:
> The rest of you should try not to pay too much attention to his frothings.
Of course not, he's only contributing actual _code_ to the core.
> He just gets pissed when I stop him from screwing up standard Perl or
> making horribly ugly things in the core that barely 1/1,000th of the
> populace cares about.
Judging by the comments on Slashdot concerning the new functionality
it appears that a far larger portion of the populace cares about this
than you want to admit. Why you don't care for it is still somewhat
of a mystery.
dgris
--
You'll feel much better once you've given up hope.
------------------------------
Date: Thu, 22 Jul 1999 10:28:54 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Scrollback perldoc in DOS-window?
Message-Id: <7n7dgn$elf8@news.cyber.net.pk>
: :Or: How am I supposed to read pods when the pipe
: :"|more" does NOT work with perldoc.bat -f ?
:
: Why not write something in perl to handle it?
Or see HTML documents :)
$blah = `perldoc @ARGV`;
open OUTPUT , ">myoutput"; #I don't use die() on Win :)
print OUTPUT $blah;
close OUTPUT;
------------------------------
Date: 22 Jul 1999 00:21:59 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Shortening the length of a string
Message-Id: <x7u2qxe2l4.fsf@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> In article <grrl3.632$Hf6.661@news2.mco> on Wed, 21 Jul 1999 17:58:13 -
LR> 0400, Travis Surgnier <surgie@bellsouth.net> says...
>> how to shorten it to $X characters. I've looked through the perlfaq and
LR> What objection do you have to substr?
LR> $short = substr $long, 0, $X;
or if you want to shorten in place do:
substr( $long, $X ) = '' ;
so it looks like substr IS the operation you are looking for.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Thu, 22 Jul 1999 01:42:12 -0400
From: "Travis Surgnier" <surgie@bellsouth.net>
Subject: Re: Shortening the length of a string
Message-Id: <seyl3.1235$477.3165@news1.mco>
Taking a closer look, I was mistaken in my first impression of the function,
thanks for the answers guys. I am a little bit wiser in the ways of perl now
:-)
Uri Guttman wrote in message ...
>>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
>
> LR> In article <grrl3.632$Hf6.661@news2.mco> on Wed, 21 Jul 1999
17:58:13 -
> LR> 0400, Travis Surgnier <surgie@bellsouth.net> says...
> >> how to shorten it to $X characters. I've looked through the perlfaq
and
>
> LR> What objection do you have to substr?
>
> LR> $short = substr $long, 0, $X;
>
>or if you want to shorten in place do:
>
> substr( $long, $X ) = '' ;
>
>so it looks like substr IS the operation you are looking for.
>
>uri
>
>--
>Uri Guttman ----------------- SYStems ARCHitecture and Software
Engineering
>uri@sysarch.com --------------------------- Perl, Internet, UNIX
Consulting
>Have Perl, Will Travel -----------------------------
http://www.sysarch.com
>The Best Search Engine on the Net -------------
http://www.northernlight.com
>"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Thu, 22 Jul 1999 00:12:03 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: special case : split this string...
Message-Id: <37969A12.1C50F822@rochester.rr.com>
Thien Syh wrote:
> i want to split the string into an array of string and return the array
> value.
> Could somebody help?
>
> ----- Personal Information -----
> <br>Name (First/Last):a
> <br>CompanyName: a
> <br>Street: a
> <br>City: a
> <br>State: a
> <br>Zip: a
> <br>Country: a
> <br>Phone: a
> <br>Fax: a
> <br>Email: a
> <br>
...
try the "split" function. It goes like:
@array=split /pattern/,$string;
See perlfunc for documentation.
------------------------------
Date: Thu, 22 Jul 1999 10:20:08 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: special case : split this string...
Message-Id: <7n7d09$elf7@news.cyber.net.pk>
: i want to split the string into an array of string and return the array
: value.
: Could somebody help?
:
: ----- Personal Information -----
: <br>Name (First/Last):a
: <br>CompanyName: a
: <br>Street: a
: <br>City: a
: <br>State: a
: <br>Zip: a
: <br>Country: a
: <br>Phone: a
: <br>Fax: a
: <br>Email: a
: <br>
You mean that data is in a scalar and you want it in an array?
&ConvertToArray ( <<EOT )
----- Personal Information -----
<br>Name (First/Last):a
<br>CompanyName: a
<br>Street: a
<br>City: a
<br>State: a
<br>Zip: a
<br>Country: a
<br>Phone: a
<br>Fax: a
<br>Email: a
<br>
EOT
sub ConvertToArray
{
split /\n/ , shift;
}
------------------------------
Date: Wed, 21 Jul 1999 23:03:02 -0500
From: "Paul Fulbright" <alcaron@espresso.wustl.edu>
Subject: SSI in Perl CGI output
Message-Id: <932616598.057.54@news.remarQ.com>
Hi, I am curious as to wether or not you can use server side includes in the
output of a CGI-script in Perl, the particular script I am using is the
robboard (www.robplanet.com) and it uses three template pages, these are
where I want the SSI to work, unfortunately when I ad <!--#include
file="file.txt"--> it does nothing, often times it will give me an internal
server error, other times it just doesnt show that at all, like if I use SSI
and it has a problem normally it gives that [There was an error proccessing
this directive] error, but from the script it doesnt show up at ALL, the
mime type in the CGI script seems to be set to text/html.
does anyone know how I get the SSI to work in the output of the CGI script?
I would GREATLY appreciate any and all help!
email me @ alcaron@email.com
Thanks
------------------------------
Date: Thu, 22 Jul 1999 09:47:01 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: SSI in Perl CGI output
Message-Id: <7n7b26$eva5@news.cyber.net.pk>
: Hi, I am curious as to wether or not you can use server side includes in
the
: output of a CGI-script in Perl, the particular script I am using is the
: robboard (www.robplanet.com) and it uses three template pages, these are
: where I want the SSI to work, unfortunately when I ad <!--#include
: file="file.txt"--> it does nothing, often times it will give me an
internal
That is because Apache API doesn't allow to grab the output of mod_cgi
and process it through mod_include!
It will be possible in Apache 2.0.
I don't know about other web servers....
: server error, other times it just doesnt show that at all, like if I use
SSI
: and it has a problem normally it gives that [There was an error
proccessing
: this directive] error, but from the script it doesnt show up at ALL, the
That is because mod_include (the ssi parser) opens the file (static) and
parses the ssi tags. And mod_cgi forks CGI and sends it output directly
to browser...
: mime type in the CGI script seems to be set to text/html.
: does anyone know how I get the SSI to work in the output of the CGI
script?
mod_perl
: I would GREATLY appreciate any and all help!
:
: email me @ alcaron@email.com
:
: Thanks
------------------------------
Date: 22 Jul 1999 05:22:47 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: STDIN redirection
Message-Id: <7n69r7$u28$1@lublin.zrz.tu-berlin.de>
Mark Zeiger <m.zeiger@worldnet.att.net> wrote in comp.lang.perl.misc:
>I have written a program that will either read a (quoted) string from the
>command line or, if the string is missing, then the string is read from
>STDIN. Is there a way that I can tell if STDIN is redirected or piped from
>another program. I want to do this because I handle input from STDIN in a
>slightly different manner and I do input from the command line.
if ( -t STDIN ) {
# input from tty
} else {
# input from somewhere else
}
Anno
------------------------------
Date: Thu, 22 Jul 1999 04:18:23 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: TIe::IxHash
Message-Id: <FF97yn.D4u@world.std.com>
Joe Rocklin <Joe.Rocklin@sdrc.com> writes:
>This is a multi-part message in MIME format.
>--------------88F137D6D524C89135A7A9F8
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
Yuch! What is this ugly MIME stuff? Why is in the middle of a text
posting?
>Has anyone ever used this module to print the contents of a hash in
>insertion order? I try it, but it doesn't seem to work.
It has worked any time that I've tried it. Although I've been somewhat
tempted to pull it out of some of the programs that I use it
for. (converting it back to a combination of array and hash. The
programs are noticably slower than they were before I added the
Tie::IxHash.)
Can you show an example where it doesn' work?
Without an example, I come up with a couple of guesses on your
problem:
If you create the Tie::IxHash in a subroutine, you must return a
reference to the hash, don't just put the hash itself as the return
value. Subroutines in perl flatten their return value into a list to
return to their caller. The subroutine may flatten the hash out in
insertion order, but the (non Tie::IxHash) hash you collect the
returning list in doesn't necessarily need to keep it that way.
sub return_an_unordered_hash_slowly {
tie %ixhash, 'Tie::IxHash';
while(<>) {
$ixhash{$_} = $.;
}
return %ixhash; # line and line number return sequentially
}
# %hash is a normal hash, so won't maitain the order passed to it.
%hash = return_an_unordered_hash_slowly();
Another potential slip up is that perl autovivfies the references to
hashes needed for multidimensional data structures, but a hash based
on Tie::IxHash creates regular hashes, not Tie::IxHashes.
use Tie::IxHash;
my %word;
tie %word, 'Tie::IxHash';
while(<>) {
my @word = split /\W+/;
for my $word (@word) {
for my $letter (split //, $word) {
$word{$word}{$letter}++;
}
}
}
for my $word (keys %word) {
print "$word:\n";
for my $letter ( keys %{$word{$word}} ) {
print " $letter: $word{$word}{$letter}\n";
}
}
--
Andrew Langmead
------------------------------
Date: 22 Jul 1999 04:27:34 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: waitpid crashes perl
Message-Id: <7n66jm$ttk$1@lublin.zrz.tu-berlin.de>
Philip H. Dye <Philip_Dye@norstanconsult.com> wrote in comp.lang.perl.misc:
>When running within a signal handler, POSIX waitpid() causes perl to crash
>deep under its perl implementation malloc() gets called while the main
>thread is also executing malloc().
Yes. Perl isn't reentrant and malloc() (perl's or other) is a particularly
likely candidate.
>Has anyone run into this behavior before ? Any known work arounds ?
A suggested workaround is to do as little as possible in the signal
handler, for instance just set a preset variable (not an undefined
one). Of course, the main program will have to check that variable
periodically and act accordingly, which can be a nuisance to do.
>This has been plaguing me since I wrote this application for a client and
>I'd really like to close the book on this issue. It would also result in a
>large company maintaining a medium size Data Warehouse using perl.
>
>Please to Philip_Dye@norstanconsult.com since I'm not on the list every
>day.
As the man said, "Post here, read here". Oh okay... posted and mailed.
Anno
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 222
*************************************