[12189] in Perl-Users-Digest
Perl-Users Digest, Issue: 5789 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 26 12:07:25 1999
Date: Wed, 26 May 99 09:00:27 -0700
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, 26 May 1999 Volume: 8 Number: 5789
Today's topics:
DBI/DBD problem <bierma.jacob@wag.nl>
FileHandle problems tertullian@my-dejanews.com
fork spawning off and restarting program over and over? <jkit@jpmorgan.com>
gdchart perl module installation problem cyewmeng@my-dejanews.com
Re: Get spaces off. (Andrea L. Spinelli)
Help needed! (hannibal josh)
Re: Help needed! <upsetter@ziplink.net>
Re: jerri rigged forms instead of CGI... bad? <matt@betcha.net>
Re: leeches, compilers, and perl, oh my (all mine?) <gbartels@xli.com>
Re: leeches, compilers, and perl, oh my (all mine?) <tchrist@mox.perl.com>
Re: leeches, compilers, and perl, oh my (all mine?) <tchrist@mox.perl.com>
Re: My old perlscripts won't run anymore <upsetter@ziplink.net>
Need help with sub routines <officemail@megsinet.net>
Re: Need help with sub routines (Greg Bacon)
Re: Password Protect <fruffet@kaptech.com>
Re: regexp question <aqumsieh@matrox.com>
Re: require problem <upsetter@ziplink.net>
Re: What's wrong with this hit counter? (Matthew Bafford)
Re: why doesn't my first program work?? (ok , third or <upsetter@ziplink.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 26 May 1999 17:02:51 +0200
From: "Jacob H. Bierma" <bierma.jacob@wag.nl>
Subject: DBI/DBD problem
Message-Id: <374C0D1B.122411DC@wag.nl>
--------------585A891F4A85CFFB4C5C4387
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi,
I am trying to connect to a MySql database via a Perlscript. I have
tested the script on a Winnt-box with Perl and MySql and a Linux-box
with the same configuration. All testing worked fine.
However, when we upload the script to our provider, we get the following
errors:
Software error:
Execution of /opt2/wag/httpd/cgi-bin/carcity.pl aborted due to
compilation errors.
Please send mail to this site's webmaster for help.
Content-type: text/html
Software error:
Unable to get Terminal Size. The TIOCGWINSZ ioctl didn't work.
The COLUMNS and LINES
environment variables didn't work. The resize program didn't
work. at
/usr/local/lib/perl5/site_perl/Term/ReadKey.pm line 301.
Please send mail to this site's webmaster for help.
Content-type: text/html
Software error:
[Wed May 26 10:09:43 1999] readline.pm: Unable to get Terminal
Size. The TIOCGWINSZ ioctl
didn't work. The COLUMNS and LINES environment variables
didn't work. The resize program
didn't work. at /usr/local/lib/perl5/site_perl/Term/ReadKey.pm
line 301.
Please send mail to this site's webmaster for help.
Content-type: text/html
Software error:
[Wed May 26 10:09:43 1999] readline.pm: [Wed May 26 10:09:43
1999] readline.pm: Unable to get
Terminal Size. The TIOCGWINSZ ioctl didn't work. The COLUMNS
and LINES environment variables
didn't work. The resize program didn't work. at
/usr/local/lib/perl5/site_perl/Term/ReadKey.pm
line 301.
Please send mail to this site's webmaster for help. >
Has anybody seen this error before and how did you sove it. I would be
very pleased.
Thanx a lot,
Jacob H. Bierma
--------------585A891F4A85CFFB4C5C4387
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi,
<p>I am trying to connect to a MySql database via a Perlscript. I have
tested the script on a Winnt-box with Perl and MySql and a Linux-box with
the same configuration. All testing worked fine.
<p>However, when we upload the script to our provider, we get the following
errors:
<br>
<blockquote><i>Software error:</i><i></i>
<p><i>Execution of /opt2/wag/httpd/cgi-bin/carcity.pl aborted due to compilation
errors.</i><i></i>
<p><i>Please send mail to this site's webmaster for help. Content-type:
text/html</i><i></i>
<p><i>Software error:</i><i></i>
<p><i>Unable to get Terminal Size. The TIOCGWINSZ ioctl didn't work. The
COLUMNS and LINES</i>
<br><i>environment variables didn't work. The resize program didn't work.
at</i>
<br><i>/usr/local/lib/perl5/site_perl/Term/ReadKey.pm line 301.</i><i></i>
<p><i>Please send mail to this site's webmaster for help. Content-type:
text/html</i><i></i>
<p><i>Software error:</i><i></i>
<p><i>[Wed May 26 10:09:43 1999] readline.pm: Unable to get Terminal Size.
The TIOCGWINSZ ioctl</i>
<br><i>didn't work. The COLUMNS and LINES environment variables didn't
work. The resize program</i>
<br><i>didn't work. at /usr/local/lib/perl5/site_perl/Term/ReadKey.pm line
301.</i><i></i>
<p><i>Please send mail to this site's webmaster for help. Content-type:
text/html</i><i></i>
<p><i>Software error:</i><i></i>
<p><i>[Wed May 26 10:09:43 1999] readline.pm: [Wed May 26 10:09:43 1999]
readline.pm: Unable to get</i>
<br><i>Terminal Size. The TIOCGWINSZ ioctl didn't work. The COLUMNS and
LINES environment variables</i>
<br><i>didn't work. The resize program didn't work. at /usr/local/lib/perl5/site_perl/Term/ReadKey.pm</i>
<br><i>line 301.</i><i></i>
<p><i>Please send mail to this site's webmaster for help. ></i></blockquote>
Has anybody seen this error before and how did you sove it. I would be
very pleased.
<p>Thanx a lot,
<br>Jacob H. Bierma</html>
--------------585A891F4A85CFFB4C5C4387--
------------------------------
Date: Wed, 26 May 1999 15:39:04 GMT
From: tertullian@my-dejanews.com
Subject: FileHandle problems
Message-Id: <7ih4io$tt1$1@nnrp1.deja.com>
Hithertofore I've stuck to DBI stuff but now I'm giving files a go
and having problems.
Documentation and camel book say ...
if ($fh->open "< file") {
perl says ...
String found where operator expected at sub009.cgi line 20,
near "->open "< file"
Any help much appreciated
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 26 May 1999 11:32:51 -0400
From: John Kit <jkit@jpmorgan.com>
Subject: fork spawning off and restarting program over and over?
Message-Id: <374C1423.D1093A27@jpmorgan.com>
I am having a strange problem with fork. I am looping the fork to
create multiple
processes to do some task. After a certain mount of loops it seems to
start to
duplicate it self forever.
I am reading from a file to pass information for the child to do some
work. The
loop depends on how many lines there are in the file. It seems that
after 15 or
or more loops it starts to duplicate. The file contains Http Url
information
which is passed to the child to run a HTTP/GET with LWP::UserAgent.
Thanks ahead of time.
John
open(WEBSERVERLIST,"$ConfWebServerFile") or die "Can't open file";
while (<WEBSERVERLIST>) {
($DirRef,$Url) = split(/;/,$_);
chomp $Url;
$DirRef = atrim($DirRef);
$Url = atrim($Url);
$DataFile = $DataDir."/".$DirRef."/".$DataFileName;
#----------
# Since we want each url to execute at the same time, well almost the
# same time, we are going to fork off a process for each url.
#
$return = fork;
if ($return == 0) {
#----------
# Child
# This is the child process. We will now go out and get the
# the html page and time it.
#
$Hour = convertto2digit(localtime() ->hour);
$Minute = convertto2digit(localtime() ->min);
$TimeStamp = $Hour.":".$Minute;
($TotalTime, $HttpStat, $Http_Desc, $Content) =
get_html($Url,$ProxyServer);
update_log($DataFile,$TimeStamp,$TotalTime,$HttpStat,$Http_Desc,$Url);
exit(0);
} elsif (defined $return) {
#----------
# Parent
# This is the parent process. We will not do anything here but
# we will just let it loop around again to kick off another
process
# or end when there are no more lines to process.
#
} else {
die "for error:$!\n";
}
#----------
}
------------------------------
Date: Wed, 26 May 1999 15:13:40 GMT
From: cyewmeng@my-dejanews.com
Subject: gdchart perl module installation problem
Message-Id: <7ih330$sk2$1@nnrp1.deja.com>
Hi,
I'm trying to use the gdchart perl module on HP-UX10.20 (found in
/www.fred.net/brv/chart).
Managed to compile the gdchart.sl library and put in the correct path
(indicated by @INC). While trying to use it in my perl script, I get
the following error:
Exec format error at /home/yew/perl5/lib/RA-
RISC2.0/5.00405/DynaLoader.pm line 172.
I figure this error has got something to with my compilation of the
gdchart_wrapper.c into gdchart.sl. But I don't know how to fix it.
Anybody can help me?? My time is running out and I'm desperate for a
soln! THANKS in advance!
BTW, following is the command I used for compiling the gdchart_wrapper:
ld -G gdc_pie.o gdchart.o price_conv.o gdc.o gdchart_wrap.o -o
gdchart.sl
-L/usr/ccs/lib -lm -lc
-L/home/yew/GDCHART_PERL/gdchart/gdchart0.94b/gd1.3 -lgd
-L/home/yew/perl5/lib/PA-RISC2.0/5.00405/CORE
-lperl /usr/ccs/lib/crt0.o
Any help is greatly appreciated!!
Thanks
Yew
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 26 May 1999 15:50:18 GMT
From: aspinelli@ismes.it (Andrea L. Spinelli)
Subject: Re: Get spaces off.
Message-Id: <374c1813.1139538746@news.inet.it>
On Wed, 26 May 1999 08:23:58 GMT, paul@vdkamer.nl (PaulK) wrote:
>$teststring= 'Hello this is a test string ';
>How do get $teststring to be 'Hello this is a test string';
$teststring =~ s/\s*$//;
--
Andrea Spinelli, Ismes SpA, Via Pastrengo 9, 24068 Seriate BG, Italy
e-mail: aspinelli@ismes.it Phone: +39-035-307209 Fax: +39-035-302999
------------------------------
Date: Wed, 26 May 1999 07:10:53 -0800
From: hannibal59@hotmail.com (hannibal josh)
Subject: Help needed!
Message-Id: <McU23.15700$me.7262697@WReNphoon4>
Can some friendly people help me to
find what is problem with this script,it dont work,
error-message is"Can't find string terminator "End_of_prog" anywhere before
EOF at xx/xx/xx.cgi line xx.
I am beginner with perl and cant find solution to problem.
#!/usr/bin/perl -w
use strict
$date = `date '+DATE: %A %e %B, %Y TIME: %I:%M %p %Z'` ;
($d , $t) = ($date =~ m#DATE: (.*) TIME: (.*)#) ;
$user = $ENV{'REMOTE_IDENT'};
$user = ($user eq "unknown")? "" : " $user" ;
$host = $ENV{'REMOTE_HOST'};
$browser = $ENV{'HTTP_USER_AGENT'};
($b,$v,$p) = ($browser =~ m/(.*)\/(\S*)(.*)/) ;
($p) = ($p =~ m/.*\((\w*).*\)/ );
$p = $p?$p:"unspecified platform";
$command = <<'End_of_prog';
$ping = `ping -s $host 64 1` ;
End_of_prog
if (eval $command) {
$* = 1; # Enable multi-line pattern match
$ping =~ m#min/avg\/max = (\d*)/\d*\/\d*# ;
$ms = $1 ;
if ( $ms <= 400) {
$link = "very fast link" ;
}
elsif ($ms <=1000 ) {
$link ="fast link" ;
}
else {
$link = "slow link" ;
}
$interrogate = <<"__EOInterrogate__";
Interrogation time of <b>$ms</b> milliseconds suggests
that you're on a
<b>$link</b><p>
__EOInterrogate__
}
else {
$interrogate="";
}
print <<__EOF__;
Content-type: text/html
<html>
<head>
<title>Browser Recognition</title>
</head>
<body bgcolor=#fffff0 text=#000000 link=#0080ff
vlink=#2e8b57>
<center><h3>Browser Recognition</h3></center>
<pre>
</pre>
Welcome <b>$user</b> from <b>$host</b> at
<b>$t</b> on <b>$d</b><p>
You are using <b>$b</b> Version <b>$v</b> for
<b>$p</b><p>
$interrogate
<hr width=300>
<p> xxxxxxxxx
xxxxxxxxxxxxxxxx "
<p>
<br>
Email <a
href="mailto:xxxxxx</a>
</body>
</html>
__EOF__
-**** Posted from RemarQ, http://www.remarq.com/?c ****-
Search and Read Usenet Discussions in your Browser
------------------------------
Date: Wed, 26 May 1999 15:55:56 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Help needed!
Message-Id: <gQU23.747$nn.214296@news.shore.net>
hannibal josh <hannibal59@hotmail.com> wrote:
: Can some friendly people help me to
: find what is problem with this script,it dont work,
: error-message is"Can't find string terminator "End_of_prog" anywhere before
: EOF at xx/xx/xx.cgi line xx.
: I am beginner with perl and cant find solution to problem.
<snip>
: $command = <<'End_of_prog';
: $ping = `ping -s $host 64 1` ;
: End_of_prog
If this is really the way your program is formatted (ie, indented), perl
won't see the End_of_prog tag. Perl expects to see it flush against the
left margin.
If it really *is* flush against the left margin, and you're still getting
this error, it may be that you're writing your script on a PC and
uploading it in binary mode to a Unix host. In this case, there will be a
superfluous carriage return character and the end of "End_of_prog" which
will also cause Perl to miss the tag. Make sure that you're uploading your
script in ASCII mode, or use a text editor like TextPad that allows you to
save files in UNIX mode by default.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Wed, 26 May 1999 11:33:51 -0400
From: "Matt Baker" <matt@betcha.net>
Subject: Re: jerri rigged forms instead of CGI... bad?
Message-Id: <7ih45m$mma$1@autumn.news.rcn.net>
Hey thanks alot that is reassuring.
matt
Jerome O'Neil <jeromeo@atrieva.com> wrote in message
news:3749CA1E.CB018CF7@atrieva.com...
>Matt Baker wrote:
>
>> Here is the dillema:
>> 1) Is it bad style or normal practice to have a CGI program spit out raw
>> HTML to the web browser?
>> I generally just do a
>> print >>EOD;
>> lots of HTML goes here
>> EOD
>
>It's not bad form. In many cases, it's preferable.
>
>Good Luck!
>
>
>--
>Jerome O'Neil, Operations and Information Services
>Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
>jeromeo@atrieva.com - Voice:206/749-2947
>The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
Date: Wed, 26 May 1999 10:10:26 -0400
From: Greg Bartels <gbartels@xli.com>
Subject: Re: leeches, compilers, and perl, oh my (all mine?)
Message-Id: <374C00D2.7D2ADBF4@xli.com>
Tom Christiansen wrote:
>
> [courtesy cc of this posting mailed to cited author]
>
> In comp.lang.perl.misc, Greg Bartels <gbartels@xli.com> writes:
> :so the guy wants to use a free tool so he can hoard his
> :source code, so what?
>
> So I wouldn't dream of helping him, that's what.
I think I just realized what's got me in this conversation.
you both want to hide information.
he wants to hide it via a compiler, you want to hide it by
witholding any knowledge you may have of the subject
(not helping him).
I say that the public knowledge base can be given away
without ever TAKING away from it.
he wants to prevent other people from viewing his
copyrighted code by obscuring it with a compiler.
you want to prevent him from doing this by
obscuring information that would help him.
not that you HAVE to help him.
but the information you're witholding is public knowledge.
(the compiler is here, you use it like this, etc)
the information he wanted to withold is his
legally copyrighted code, I assume.
its not like the public knowledgebase will run out
if you give too much of it away.
people on this group keep saying something to the effect of:
"if you think you'll be able to protect your code through
anything but copyright law, you're mistaken. obscuring your
code doesn't really protect it, it just makes it more
difficult to get at."
perl is copyrighted, it is legally protected.
yet, people on this group try to obscure it from those
they don't believe should have it. all they do is
make it more difficult for people to get at.
so does the group believe in security by obscurity or not?
if not, there should be no concern with making any
information available about perl or compilers or whatever
else anyone asks about.
Does the group ascribe to open-source and providing a
public knowlegebase that is freely available?
either you do or you dont. you cant give it away
to some and hide it from others, and say you
support open source.
how can anyone be expected to come over to the
open-source side if we dont practice what we preach?
Greg
> :leech is a very charged word, by the way.
>
> Of course it is. And a very apt one, as well.
> You'll notice it in the subject headers, which I
> did not invent.
>
> --tom
> --
> User, n.: "The word computer professionals use when they mean 'idiot'."
> - Dave Barry
------------------------------
Date: 26 May 1999 09:22:38 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: leeches, compilers, and perl, oh my (all mine?)
Message-Id: <374c11be@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
Greg Bartels <gbartels@xli.com> writes:
:he wants to hide it via a compiler, you want to hide it by
:witholding any knowledge you may have of the subject
:(not helping him).
If I had information that would allow you to fire the nukes in Montana,
I'd withhold that as well. It's a moral decision.
--tom
--
X-Windows: It was hard to write; it should be hard to use.
--Jamie Zawinski
------------------------------
Date: 26 May 1999 09:23:30 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: leeches, compilers, and perl, oh my (all mine?)
Message-Id: <374c11f2@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
Greg Bartels <gbartels@xli.com> writes:
:how can anyone be expected to come over to the
:open-source side if we dont practice what we preach?
You're beginning to practice Orwellian prevarication.
--tom
--
I subscribe to the Quentin Crisp school of thought on housework:
"After three years, the dust doesn't get any thicker."
------------------------------
Date: Wed, 26 May 1999 15:51:31 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: My old perlscripts won't run anymore
Message-Id: <7MU23.746$nn.214296@news.shore.net>
Michiel Peene <michiel.peene@advalvas.be> wrote:
: and the webserver (netscape 3.51) error.log looks like that
: #####
: [26/May/1999:15:08:57] failure: for host xxx.xxx.xxx.xxx trying to GET
: /webmail/login.pl, cgi-parse-output reports: the CGI program
: C:\Perl\bin\perl.exe did not produce a valid header (program terminated
: without a valid CGI header (check for core dump or other abnormal
: termination)
: #####
: When I run the script form the command line, it gives me the whole HTML
: as output without any errors!
Well, it looks like your program did not return a header that the web
server expected to see. Are you outputting a "content-type" header before
your HTML, or just the HTML?
You may want to do some reading on the way CGI works. It's not very
complicated, but if you screw it up, all you get are cryptic "server
errors". There's a good FAQ at
http://www.webthing.com/tutorials/cgifaq.html, as well as Brian Foy's CGI
meta-faq, which is either down or has been moved since the last time I
bookmarked it.
Hope this helps, and that it encourages you to continue learning and using
Perl.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Wed, 26 May 1999 10:26:46 -0500
From: "Office mail" <officemail@megsinet.net>
Subject: Need help with sub routines
Message-Id: <HoU23.356$h85.363@news.megsinet.net>
Im completely confused by this whole subroutine function but have a great
need for it right now. Could someone possibly send me a sample script with
subroutines in it. If anyone could it would be a great help,
knitemare@megsinet.net. If you can explain here how it works that would be
really cool too.
Thanks,
Jay Knite
------------------------------
Date: 26 May 1999 15:36:12 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Need help with sub routines
Message-Id: <7ih4dc$d7s$2@info2.uah.edu>
In article <HoU23.356$h85.363@news.megsinet.net>,
"Office mail" <officemail@megsinet.net> writes:
: Im completely confused by this whole subroutine function but have a great
: need for it right now. Could someone possibly send me a sample script with
: subroutines in it. If anyone could it would be a great help,
: knitemare@megsinet.net. If you can explain here how it works that would be
: really cool too.
#! /usr/bin/perl -w
sub say {
my($what) = @_;
print $what, "\n";
}
sub ask {
my($query) = @_;
print $query, "\n";
my $response = <>;
chomp $response;
$response;
}
my $who = ask "What is your name?";
say "Hi, $who, it's nice to meet you."
Have you read the perlsub manpage?
Greg
--
If you don't have anything good to say... say it often!
-- Ed the Sock
------------------------------
Date: Wed, 26 May 1999 16:16:13 +0200
From: "Fred Ruffet" <fruffet@kaptech.com>
Subject: Re: Password Protect
Message-Id: <7igvnl$8dp$1@gatekeeper.ornano.kapt.com>
Alex,
I started to write a na pplication like yours a few months ago, and I felt
the same. I found a way to protect my page, wich I find correct, but maybe
you won't.
First, the user go to a page were he selects his name and enter is password.
Then, a cookie is set, with is login and password. After all this, all the
pages which are to be protected, are not html. They are perl scripts that,
at first verifies his identity, then process the operations. html pages are
made by the perl scripts with squeletons, and filled with the datas. As the
cookie is crypted, and disappears after the disconnect from the browser, I
consider it's safe...
Regards,
Fred
Alex a icrit dans le message <374BF1A9.321206F6@netvigator.com>...
>Hi all,
>I need to protect some .html pages so that only persons have correct
>password can enter these pages.
>There are some ready made scripts on internet on this topic. However, I
>found out that they are not actually password protected !
>For example, usually the scripts have a login.html where visitors can
>enter the "protect.html" if the password you fill in the form of
>login.html is correct. However, if you know the url of the
>"protect.html", you can enter the "protect.html" directly !!!
>Are there any real protect scripts ?
>Thank you
>alex
>
------------------------------
Date: Wed, 26 May 1999 10:53:19 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: regexp question
Message-Id: <x3ywvxvyja9.fsf@tigre.matrox.com>
Me <aghaeim@genesis.co.nz> writes:
> Bryan Camp wrote:
> >
> > Hello,
> >
> > I'm having problems getting a regexp to work.
Have you read perlre, perlop and perlfaq6 ?
> > I'm reading in a data file with the following format:
> >
> > 999-999 RES SRC1=A120C65000000_CR08|NAME1 SRC2=A120C65000001_CR08|NAME2
> > 999-998 RES SRC1=A120C65000002_CCC1|NAME3
> > 999-997 CAP SRC1=A120C65000009_FAL4|NAME4 SRC2=_CRTY|NAME5
> >
> > What I want to do is get rid of everything between
> > the = sign and the underscore sign, which can occur
> > multiple times in the same line:
> >
> > 999-999 RES SRC1=_CR08|NAME1 SRC2=_CR08|NAME2
> > 999-998 RES SRC1=_CCC1|NAME3
> > 999-997 CAP SRC1=_FAL4|NAME4 SRC2=_CRTY|NAME5
> >
> > Here is what I have so far:
> >
> > #!usr/bin/perl -w
It is advisable to add 'use strict;' here. It's always a good idea.
> > open (FH, "+< $file");
You should check the return values of your open() statements.
open FH, "+<$file" or die "Couldn't open $file: $!\n";
> > while(<FH>){
> > $sub =~ ( s/(/\b=\+_\b/)/g )
What is $sub? You are reading the file, line by line, and storing each
line in $_ in each iteration of the while() loop. No where in the
program you set the value of $sub. Moreover, you have a syntax error
in your s/// statement. What you need is something like:
s/=.*?_/=_/g;
Since no variable is specified, the above substitution works on
$_, which is what you want. Here, you we asking to match an equal
sign, followed by a non-greedy match (i.e. as few characters as
possible), followed by an underscore, and substitute that with an
equal sign followed by an underscore. This is done globally.
Do yourself a favour and read perlre.
Mind you that you don't really do anything to $_ after you modify
it. This will not modify your original file. For that, you need to
read some docs/FAQs. perlfaq5 would be of interest:
How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the
beginning of a file?
> > }
> > close (FH);
Again, it is advisable to check the return status of your close().
> > Can someone tell me what I'm doing wrong?
You're trying to code and use regexps without really understanding how
they work. You need to slow down, read some docs, and all will be fine.
> > Thank you very much.
> >
> > Bryan
>
> I guess the correct form of what you mean is :
> $sub =~ s/\b\=.*\_\b//g ; or even $sub=~ s/(=.*\_)//g ;
Ummm ... nope. Your first regexp fails because a \b, by definition,
matches locations between \w characters and \W characters. Since an
underscore is a \w character (yes \w .. not \W), and it is followed by
another \w character, no match will occur. You also don't need to
escape the '=' and '_' characters.
Your second regexp fails because you use greedy matching (which is the
default). This produces the wrong results. You also escape the '_'
which is unnecessary, and you capture the match into $1, and you never
use it.
Trying to help people is a good thing. Giving them wrong answer just
confuses them more and more. Test your code before you post.
HTH,
Ala
------------------------------
Date: Wed, 26 May 1999 15:44:54 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: require problem
Message-Id: <WFU23.745$nn.214296@news.shore.net>
alfredo <alfredo@ronchiato.it> wrote:
: When I use command -> require "script.pl"; an error appair : internal
: server error !
: Someone can help me ? How do I do for use this command ?
I'm guessing that you're writing a CGI script. Generally speaking, when a
CGI script fails, it produces a server error. The error you are seeing
could be caused by just about anything.
Two things to try: Run the script from the command line (in which case you
should see the error message on your terminal), or check in your server's
error logs.
One thing to double check: Any file that's "required" by a perl script has
to return a "true" value or the "require" statement will fail. Most
programmers accomplish this by putting a "1" on the last line of their
include file; check the docs for more info.
Hope this helps, and that it encourages you to continue learning and using
Perl.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Wed, 26 May 1999 15:07:05 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: What's wrong with this hit counter?
Message-Id: <slrn7ko1ge.uo4.dragons@dragons.duesouth.net>
On 26 May 1999 03:52:17 -0700, Randal L. Schwartz <merlyn@stonehenge.com>
held some poor sysadmin at gun point while typing in the following:
: Doesn't work when there's more than one user hitting at the same time.
:
: Of course, if your page is so boring that you can guarantee that... :)
Nah, Murphy claims that those two hits of the year will happen at the
same time.
Either that, or your gonna go hit your own page to bump the counter just
as someone else visits it...
:-)
--Matthew
------------------------------
Date: Wed, 26 May 1999 15:38:16 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: why doesn't my first program work?? (ok , third or something)
Message-Id: <IzU23.744$nn.214296@news.shore.net>
Tom Christiansen <tchrist@mox.perl.com> wrote:
: whose suffix ends in ".cgi". That's highly non-standard: perl libraries
: end in ".pl" -- obviously. But why are you using a simple library rather
: than a module?
Um, maybe because it's his *first* friggin' program?? Are you really that
out of touch with reality that you expect anyone in the world to grasp
every aspect of Perl before they write a single line of code? Sheesh.
--Art
PS: What's "obvious" about using ".pl" instead of some other suffix to
represent a perl library?
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5789
**************************************