[17425] in Perl-Users-Digest
Perl-Users Digest, Issue: 4845 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 8 11:05:31 2000
Date: Wed, 8 Nov 2000 08:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973699508-v9-i4845@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 8 Nov 2000 Volume: 9 Number: 4845
Today's topics:
Re: $password = crypt($pass, ar); <dsimonis@fiderus.com>
Re: [Way OT] Re: OOP and information hiding <mjcarman@home.com>
cleaning up user input <--www forms <eyoung@noway.com>
Re: FormMail.pl with file attachment support? <no-mailr@blabla.org>
Re: getgrgid does not work with nis (perl 5.6.0) (Anno Siegel)
Re: Help -- msgget with key >= 0x80000000 fails <geoff-at-farmline-dot-com@127.0.0.1>
Re: HELP Winows NT Mail::Sender <camerond@mail.uca.edu>
Re: Help with HTML::Parser module <bart.lateur@skynet.be>
Re: Help with HTML::Parser module <preetham@india.hp.com>
Re: HELP <jhansknecht@hanstech.com>
Re: Installation Problem with ActiveState's Module WWW- (Johannes Eble)
Re: javascript in perl CGI scripts. <preetham@india.hp.com>
Re: MS SQL & Perl <hartleh1@westat.com>
Net::LDAP + URI::ldap -> referrals <godoy@conectiva.com>
Re: Newbie column data question <dlorre@caramail.com>
Re: Passing args as references <gods-apollo@home.com>
Perl on Win32 - System Call error numbers <KPhilbrick@carolina.rr.com>
Re: Perl prototype for program in c (Anno Siegel)
Re: Pushing a hash on to a stack... <jeffp@crusoe.net>
Searching for many words in large string <tony@softins.clara.co.uk>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 08 Nov 2000 09:54:01 -0500
From: Drew Simonis <dsimonis@fiderus.com>
Subject: Re: $password = crypt($pass, ar);
Message-Id: <3A096909.C9398190@fiderus.com>
Gwyn Judd wrote:
>
> Yeah but then you are stuck if the user can't remember the password and
> you have to email it to them. Of course, the whole idea of emailing
> someone a password is so ridiculous from the security front I don't know
> why I'm mentioning it.
>
What is ridiculous from a security perspective is often ignored
in favor of what is necessary from a business perspective. I know
of many very large companies where forgotten passwords are e-mailed
to the individual, or left on voicemail, or told directly over the
phone. None good, but when there is no other way...
------------------------------
Date: Wed, 08 Nov 2000 08:10:51 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: [Way OT] Re: OOP and information hiding
Message-Id: <3A095EEB.C5B63648@home.com>
Gwyn Judd wrote:
>
> I was shocked! How could Abigail <abigail@foad.org>
> say such a terrible thing:
>
> >Perl lacks the glue to bind objects together. You can still build
> >nice things if everyone makes lego bricks; you can also make things
> >together with velcro, or by using bolts. But velcro doesn't stick
> >to lego. I better make lego bricks when I want to reuse someone
> >else lego bricks, and work hard if I also want to incorperate
> >someones velcro.
>
> Ah but what if you wrap the velcro straps around the lego blocks?
That's the hard way. You have to peel off the backing and attach the
sticky side of the velcro to the lego. :)
------------------------------
Date: Wed, 08 Nov 2000 08:45:27 -0600
From: eyoung <eyoung@noway.com>
Subject: cleaning up user input <--www forms
Message-Id: <3A096707.D69E69DE@noway.com>
Sometimes an idiot will enter tons of garbage into a text area, such as
in a message
board. If they keep typing without any spaces...the end result is a very
long line in the next web page. The following code will look for a word
that is over 80 characters and divide it into two pieces. However if the
evil user types 180 characters the fist line will end up with 80
characters and the remaining 100 will be on the next line not to mention
if the 180 characters start at the end of the section....how do I change
my to make it so that after 80 charaters a new line will be started. I
tried doing it in the html by using the width and size settings on
objects but that does not work either.
$messagetext =~ s/(\b[a-zA-Z]{80})([a-zA-Z]+\b/ "$1­ $2" /ge;
email eyoung@NOSPAMncsa.uiuc.edu
------------------------------
Date: Wed, 08 Nov 2000 15:42:42 +0100
From: AH <no-mailr@blabla.org>
Subject: Re: FormMail.pl with file attachment support?
Message-Id: <3A096662.3DE6CC93@blabla.org>
jesus X wrote:
> Does anyone know of a Perl script like "Matt's" FormMail.pl program that
> supports file attachments? A single attachment is all that's needed...
>
> --
> jesus X [ Booze-fueled paragon of pointless cruelty and wanton sadism. ]
> email [ jesusx @ who.net ]
> web [ http://www.burntelectrons.com/ ]
> tag [ The Universe: It's everywhere you want to be. ]
> warning [ If at first you don't succeed, reload. ]
I have used Mail::Sender for this.
Regards
--
Andre H. UNIX System Administrator
------------------------------
Date: 8 Nov 2000 15:42:52 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: getgrgid does not work with nis (perl 5.6.0)
Message-Id: <8ubs9s$1ld$1@lublin.zrz.tu-berlin.de>
Olivier LACROIX <Olivier.Lacroix@ciril.fr> wrote in comp.lang.perl.misc:
>Hello.
>
>I have a problem with getgrgid (and with all commend getgr*). It returns
>the correct value for all local groups, but returns NULL value for all
>groups in the NIS database. I think there is a bug, because all commands
>getpw* work (even with NIS).
If there is a bug, it isn't in perl. The interaction with NIS is
done on system level in the like-named library call getgrgid(3).
Perl only hands the results down (up?).
I'd rather suspect a malfunction of the NIS system. Does niscat
(or whatever you use for the purpose) show you the missing groups?
Anno
------------------------------
Date: Wed, 8 Nov 2000 14:07:31 -0000
From: "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1>
Subject: Re: Help -- msgget with key >= 0x80000000 fails
Message-Id: <8ubmjq$1he$1@soap.pipex.net>
"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn90ifbf.boe.mgjv@martien.heliotrope.home...
> One thing you could do, in the meantime, is check the Perl code to see
> what goes on when you call these functions, and compare them with what
> they should do. It is possible that the Perl 5.005_03 code uses an int
> when they should use a key_t. Perl 5.6.0 uses
>
> key = (key_t)SvNVx(*++mark);
>
> which looks like a cast from a double to a key_t. Maybe that is just not
> correct. Try it out in C, and see if it works. Check the 5.005_03
> sources first, to see how exactly it happens there (doio.c).
> Is this the perl that comes with RedHat? If so, chuck it and compile
> your own. Your problem might just go away. it wouldn't be the only thing
> that suddenly would repair itself.
Heh. Tried that. However it seems that there's an error going on somewhere
in linux: linux's key_t is an int, which (apparently) implies a signed int.
As such my understanding is that my specifying a key of ffe0ffe0 _should_
fail?
Any thoughts appreciated.
Geoff
------------------------------
Date: Wed, 08 Nov 2000 09:36:29 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: HELP Winows NT Mail::Sender
Message-Id: <3A0972FD.7577CB6@mail.uca.edu>
[the dead comp.lang.perl del from followups]
Dave E wrote:
>
> well, if you're willing to try advice from a non-expert,
>
> I tried to install Mail::Sender via ppm.pl and picked up an error message. As
> well, use Send::Mail came up with an error (sounds like what you got too).
>
> So, I suspect the answer is that Mail::Sender is not compatible with the Win32
> version of Perl. Or, that something else has to be installed first.
>
> If you want a work-around, I have sent mail by shelling out to blat.exe. A
> feeware mailer you can pick up. If you can't get Mail::Sender working, you
> could use this.
>
> David...
>
> P.S. If you do get Mail::Sender going, send me an email :) it's cleaner that
> blat.
Mail::Sender works fine on my machines (NT & 98). It's pure Perl, so you
can install it manually. I don't think Jenda has had time to make a 6xx
PPM package (he has a few months left in the Czech army), so I'd just
stick it in yourself (mine is in the .../site/lib/Mail directory, so it
shows up in @INC), pod2html the docs, and link them into your HTML help
files. A little work, but intellectually satisfying.
I don't think there is anything out there called Send::Mail (although it
might be somewhere), but there is Mail::Sendmail which has good
functionality, too.
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: Wed, 08 Nov 2000 14:35:35 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Help with HTML::Parser module
Message-Id: <a8oi0ts1vnlg97hmlt4io41c355sjukhsd@4ax.com>
Juan Eliseo Carrasco Díaz wrote:
>I trying to delete all the <font face="Arial"> and <font face="Times new
>roman"> marks and its respective </font> marks of my HTML pages, but I
>can't find an easy way.
I can understand. Filtering out <font> and </font> tags is easy, but the
problem is that you want to selectively filter them out! So you have to
link the </font> tags to their respective <font> counterpart. Therefore,
you need to get the HTML file's tree structure. I think
HTML::TreeBuilder can do that (package: HTML-Tree; built on top of
HTML::Parser), but:
* It is VERY memory intensive. I've had a test case where I had an
out-of-memory error for processing a 15k HTML file. Keeping a whole
database of records in memory all at once (25000 items, the printed out
version makes a book of over 1000 pages), on the same computer, is no
problem. Now, 15k is a small HTML file.
* If your HTML file isn't 100% complying to the official specs, I think
this module will choke on it.
Well, *if* you can get this to work, you'll get a tree structure, which
you then need to reorganize. Geez, that's pretty hard. And then, you
need to make the reorganized tree spit out a HTML file again.
HTH,
Bart.
------------------------------
Date: Wed, 8 Nov 2000 08:49:16 -0600
From: "preetham" <preetham@india.hp.com>
Subject: Re: Help with HTML::Parser module
Message-Id: <8ubp6a$inc$1@web1.cup.hp.com>
there is a callback feature in HTML::Parser. I think u need to create a sub
class of it . it calls 'start(..) ' method whenever it finds a tag & a
'end(..)' method when it finds ending tag (/tags). using this u can easily
remove those font tags & its not memory intensive if u do it properly.
u can keep a count which is incremented as u find a <..> tag and decremented
for each </..> tag . this will help u remove those <font...> and </font>
tags efficiently
"Juan Eliseo Carrasco Díaz" <eliseo@cocoon.ulpgc.es> wrote in message
news:3A094BCF.2020E154@cocoon.ulpgc.es...
> I trying to delete all the <font face="Arial"> and <font face="Times new
>
> roman"> marks and its respective </font> marks of my HTML pages, but I
> can't find an easy way.
>
> Example:
>
> Text .... <font face="Arial"> more text .... <b> xxx </b> ....
> .... <font size=+1> .... </font> ....
> <font face="Times new roman"> <font color=red> .... </font> ...
> .... </font> .... </font>
>
>
> Desired result:
>
> Text .... more text .... <b> xxx </b> ....
> .... <font size=+1> .... </font> ....
> <font color=red> .... </font> ...
> .... ....
>
>
> Somebody say me that HTML::Parse module can help me. I downloaded it. I
> read the documentation, but I don't know how to start. (I'm a beginner).
>
------------------------------
Date: Tue, 7 Nov 2000 19:46:15 -0500
From: "John Hansknecht" <jhansknecht@hanstech.com>
Subject: Re: HELP
Message-Id: <8ubl4301uru@enews3.newsguy.com>
Go to NT Help index and lookup the "at command". This is the NT equivalent
to cron and you can use it to schedule a job to run on a regular basis.
John Hansknecht
jhansknecht 'at' hanstech.com
<nodo70@my-deja.com> wrote in message news:8u9p41$2bc$1@nnrp1.deja.com...
> Anyone can help me to write a simple code that run every 5 minutes? I
> know how to set it up in Unix for cron job but I am using NT I just wan
> to to run my program to check the system every 5 mins. Thanks for your
> help.
>
> -nodo
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Wed, 08 Nov 2000 14:18:07 GMT
From: johannes.eble@arcormail.de (Johannes Eble)
Subject: Re: Installation Problem with ActiveState's Module WWW-Search
Message-Id: <3a096011.198034408@news.btx.dtag.de>
Sorry, despite the header, this question is in English!
On Wed, 08 Nov 2000 13:25:12 GMT, johannes.eble@arcormail.de (Johannes
Eble) wrote:
>Hello,
>
>I want to install the ActiveState Modul WWW-Search on a Win98 PC
>without Internet connection.
>
>I have downloaded the *.zip file from
>http://www.ActiveState.com/PPMPackages/5.6/zips
>
>(another (Internet) PC WITHOUT Perl) and transferred it to the local
>PC.
>Then I have unzipped the files with WinCommander into the path
>D:\perl.
No, sorry. It is D:\perl\wwwser\
>
>As stated in the readme file I opened a dos-console, changed into that
>directory and entered the command:
>ppm install WWW-Search.ppd
>
>I get the error message: "Error read ./"
>
>I get the same error if I write "ppm install WWW-S~1.ppd" instead.
>
>Thanks for any help :)
>
>Johannes
Thanks in advance.
Johannes
------------------------------
Date: Wed, 8 Nov 2000 08:54:18 -0600
From: "preetham" <preetham@india.hp.com>
Subject: Re: javascript in perl CGI scripts.
Message-Id: <8ubpfo$is0$1@web1.cup.hp.com>
this looks like some error in your javascript. the line no which IE gives is
usually wrong. Try debugging javascript using script debugger(i think it
can be downloaded for free) or Visual studio.
"steve" <home@aidans0.demon.co.uk> wrote in message
news:973639050.24885.0.nnrp-09.c1ed46c5@news.demon.co.uk...
> Hi i am trying to run CGI scripts on micro$oft Windows ME with JavaScript
> embedded. I am sure that I've made a trivial mistake in copying the code
> from my Linux installation but no matter what I try, Micro$oft IE always
> gives the error on line 5 char 15.
>
> Where is the line 5 refered to in the error from IE?
>
> PS On Linux my code works fine. On Windoze I'm using IndigoPerl.
>
> Here's the whole file
>
> #!perl -w
> BEGIN {
> use CGI::Carp qw(carpout);
> open(LOG, ">>C:\\perl\logs\mycgi-log.log") or
> die("Unable to open mycgi-log: $!\n");
> carpout(LOG);
> }
>
> use strict;
> use CGI qw/:standard :netscape/;
> use CGI::Carp qw(cluck fatalsToBrowser);
> my($JSC)=<<END;
>
> function CSURLPopupShow(formName, popupName) {
> var form = CSFindElement(formName,0);
> var popup = form.elements[popupName];
> location.replace(popup.options[popup.selectedIndex].value);
> popup.selectedIndex = 0;
> }
> function IsIE() { return CSAg.indexOf('MSIE') > 0;}
> function CSIEStyl(s) { return document.all.tags('div')[s].style; }
> CSAg = window.navigator.userAgent;
> CSBVers = parseInt(CSAg.charAt(CSAg.indexOf('/')+1),10);
> function CSFindElement(n,ly) {
> if (CSBVers < 4) return document[n];
> var curDoc = ly ? ly.document : document; var elem = curDoc[n];
> if (!elem) {
> for (var i=0;i<curDoc.layers.length;i++) {
> elem = CSFindElement(n,curDoc.layers[i]);
> if (elem) return elem;
> }
> }
> return elem;
> }
> END
>
> ;
>
> my $q = new CGI;
> my
>
($book_image,$book_id,$book_price,$book_isbn,$book_text,$book_author,$book_t
> itle,$book_type);
>
> my ($site_dir) = "http://localhost/truecrime";
> my ($img_dir) ="http://localhost/truecrime/images";
> my ($data_dir) ="c:\\perl\\htdocs\\truecrime";
>
> #my ($site_dir) = "http://truecrime";
> #my ($img_dir) ="http://truecrime/images";
> #my ($data_dir) ="/home/truecrime";
>
> my ($script_dir) = "/jscript";
>
> add_book_to_cart($q) if $q->param('add');
> $book_id = $q->param('book_id');
> set_book_details();
> my($labels,$values) = make_book_list();
>
> print $q->header(-expires=>"-1d");
> print $q->start_html({-bgcolor=>"#ffffff",
> -script=>[ {-language=>"JavaScript1.2",-src=>"$JSC"} ]},
> # -script=>[ {-language=>"JavaScript1.2",
> # -src=>"$script_dir/standard.js"}],
> # {-language=>"JavaScript",
> # -src=>"$script_dir/rollover.js"}],
> # -onLoad=>"CSScriptInit();"},
> "Buy Crime Books");
>
> print $q->div({align=>'center'},
> table({-border=>0, -cellpadding=>2,-cellspacing=>0, -width=>500},
> Tr(td({-colspan=>2},img({-width=>326,-src=>"$img_dir/book_logo.gif"}))),
>
> Tr(start_form({-name=>"change_book"}),
> td("Choose a book :"),
> td(popup_menu({-name=>"chooser",-labels=>$labels, -values=>$values,
> -onChange=>"alert('okay');CSURLPopupShow('change_book','chooser');"})),
> end_form()),
>
> Tr(td({-height=>20},$book_title),
> td({-align=>"center", -rowspan=>7},
> img({-width=>300, -src=>$book_image}))),
> Tr({-height=>20},td("$book_isbn")),
> Tr({-height=>20},td("$book_author")),
> Tr({-height=>20},td("$book_type")),
> Tr({-height=>20},td(" $book_price")),
> Tr({-height=>20},td(
> start_form(-name=>'addform'),
> submit({-name=>'add', -value=>'Add'}),
> hidden({-name=>'book_id'}),
> hidden({-name=>'cart_id'}),
> end_form())),
> Tr(td($book_text))
> ));
>
> print $q->div({align=>'center'},
> table({-border=>0, -cellpadding=>2,-cellspacing=>0, -width=>500},
> Tr(td(a({-href=>"$site_dir/index.html",
> -onmouseover=>"return CSIShow('home',1)",
> -onmouseout=>"return CSIShow('home',0)"},
> img({-src=>"$img_dir/home_link1.gif", -border=>0}))),
> td(a({-href=>"$site_dir/mags.html",
> -onmouseover=>"return CSIShow('mags',1)",
> -onmouseout=>"return CSIShow('mags',0)"},
> img({-src=>"$img_dir/mag_link1.gif", -border=>0}))),
> td(a({-href=>"$site_dir/books.html",
> -onmouseover=>"return CSIShow('books',1)",
> -onmouseout=>"return CSIShow('books',0)"},
> img({-src=>"$img_dir/book_link1.gif", -border=>0}))),
> td(a({-href=>"$site_dir/about.html",
> -onmouseover=>"return CSIShow('about',1)",
> -onmouseout=>"return CSIShow('about',0)"},
> img({-src=>"$img_dir/about_link1.gif", -border=>0}))))));
>
> print $q->dump;
> print $q->end_html;
>
> sub set_book_details {
> # open the file containing the details of the book
> read_book_file();
> $book_image = "$site_dir/books/images/$book_id.jpg";
> }
>
> sub read_book_file {
> my ($filename) = "$data_dir/books/details/$book_id.txt";
> my ($details,@contents);
>
> open (READ, $filename) or croak ("Couldn't open file $filename");
> (@contents) = <READ>;
> close (READ);
> ($details,$book_text)=splice @contents;
>
> ($book_isbn,$book_author,$book_type,$book_price,$book_title)
> = split ':', $details;
> return;
> }
>
> # read the book list and make a hash for labels from the name and id.
> sub make_book_list {
> my (%list,@arry,$name,$id,$label);
> my ($n) = 0;
> my ($url) = "$site_dir/cgi-bin/show_book.pl";
> open (READ,"$data_dir/books/index.txt")
> or croak("open_read error opening catalog");
> while(<READ>) {
> chomp;
> ($id,$name)=split ":",$_;
> $label = "$url?book_id=$id";
> $list{$label} = $name unless $id == $book_id;
> $arry[$n++] = $label unless $id == $book_id;
> }
> return \%list,\@arry;
> }
>
> sub add_book_to_cart {
> $q->param(-name=>'cart_id',-value=>'1');
> }
>
>
>
------------------------------
Date: Wed, 08 Nov 2000 10:41:04 -0500
From: Henry Hartley <hartleh1@westat.com>
Subject: Re: MS SQL & Perl
Message-Id: <3A097410.4E83B7D@westat.com>
Rich Parker wrote:
>
> But that still leaves my last question unanswered: What about the 'make' after the 'perl
> makefile.pl', how did the rest of you get around that w/o having a Unix Shell???
> HELP!!
On WinNT, you really don't need to do all this. Git your browser out
and go to
<http://www.activestate.com/Products/ActivePerl/docs/faq/activeperl-faq2.html>
and read what you find there. Then, use ppm to install your modules.
You'll be glad you did.
--
Henry Hartley
Westat
Rockville, Maryland, USA
------------------------------
Date: 08 Nov 2000 11:42:45 -0200
From: Jorge Godoy <godoy@conectiva.com>
Subject: Net::LDAP + URI::ldap -> referrals
Message-Id: <kpwveevaui.fsf@dagon.conectiva>
Hi!
Is there anybody working with Net::LDAP and URI::ldap (or any other
module) that's being able to follow server REFERRALs?
I'm not being able to make it work, with the LDAP queries never being
answered when they are in other LDAP server.
If I connect to any LDAP server and ask for something that I already
know it's there, then I get the correct answer...
Thanks,
--
Godoy. <godoy@conectiva.com>
Departamento de Publicações Conectiva S.A.
Publishing Department Conectiva Inc.
------------------------------
Date: Wed, 08 Nov 2000 14:40:02 GMT
From: Dominique Lorre <dlorre@caramail.com>
Subject: Re: Newbie column data question
Message-Id: <8ubok1$k0b$1@nnrp1.deja.com>
In article <8ubf9s$ctb$1@nnrp1.deja.com>,
jocke1s@my-deja.com wrote:
> Hi list,
>
> somewhat of a newbie problem here. Please let me know what list
> I should post on if this is the wrong one.
>
> I have a file file looking like this:
>
> 1234
> 9835489435
> 99233
> 2000
> 9374
> 222
> .
> .
> more numbers
> .
> .
> .
>
> or something similar. Just a file with column data.
> I need to get output that looks like this.
>
> some text whatever on the first line , "1234 9835489435 99" // @
> "233 2000 9374 222 ........... more numbers ..... " // @
> "....more numbers ...")
> some other text
>
> So my problem is that I need to split the numbers of the
> first line at a specific location even if it means the
> number is printed on two lines.
Something is unclear here : you put a space between 2 numbers, so can
you have something like : "1234 384379374327 " ?
>
> I tried
> printf "enter file of elements: ";
> $el = <STDIN>;
> open (ELEMENTS, "$el") || die "Can't find file $el $!\n";
> # where $el is my file with column data
> while(<ELEMENTS>) { push (@list, split(" ",$_) ) } close(ELEMENTS);
> # print @list prints the whole list on one line.
You should have a look at the join() function.
>
> Any ideas how to do this is most welcomed. Even just a hint
> on what I could use (splice, split etc)
The idea is the following:
1) get all the file in one string
2) convert the newline to spaces
3) use substr to get the exact width you require
4) use join to print the result
<------------------------------------------------>
#!/usr/bin/perl -w
use strict ;
my(@list, $width, $len, $pos, $result) ;
$width = 16 ; # elem size
open (ELEMENTS, "num.txt") || die "Can't find file: $!\n";
# get all lines into one string
undef $/ ;
$result = <ELEMENTS> ;
close(ELEMENTS) ;
# convert the newlines to spaces
$result =~ tr/\n/ / ;
$len = length($result) ;
$pos = 0 ;
while ($pos <= ($len-$width)) {
push (@list, '"' . substr($result, $pos, $width) . '"') ;
$pos += $width ;
}
if ($pos < $len) {
push (@list, '"' . substr($result, $pos, $len-$pos) . '"') ;
}
print join(" @ // ", @list) ;
<---------------------------------------------------->
HTH
PS: This time i haven't made any change on the fly ;)
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 08 Nov 2000 15:37:10 GMT
From: "John" <gods-apollo@home.com>
Subject: Re: Passing args as references
Message-Id: <GqeO5.1203$U46.66354@news1.sttls1.wa.home.com>
Yes.. if you declare the variable outside the function:
my $chub;
$yourfawn = 1;
chubby();
If you write a function that:
sub chubby ()
{
my $temp = $yourfawn;
$chub = temp;
}
There is no point in returning anythinga s you are directly accessing the
variable as you have already changed it. What if I need to use this
function more than once for different variables. Sure.. this does solve my
problem for what I need to do.. for one variable. And this is what I have
used. But what happens when I need the function to do the same with $hat
and $cat or $blue and $nosedive? I'm stuck.
I'm trying to use sharp code.. where the function only touches what is
passed to it.. and the only things that come out are passed out. When I
want to edit an outside variable in the function I want to do it because I
explicitly said so.. not because my code was written so it can edit other
variables sloppily.
>In Perl, function arguments are always passed by reference.
>
> sub set_to_37 {
> $_[0] = 37;
> }
>
> $x = 19;
> set_to_37($x);
> print $x, "\n"; # Prints 37
------------------------------
Date: Wed, 08 Nov 2000 15:10:34 GMT
From: "Kevin Philbrick" <KPhilbrick@carolina.rr.com>
Subject: Perl on Win32 - System Call error numbers
Message-Id: <K1eO5.8587$I8.1186969@typhoon.southeast.rr.com>
Is there anyway to determine what an error number, returned from a system
call, means? I am getting a 65280 error number with no text explanation.
# run the command
my @command = ("[path]xyz.exe");
if( system("@command") ) {Logger("Error Running Job: $?: $@")}
Logger is a sub that prints whatever to an error log.
Here is the output:
Error Running Job: 65280:
Any help would be most appreciated.
KevinP
------------------------------
Date: 8 Nov 2000 15:19:46 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl prototype for program in c
Message-Id: <8ubqui$1jr$1@lublin.zrz.tu-berlin.de>
Milan Miladinovic <vortex@ptt.yu> wrote in comp.lang.perl.misc:
>Be shocked on the other place!
>Here is people who need help. I'm asking only to give me right way to
>resolve my problem... like the others do.
Oh no, you don't understand how this works.
We sometimes try to help people who show that they have made an
effort to solve their own problem. You have shown nothing of that
sort.
Moreover, the problems you have shown look very reasonable, and I
bet a majority here would rather have you think about them than
answer them for you.
Now quit lurking on Usenet and do your homework.
Anno
------------------------------
Date: Wed, 8 Nov 2000 10:17:22 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Pushing a hash on to a stack...
Message-Id: <Pine.GSO.4.21.0011081010110.11113-100000@crusoe.crusoe.net>
On Nov 8, Mark-Jason Dominus said:
>In article <8FE6A4D54craznar@130.102.2.1>,
>Christopher Burke <craznar@hotmail.com> wrote:
>>I am gathering by the tone of these responses that people are incapable of
>>answering a question
>> - or that Perl is incapable of pushing hashes onto a
>>stack.
>
> pushing hashes onto a stack in Perl requires references.
>
>>Either way I will write my on push/pop to get around the problem.
>
>When you do, I would love to see it. Your previous suggestion did
>indeed involve references.
[THIS IS NOT A GOOD SOLUTION, in my opinion, because it generates a very
large and unweildy array. There's NO REASON NOT to use references.]
It can be done without references, and I fear for my life for displaying
such a horrid and ugly solution here:
%hash = generate_hash_somehow();
$len = 2 * keys(%hash);
push @array, %hash, $len;
Then, for reading the most recently added hash:
$len = pop @array;
%hash = splice(@array, -$len);
If you want to allow both forwards and backwards reads:
%hash = generate_hash_somehow();
$len = 2 * keys(%hash);
push @array, $len, %hash, $len;
and then read via
$len = pop @array;
%hash = splice(@array, -$len);
pop @array;
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Wed, 8 Nov 2000 14:29:26 -0000
From: "Tony Mountifield" <tony@softins.clara.co.uk>
Subject: Searching for many words in large string
Message-Id: <4tdO5.58560$mv2.244955@news2-win.server.ntlworld.com>
Hi, I wonder if anyone can improve on this.
I have a potentially long list of words, and need to know which, if any,
appear in a large string. Assume the string and the list of words are
already folded to lower case.
My idea:
study $string;
@found = grep {$string =~ /\b$_\b/} @wordlist;
Can this be improved upon, for speed?
Cheers,
Tony
------------------------------
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 4845
**************************************