[15909] in Perl-Users-Digest
Perl-Users Digest, Issue: 3322 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 11 14:10:27 2000
Date: Sun, 11 Jun 2000 11:10:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <960747016-v9-i3322@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 11 Jun 2000 Volume: 9 Number: 3322
Today's topics:
Re: how to check for integer? <gellyfish@gellyfish.com>
Re: how to check for integer? <thoren@southern-division.com>
Re: how to check for integer? (Tad McClellan)
Re: how to check for integer? <gellyfish@gellyfish.com>
I need some help with regex. <jabbott@abbotts.org>
Re: I need some help with regex. <trevor@trevorsky.com>
Re: I need some help with regex. <jabbott@abbotts.org>
Re: Larry Rosler interview on perl.com! <gellyfish@gellyfish.com>
Re: Larry Rosler interview on perl.com! <gellyfish@gellyfish.com>
obfuscated but useful magic() - thank you <sweeheng@usa.net>
Problem with the SlideShow module (Hans Kristian Ruud)
Re: Problem with the SlideShow module <gellyfish@gellyfish.com>
Removing Whitespace <jdNOjdSPAM@syncon.ie.invalid>
Re: Removing Whitespace <bwalton@rochester.rr.com>
Re: rmdir in NT 4... (Clinton A. Pierce)
SCRIPT WRITERS HELP NEEDED <eric_smyths@yahoo.com>
Re: Shebang line -- What exactly does Perl do? (Tad McClellan)
Re: Shebang line -- What exactly does Perl do? <gellyfish@gellyfish.com>
Re: textfile reading template <jagman98@home.com>
Re: Time-Date Question ?? (Peter J Scott)
Re: Trying to figure out how wtmp is packed <imaginos@imaginos.net>
Re: Trying to figure out how wtmp is packed <gellyfish@gellyfish.com>
Re: uses for PERL (Tad McClellan)
Re: where can I find doc for epl files <billy@arnis-bsl.com>
Re: Write to file via CGI script? <billy@arnis-bsl.com>
Re: Write to file via CGI script? (Tad McClellan)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Jun 2000 13:27:30 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: how to check for integer?
Message-Id: <8i00ji$o8h$1@orpheus.gellyfish.com>
On Sun, 11 Jun 2000 09:25:56 +0200 Mariska wrote:
> Hi all
> I don't know how to check if a number is an integer.
> I need to do something when a number is even.
> i divide a number by 2 and i want to check if the result is an integer or
> not.
>
You dont need to do that :
if ( $number % 2 )
{
print "Odd";
}
else
{
print "Even";
}
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: Sun, 11 Jun 2000 18:07:58 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: Re: how to check for integer?
Message-Id: <8i0drg$b14$18$1@news.t-online.com>
Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
news:8i00ji$o8h$1@orpheus.gellyfish.com...
> On Sun, 11 Jun 2000 09:25:56 +0200 Mariska wrote:
> > Hi all
> > I don't know how to check if a number is an integer.
> > I need to do something when a number is even.
> > i divide a number by 2 and i want to check if the result is an integer
or
> > not.
> >
>
> You dont need to do that :
>
> if ( $number % 2 )
> {
> print "Odd";
> }
> else
> {
> print "Even";
> }
so, given 2.5 as $number it returns "Even"
do you think 2.5 is an even number? ;>
gruß
thoren
8#X
--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com
------------------------------
Date: Sun, 11 Jun 2000 11:17:00 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how to check for integer?
Message-Id: <slrn8k7bbc.56k.tadmc@magna.metronet.com>
On Sun, 11 Jun 2000 09:25:56 +0200, Mariska <mariska@excite.nl> wrote:
>I don't know how to check if a number is an integer.
If you had checked the Perl FAQ before posting to the Perl
newsgroup (as good manners requires), then you would know
how to do that:
perldoc -q integer
>I need to do something when a number is even.
do_something() unless $_ % 2;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 11 Jun 2000 17:36:48 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: how to check for integer?
Message-Id: <8i0f70$p5o$1@orpheus.gellyfish.com>
On Sun, 11 Jun 2000 09:32:20 GMT jason wrote:
> Mariska writes ..
>>I don't know how to check if a number is an integer.
>>I need to do something when a number is even.
>>i divide a number by 2 and i want to check if the result is an integer or
>>not.
>
> if your end goal is just to determine whether an integer is even or not
> then the following Perlistic method is hard to beat
>
> $var =~ /[02468]$/;
>
Oh sure it is yeah nice one :
#!/usr/bin/perl -w
use Benchmark;
use strict;
sub regex
{
my @numbers = (0 .. 100);
foreach (@numbers)
{
if( $_ !~ /[02468]$/ )
{
my $junk++;
}
}
}
sub modulus
{
my @numbers = (0 .. 100);
foreach (@numbers)
{
if( $_ % 2 )
{
my $junk++;
}
}
}
timethese(10000,{
Regex => \®ex,
Modulus => \&modulus
});
Giving :
Benchmark: timing 10000 iterations of Modulus, Regex...
Modulus: 3 wallclock secs ( 2.74 usr + 0.00 sys = 2.74 CPU) @ 3649.64/s (n=10000)
Regex: 7 wallclock secs ( 6.25 usr + 0.00 sys = 6.25 CPU) @ 1600.00/s (n=10000)
The moral of the story being to use mathematical operations to solve
mathematical problems.
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: Sun, 11 Jun 2000 11:44:59 -0500
From: john abbott <jabbott@abbotts.org>
Subject: I need some help with regex.
Message-Id: <3943C20B.16FB38D@abbotts.org>
Hello,
I have been trying to get this to work for a couple of days and can't
seem to figure it out. This is the situation, I am trying to cut some
images out of an html file and leave the alt tags in to make a text
link. $body is my html (I think one line at a time but I am not sure)
The line,
<a href="contact.html"><img src="artwork/contact.gif" width="83"
height="21" border=0 alt="Contact Us"></a><a href="sitemap.html"><img
src="artwork/sitemap.gif" width="57" height="21" border=0 alt="Site
Map"></a><a href="search.html"><img src="artwork/search.gif" width="95"
height="21" border=0 alt="Search our Site"></a>
and I am using,
$body =~ s/\<img src=.*alt=\"(.*)">/$1/gi
Which produces,
<a href="contact.html">Search our Site</a>
Ok, this makes sence. I am using the .* which is greedy and matches to
the end of the line. Then it backtracks to the first alt, "Search our
Site", and makes this the text. So, what I need to do is match only
until the first alt. Reading Jeffy Friedl's book I came up with,
$body =~ s/<img[^alt]* alt="(.*)">/$1/ig;
Which I really thought would work.... except it doesn't match at all --
I can't figure out why. So I added the dot again
$body =~ s/<img[^alt].* alt="(.*)">/$1/ig;
and now it works exactly like the first one. Any ideas what I am doing
wrong?
--john abbott
------------------------------
Date: Sun, 11 Jun 2000 10:42:39 -0700
From: "Trevor Sky Garside" <trevor@trevorsky.com>
Subject: Re: I need some help with regex.
Message-Id: <NaQ05.14601$v_.857340@nntp2.onemain.com>
Try using the non-greedy /.*?/ construct. I haven't tried applying it to
your case right here, but glancing at it quickly tells me that it should
work for you.
--Trevor
"john abbott" <jabbott@abbotts.org> wrote in message
news:3943C20B.16FB38D@abbotts.org...
> Hello,
>
> I have been trying to get this to work for a couple of days and can't
> seem to figure it out. This is the situation, I am trying to cut some
> images out of an html file and leave the alt tags in to make a text
> link. $body is my html (I think one line at a time but I am not sure)
>
> The line,
> <a href="contact.html"><img src="artwork/contact.gif" width="83"
> height="21" border=0 alt="Contact Us"></a><a href="sitemap.html"><img
> src="artwork/sitemap.gif" width="57" height="21" border=0 alt="Site
> Map"></a><a href="search.html"><img src="artwork/search.gif" width="95"
> height="21" border=0 alt="Search our Site"></a>
>
> and I am using,
> $body =~ s/\<img src=.*alt=\"(.*)">/$1/gi
> Which produces,
> <a href="contact.html">Search our Site</a>
>
> Ok, this makes sence. I am using the .* which is greedy and matches to
> the end of the line. Then it backtracks to the first alt, "Search our
> Site", and makes this the text. So, what I need to do is match only
> until the first alt. Reading Jeffy Friedl's book I came up with,
>
> $body =~ s/<img[^alt]* alt="(.*)">/$1/ig;
>
> Which I really thought would work.... except it doesn't match at all --
> I can't figure out why. So I added the dot again
>
> $body =~ s/<img[^alt].* alt="(.*)">/$1/ig;
>
> and now it works exactly like the first one. Any ideas what I am doing
> wrong?
>
> --john abbott
>
------------------------------
Date: Sun, 11 Jun 2000 12:04:18 -0500
From: john abbott <jabbott@abbotts.org>
Subject: Re: I need some help with regex.
Message-Id: <3943C692.FF0C2B53@abbotts.org>
I was about to write and tell you that:
$body =~ s/\<img src=.*?alt=\"(.*)">/$1/gi;
Does not seem to work. I end up with:
<a href="contactT.html">Contact Us"></a><a href="sitemapT.html"><img
src="artwork/sitemap.gif" width="57" height="21" border=0 alt="Site
Map"></a><a href="searchT.html"><img src="artwork/search.gif" width="95"
height="21" border=0 alt="Search our Site</a>
But then looked at how close it came to working! I added a second /?/
and wha-la!
$body =~ s/\<img src=.*?alt=\"(.*?)">/$1/gi;
It works!
<a href="contactT.html">Contact Us</a><a href="sitemapT.html">Site
Map</a><a href="searchT.html">Search our Site</a>
Thank you so very much!
--ja
Trevor Sky Garside wrote:
>
> Try using the non-greedy /.*?/ construct. I haven't tried applying it to
> your case right here, but glancing at it quickly tells me that it should
> work for you.
>
> --Trevor
>
> "john abbott" <jabbott@abbotts.org> wrote in message
> news:3943C20B.16FB38D@abbotts.org...
> > Hello,
> >
> > I have been trying to get this to work for a couple of days and can't
> > seem to figure it out. This is the situation, I am trying to cut some
> > images out of an html file and leave the alt tags in to make a text
> > link. $body is my html (I think one line at a time but I am not sure)
> >
> > The line,
> > <a href="contact.html"><img src="artwork/contact.gif" width="83"
> > height="21" border=0 alt="Contact Us"></a><a href="sitemap.html"><img
> > src="artwork/sitemap.gif" width="57" height="21" border=0 alt="Site
> > Map"></a><a href="search.html"><img src="artwork/search.gif" width="95"
> > height="21" border=0 alt="Search our Site"></a>
> >
> > and I am using,
> > $body =~ s/\<img src=.*alt=\"(.*)">/$1/gi
> > Which produces,
> > <a href="contact.html">Search our Site</a>
> >
> > Ok, this makes sence. I am using the .* which is greedy and matches to
> > the end of the line. Then it backtracks to the first alt, "Search our
> > Site", and makes this the text. So, what I need to do is match only
> > until the first alt. Reading Jeffy Friedl's book I came up with,
> >
> > $body =~ s/<img[^alt]* alt="(.*)">/$1/ig;
> >
> > Which I really thought would work.... except it doesn't match at all --
> > I can't figure out why. So I added the dot again
> >
> > $body =~ s/<img[^alt].* alt="(.*)">/$1/ig;
> >
> > and now it works exactly like the first one. Any ideas what I am doing
> > wrong?
> >
> > --john abbott
> >
------------------------------
Date: 11 Jun 2000 13:02:17 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <8hvv49$o6s$1@orpheus.gellyfish.com>
On Sun, 11 Jun 2000 14:32:49 +0930 Henry wrote:
> In article <pKs05.110113$hT2.431098@news1.rdc1.ct.home.com>, Dan
> Sugalski <dan@tuatha.sidhe.org> wrote:
>
<with regard to the standard Perl documentation>
>> and folks seem to be doing pretty well with what's provided,
>
> No, they aren't.
>
I'm sorry you are going to have to do better than this. Who are these
'they' and by what objective standards have you determined that these
people of yours arent 'doing pretty well' ?
In what way would *you* have the documentation changed so it is more
useful to your imaginary friends and why havent you submitted a patch
if it is so important to you ?
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: 11 Jun 2000 13:05:04 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <8hvv9g$o77$1@orpheus.gellyfish.com>
On Sun, 11 Jun 2000 01:03:05 -0700 Larry Rosler wrote:
> In article <htp-C7C097.15125511062000@news.metropolis.net.au>,
> htp@mac.com says...
>
> ...
>
> Obviously you wouldn't present such
> disparaging views without strong evidence to support your observations.
>
The record may indicate otherwise.
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: Mon, 12 Jun 2000 00:16:31 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: obfuscated but useful magic() - thank you
Message-Id: <8i0dn1$g4e$1@clematis.singnet.com.sg>
Thanks to all who participated in the "obfuscated but useful magic()"
thread - particularly for pointing out the magic(...) bug, creative usage of
gmtime, map and +, and my need of a "drawing board". :o) It was eye-opening
and fun.
For record, the minimal magic() I know to perform my original task is:
sub magic{+{map{$_,(substr gmtime$_*25e5,4,3)x2,$_}1..12}->{+pop}||'bad'}
It is a concoction of various suggestions. Hmm... a single-line solution
that fits on a 80-char line. Not bad at all! :o)
Swee Heng
------------------------------
Date: 11 Jun 2000 14:41:07 GMT
From: hkr@ifi.uio.no (Hans Kristian Ruud)
Subject: Problem with the SlideShow module
Message-Id: <8i08e3$cfr$1@maud.ifi.uio.no>
I have a perl script, which I am trying to run on a Windows NT machine.
I only get this error message, though:
D:\drsc\Tk-SlideShow-0.06\ex1>ex1.pl
IO::Socket::INET: Unknown error at d:\perl\site\lib/X11/Protocol/Connection/INET
Socket.pm line 24
d:\perl\site\lib/Tk/SlideShow.pm:20 (main)
d:\perl\lib/Carp.pm:271 (Carp)
d:\perl\site\lib/X11/Protocol/Connection/INETSocket.pm:28 (X11::Protocol
::Connection::INETSocket)
d:\perl\site\lib/X11/Protocol.pm:2379 (X11::Protocol)
(eval 6):3 (Tk::SlideShow)
d:\perl\site\lib/Tk/SlideShow.pm:133 (Tk::SlideShow)
D:\drsc\Tk-SlideShow-0.06\ex1\ex1.pl:6 (main)
Can't connect to display `localhost:0': Bad file descriptor at d:\perl\site\lib/
X11/Protocol.pm line 2379
H=768, W=1024
d:\perl\site\lib/Tk/SlideShow.pm:20 (main)
d:\perl\site\lib/Tk/SlideShow/Sprite.pm:133 (Tk::SlideShow::Sprite)
d:\perl\site\lib/Tk/SlideShow.pm:181 (Tk::SlideShow)
d:\perl\site\lib/Tk/SlideShow.pm:145 (Tk::SlideShow)
D:\drsc\Tk-SlideShow-0.06\ex1\ex1.pl:6 (main)
Can't connect to display `localhost:0': Bad file descriptor at d:\perl\site\lib/
X11/Protocol.pm line 2379
...propagated at d:\perl\site\lib/Tk/SlideShow/Sprite.pm line 133.
Any advice?
- thanx in advance -
--
* Hans Kr. Ruud The noble art *
* Kristine Bonnevies vei 15 of losing face *
* 0592 ÅRVOLL may one day save *
* Tlf. 22 65 22 34 (hjemme) 22 77 59 40 (jobb) the human race *
--
--
* Hans Kr. Ruud The noble art *
* Kristine Bonnevies vei 15 of losing face *
* 0592 ÅRVOLL may one day save *
------------------------------
Date: 11 Jun 2000 17:17:20 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Problem with the SlideShow module
Message-Id: <8i0e2g$p49$1@orpheus.gellyfish.com>
On 11 Jun 2000 14:41:07 GMT Hans Kristian Ruud wrote:
>
> I have a perl script, which I am trying to run on a Windows NT machine.
>
> I only get this error message, though:
>
>
> D:\drsc\Tk-SlideShow-0.06\ex1>ex1.pl
> IO::Socket::INET: Unknown error at d:\perl\site\lib/X11/Protocol/Connection/INET
> Socket.pm line 24
> d:\perl\site\lib/Tk/SlideShow.pm:20 (main)
> d:\perl\lib/Carp.pm:271 (Carp)
> d:\perl\site\lib/X11/Protocol/Connection/INETSocket.pm:28 (X11::Protocol
> ::Connection::INETSocket)
> d:\perl\site\lib/X11/Protocol.pm:2379 (X11::Protocol)
> (eval 6):3 (Tk::SlideShow)
> d:\perl\site\lib/Tk/SlideShow.pm:133 (Tk::SlideShow)
> D:\drsc\Tk-SlideShow-0.06\ex1\ex1.pl:6 (main)
> Can't connect to display `localhost:0': Bad file descriptor at d:\perl\site\lib/
> X11/Protocol.pm line 2379
> H=768, W=1024
> d:\perl\site\lib/Tk/SlideShow.pm:20 (main)
> d:\perl\site\lib/Tk/SlideShow/Sprite.pm:133 (Tk::SlideShow::Sprite)
> d:\perl\site\lib/Tk/SlideShow.pm:181 (Tk::SlideShow)
> d:\perl\site\lib/Tk/SlideShow.pm:145 (Tk::SlideShow)
> D:\drsc\Tk-SlideShow-0.06\ex1\ex1.pl:6 (main)
> Can't connect to display `localhost:0': Bad file descriptor at d:\perl\site\lib/
> X11/Protocol.pm line 2379
> ...propagated at d:\perl\site\lib/Tk/SlideShow/Sprite.pm line 133.
>
>
> Any advice?
>
Yep, try it on a machine with a X server on it - I am not familiar with
the module but it appears to be trying to create a raw X11 window ...
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: Sun, 11 Jun 2000 08:33:34 -0700
From: deno <jdNOjdSPAM@syncon.ie.invalid>
Subject: Removing Whitespace
Message-Id: <310a0058.ab85a16c@usw-ex0105-036.remarq.com>
Here the task - The script reads from a csv file and writes to
another csv file.
Here the problem- I'm looking for a method to ensure that all
fields are written to the second csv file without leading or
trailing whitespace. What's the bestway to accomplish this. Yes
I'm new to perl but I have tryed.
s/^\s+//; s/\s+$//; - how do I incorporate these so each field
is modified?
while (<USRL>)
{
($loginn,$lastn,$firstn,$dept,$title,$tel) = split (',');
die "\n\nFatal Error !! - Required field missing in $ui_file
at Line $user_count\n\n"
if (grep {!$_ or $_ =~ /\"/} ($loginn,$lastn,$firstn));
print IMPORTDATA
"$firstn,$lastn,$firstn,$dept,$title,$tel\n";
}
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Sun, 11 Jun 2000 17:56:28 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Removing Whitespace
Message-Id: <3943D1C0.7041744C@rochester.rr.com>
deno wrote:
>
> Here the task - The script reads from a csv file and writes to
> another csv file.
>
> Here the problem- I'm looking for a method to ensure that all
> fields are written to the second csv file without leading or
> trailing whitespace. What's the bestway to accomplish this. Yes
> I'm new to perl but I have tryed.
>
> s/^\s+//; s/\s+$//; - how do I incorporate these so each field
> is modified?
>
> while (<USRL>)
>
> {
>
> ($loginn,$lastn,$firstn,$dept,$title,$tel) = split (',');
>
> die "\n\nFatal Error !! - Required field missing in $ui_file
> at Line $user_count\n\n"
> if (grep {!$_ or $_ =~ /\"/} ($loginn,$lastn,$firstn));
>
> print IMPORTDATA
> "$firstn,$lastn,$firstn,$dept,$title,$tel\n";
>
> }
...
The easiest way is to use map:
while(<DATA>){
chomp;
($loginn,$lastn,$firstn,$dept,$title,$tel) =
map {s/^\s+//;s/\s+$//;$_} split(',');
die "\n\nFatal Error !! - Required field missing in $ui_file at Line
$user_count\n\n"
if (grep {!$_ or $_ =~ /\"/} ($loginn,$lastn,$firstn));
print
"$firstn,$lastn,$firstn,$dept,$title,$tel\n";
}
__END__
a,b,c,d,e,f
aa , bb , cc , dd , ee , ff
--
Bob Walton
------------------------------
Date: Sun, 11 Jun 2000 16:03:32 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: rmdir in NT 4...
Message-Id: <oLO05.105338$h01.843768@news1.rdc1.mi.home.com>
[Posted and mailed to original poster]
In article <MPG.13adda474ea86051989721@news>,
elephant@squirrelgroup.com (jason) writes:
> Mark S. Blamey writes ..
>>I've written this code and am finding the directory is not removed by
>>rmdir. I'm assuming something is left in the directory so the command
>>fails. How can I fix it so that the directory will be deleted as
>>desired?
>>
>> opendir(FILES,"$my_dir/s$name");
>> @filelist = grep(!/^\.|^_/, readdir (FILES));
>> closedir(FILES);
>> foreach $filelist (@filelist) {
>> unlink("$my_dir/s$name/$filelist");
>> }
>> rmdir("$my_dir/s$name");
>
> two things
>
Two more. You should always check the return value from system calls
like unlink() and rmdir(). They can provide clues as to what went
wrong!
unlink("$my_dir/s$name/$filelist") || warn "Cannot unlink: $!";
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Sun, 11 Jun 2000 10:07:29 -0700
From: eric <eric_smyths@yahoo.com>
Subject: SCRIPT WRITERS HELP NEEDED
Message-Id: <0ebce242.ad42ccd1@usw-ex0104-028.remarq.com>
SCRIPT WRITERS HELP NEEDED --
comp.lang.perl.misc
WE WILL PAY FOR THE WORK THAT YOU MIGHT DO FOR US.
We have had a web site designed for us.
You can view it at:
http://worldholding.port5.com
The person, who designed and wrote the HTML coding, does not
have the experience to complete the project with the scripting.
He has told us that he has been able to accomplish everything,
except:
1. Writing the scripting that will add a 6-position alpha
plus consecutive number to the data record (A10197, A10198, etc).
2. Send an auto response e-mail message 1 hour after the
consumer enters the information into the form.
We are willing to pay you, if you can help us.
If you are interested and have the time to complete this
assignment, please contact us immediately:
In addition to posting to this forum, can you please e-mail your
posting to me at:
lpsca@earthlink.net
or contact us by AOL or ICQ Messengers
AOL Messenger - lrcal67
ICQ Messenger - 7612119
Thanks!
Eric and Larry
==========In addition to posting your response to this newsgroup,
please send a copy of your reply to me at:
eric_symths@yahoo.com
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Sun, 11 Jun 2000 11:31:07 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Shebang line -- What exactly does Perl do?
Message-Id: <slrn8k7c5r.56k.tadmc@magna.metronet.com>
On Sun, 11 Jun 2000 08:47:49 GMT, Bart Lateur <bart.lateur@skynet.be> wrote:
>Tom Phoenix wrote:
>
>>perl looks for the word "perl" on that line. If it's a shebang-line
>>without that string, perl starts that program for you.
>
>Eh? Perl starts a different program as referenced in the shebang line?
>Is that normal behaviour?
>
>I would think that the (Unix) shell would do that, and launch perl (or
>another program) with the script as a parameter.
The kernel (not the shell) handles magic numbers ( #! is a magic number).
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 11 Jun 2000 16:51:01 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Shebang line -- What exactly does Perl do?
Message-Id: <8i0ch5$p2k$1@orpheus.gellyfish.com>
On 11 Jun 2000 10:22:20 +0100 Jonathan Stowe wrote:
> On Sat, 10 Jun 2000 16:11:24 -0700 Tom Phoenix wrote:
>> On Sat, 10 Jun 2000, daniel mcgrath wrote:
>>
>>> So, what exactly happens with the shebang line?
>>
>> Is that what you needed, or is there something more?
>>
>
> Well there is the extra little bit of magic that if there is a shebang line
> and that contains the path to another executable other than perl then Perl
> will exec that interpreter with the program name as an argument, I've
> never been quite sure of the utility of this feature but I'm sure someone
> must use it.
>
Sorry, Tom had actually said that but I didnt read it properly.
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: Sun, 11 Jun 2000 14:50:13 GMT
From: Manny <jagman98@home.com>
Subject: Re: textfile reading template
Message-Id: <3943A729.6A3EC27A@home.com>
I have been doing following so far:
open(INF, $inf) || die "";
while(<INF>) {
if ( $_ =~ "field1" ) {
($field1token, $field1value) = split(/\:/);
} elsif ....
better way to do this?
Thanks
Manny
Manny wrote:
> Needs to read huge text file in series of records. Folliwing text file:
>
> test.txt
>
> field1 : value1
> field2 : value2
> field3 : value3
>
> field1 : 1
> field2 : 2
> field3 : 3
> =============
>
> I needs to read in
> $value1,$value2,$value3 as record 1. and write it to other text file.
> example:
>
> test.out
> value1,value2,value3
> 1,2,3
> and so on.
>
> Thanks in advance!
------------------------------
Date: Sun, 11 Jun 2000 16:57:12 GMT
From: peter@PSDT.com (Peter J Scott)
Subject: Re: Time-Date Question ??
Message-Id: <IxP05.13173$F9.419676@news1.gvcl1.bc.home.com>
In article <8hvp1j$nks$1@orpheus.gellyfish.com>,
Jonathan Stowe <gellyfish@gellyfish.com> writes:
>On Sat, 10 Jun 2000 22:35:26 GMT Peter J Scott wrote:
>> I assume you are talking about golf scores, not performance?
>
>For myself I have little interest in golf scores, using unpack is probably
>better for maintainer efficiency as there is only one point at which things
>need to be changed if the format of the data is changed, using substr()
>would mean that all the indexes need to be recalculated. Infact I find
>it easier to frame a single unpack format than a bunch of substr()s.
So do I. I misrendered what you just said into "golf scores" in a misplaced
effort to save typing, unfortunately.
Actually, I'm surprised that "A2"x5 isn't turned into "A2A2A2A2A2" by constant folding.
--
Peter Scott
------------------------------
Date: Sun, 11 Jun 2000 08:23:10 -0800
From: imaginos <imaginos@imaginos.net>
Subject: Re: Trying to figure out how wtmp is packed
Message-Id: <sk7beqofh5143@corp.supernews.com>
In article <slrn8k6uo1.9i.jb@yperite.demon.co.uk>, jb@yperite.demon.co.uk (Joe Broz) wrote:
> On Sun, 11 Jun 2000 01:43:21 -0800, imaginos <imaginos@imaginos.net> wrote:
>>I'm trying to figure out how linux glibc wtmp is packed.
>>
>>This is what i have so far, The variable $key is what i'm trying
> to figure out. I think i'm close
>>but i'm a ways off too. any thoughts ?
>>
>
> Look at man 5 utmp. The perl Cookbook has a bit of code that shows
> how to do this as well.
Iv'e been studying that man page for 2 days now, and utmp.h and bits/utmp.h and i can't get clued in from that. Assuming the perl cookbook is a book, i guess i'll go buy it later on today.
------------------------------
Date: 11 Jun 2000 12:44:51 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Trying to figure out how wtmp is packed
Message-Id: <8hvu3j$o3u$1@orpheus.gellyfish.com>
On Sun, 11 Jun 2000 01:43:21 -0800 imaginos wrote:
> I'm trying to figure out how linux glibc wtmp is packed.
>
> This is what i have so far, The variable $key is what i'm trying to figure out. I think i'm close
> but i'm a ways off too. any thoughts ?
>
> #!/usr/bin/perl
> open (WTMP, "/var/log/wtmp");
> $key = "L a12 a32 a256 l l";
> $keylen = length(pack($key, ()));
> while (sysread(WTMP, $buff, $keylen)) {
> @blah = unpack($key, $buff);
> foreach $val(@blah) {
> print "'$val' ";
> }
> print "\n";
> }
>
On my system (Red Hat 6.1) this is the format that works :
($type,
$pid,
$line,
$id,
$user,
$host,
$termination,
$exit,
$session,
$time,
$time_millis
) = unpack("s x2 L A32 A4 A32 A256 s s L L L",$utdata);
If this isnt right then you will need to look in /usr/include/utmp.h
(actually /usr/include/bits/utmp.h here) to work out the actual format.
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: Sun, 11 Jun 2000 09:01:37 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: uses for PERL
Message-Id: <slrn8k73dh.513.tadmc@magna.metronet.com>
On Sat, 10 Jun 2000 11:54:18 -0500, david <djhill@ameritech.net> wrote:
>What other uses are there for PERL
>besides creating websites?
Everything.
Perl (not PERL) existed for years before the WWW was
even invented!
I've used Perl everyday for several years. I've never written
a CGI program.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 11 Jun 2000 14:08:10 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: where can I find doc for epl files
Message-Id: <8i06g4$fnr$1@nnrp1.deja.com>
In article <393FEF08.34951F7B@deja.com>,
smohamme@deja.com wrote:
> Hi Guys,
> Which perldoc has the document for .epl files??? Thank you for
your
> help.
>
I guess you are speaking about Embedded Perl (ePerl).
If so, consult http://www.engelschall.com/sw/eperl for details.
Hope this helps.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 11 Jun 2000 13:33:30 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: Write to file via CGI script?
Message-Id: <8i04fa$ebe$1@nnrp1.deja.com>
In article <8hvd8a$vsv$1@nnrp1.deja.com>,
xenite9@my-deja.com wrote:
> Hi,
>
> I've been trying to build a CGI interface to my firewall on my
> *trusted* LAN so I can administer my firewall through my web browser.
> It's my way of motivating myself to learn Perl/CGI. I really don't
> know what I'm doing. This is my test script. Here goes. I was able
> to figure out how to pass the arguments this script (below) needs to
> give the output I want. If the argument for the "$web" variable
equals
> on, it prints the first message stating that "Web is enabled", else it
> prints the "Web is not enabled" message and so on for the other "$'s".
> I'm sure that's clear to all you guys who know what you're doing.
> Then I went to phase 2 of my project. Since I ultimately need
the
> code to open the firewall script file (text) and write to it if the
> value=on, I inserted some code I got from www.perlmonks.com to do just
> that. Actually I tried a lot of different code samples from their
> site. The cgi script still executes like it did before I added the
> file writing code, but fails to write to disk. It will not write to
> disk. Anyone have any ideas on how I can get the code to write to
disk
> if the value=on? Any help would be appreciated.
>
> Thanks.
> AC
>
> #!/usr/bin/perl -w
>
use strict;
> use CGI qw(:standard);
>
use CGI::Carp qw(fatalsToBrowser);
> print "Content-type: text/html\n\n";
IMHO, if you already use CGI, why not to:
print header();
> print "Service Status";
>
> #In step some kicking variables
> $web = param("web");
> $email = param("email");
> $ftp = param("ftp");
>
> if ($web eq "on") {
> print "Web is enabled.";
>
> #Opens text file called fwscript-trys to write to it-fails
> $fwscript = "fwscript";
>
> open FH, ">>$fwscript";
You *always* should check return values from system calls:
open FH, ">>$fwscript" or die "cannot open $fwscript: $!\n";
Also you should use '/full/path/to/fwscript' instead
of 'fwscript' as a file name. If you don't specify the
full path, you script tries to create the file in the
current working directory (which may or may not be one where
script itself resides), so you end up trying to create
a file in an unknown (to you) directory.
> print FH "I will print this to a file\n";
>
> } else {
> print "Web is not enabled.";
> }
>
...skipped...
BTW, if you are going to perform a task which requires
root privileges (administrating a firewall) from cgi script
be prepared to manage various permission issues.
And don't miss Randal L. Schwartz UnixReview
(http://www.stonehenge.com/merlyn/UnixReview/)
and WebTechniques (http://www.stonehenge.com/merlyn/WebTechniques/)
columns.
Hope this helps.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 11 Jun 2000 11:21:57 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Write to file via CGI script?
Message-Id: <slrn8k7bkl.56k.tadmc@magna.metronet.com>
On Sun, 11 Jun 2000 06:57:16 GMT, xenite9@my-deja.com <xenite9@my-deja.com> wrote:
>site. The cgi script still executes like it did before I added the
>file writing code, but fails to write to disk. It will not write to
>disk.
>open FH, ">>$fwscript";
Just asking (to open a file) does not imply what you will get
what you asked for.
You should always, yes *always*, check the return value
from open() calls:
open FH, ">>$fwscript" or die "could not open '$fwscript' $!";
The docs for open() say the same thing.
It is not possible that you are using the open() function without
reading about the open() function, is it?
That would be as foolish as signing a contract without reading it.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 3322
**************************************