[15962] in Perl-Users-Digest
Perl-Users Digest, Issue: 3374 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 15 14:15:48 2000
Date: Thu, 15 Jun 2000 11:15:35 -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: <961092935-v9-i3374@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 15 Jun 2000 Volume: 9 Number: 3374
Today's topics:
Re: NET::SMTP <tschilbach@aodinc.com>
Re: NET::SMTP <care227@attglobal.net>
Re: NET::SMTP <iltzu@sci.invalid>
Re: NET::SMTP <red_orc@my-deja.com>
Re: NT vs Unix detection <pds@x-datcon.co.uk>
Re: OLE and CGI ?? Not working ! roeerubin@my-deja.com
Re: perl to read a given URL <red_orc@my-deja.com>
Re: Question: any ASP parser available? <abe@ztreet.demon.nl>
return process management in perl rico28@my-deja.com
Re: Securing script edited data on a public server nobull@mail.com
segmentation fault <smaharaj@bu.edu>
Re: simple array question (Mark-Jason Dominus)
Sorting a ':' delimeted file by a field value/surname. <jimmy.lantz@ostas.lu.se>
Re: Sorting a ':' delimeted file by a field value/surna <blah@nospam.com>
Re: Sorting a ':' delimeted file by a field value/surna <wizard@psychodad.com>
Re: Sorting a ':' delimeted file by a field value/surna <lr@hpl.hp.com>
Re: sorting an array <sariq@texas.net>
Taryag Perl <tzadikv@my-deja.com>
Re: Taryag Perl <tony_curtis32@yahoo.com>
Re: trouble installing manpages <lsloan@umich.edu>
uploading files problem <wstsoi@hongkong.com>
Re: uploading files problem <care227@attglobal.net>
Re: uses for PERL (Mark-Jason Dominus)
Re: uses for PERL <rootbeer@redcat.com>
Re: uses for PERL (Mark-Jason Dominus)
Re: uses for PERL (Randal L. Schwartz)
want some money??? <dbigger@redhotant.com>
Re: want some money??? <care227@attglobal.net>
Re: works without strict but not with why ???? <abe@ztreet.demon.nl>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 15 Jun 2000 11:29:35 -0500
From: "Timothy H. Schilbach" <tschilbach@aodinc.com>
Subject: Re: NET::SMTP
Message-Id: <8ib0bm$tmo$1@news.chatlink.com>
Dan,
Whats jeopardy posting? I am new to newsgroups and I am used to a formal
support system. Sorry if I annoy you. But I am just searching for answers.
--
Timothy H. Schilbach
Alpha Omega Design Inc.
tschilbach@aodinc.com
1-877-263-7094
Visit our website at www.aodinc.com
Dan Sugalski <dan@tuatha.sidhe.org> wrote in message
news:Kq525.1163$Zg4.6078@news1.rdc1.ct.home.com...
> Timothy H. Schilbach <tschilbach@aodinc.com> wrote:
> > Dan,
>
> > No upgrades of PERL over libnet. It works in all my other apps except
for
> > this one. All my casing is correct (went back and corrected it) and yet
> > still get the same results. Any other suggestions?
>
>
> Two:
>
> 1) (non-topic-specific) Stop jeapordy-quoting, please! Makes it tough to
> track what's going on
>
> 2) Check to make sure the Net::SMTP->new call actually suceeded. You don't
> check, and it could well have failed. That'd leave you calling a method on
> undef, which won't work too well... :)
>
> Dan
>
>
> > --
> > Timothy H. Schilbach
> > Alpha Omega Design Inc.
> > tschilbach@aodinc.com
> > 1-877-263-7094
> > Visit our website at www.aodinc.com
>
> > Dan Sugalski <dan@tuatha.sidhe.org> wrote in message
> > news:dkX15.1123$Zg4.5233@news1.rdc1.ct.home.com...
> >> Timothy H. Schilbach <tschilbach@aodinc.com> wrote:
> >> > Dan,
> >>
> >> > This did not fix the problem, get the same errors reguardless. PERL
on
> > NT
> >> > doesnt seem to be case sensitive. Any other suggestions?
> >>
> >> Perl on NT is case-sensitive. Perl everywhere is case-sensitive.
(Actually
> >> you can get away with the "use" bit in a case-insensitve manner on
systems
> >> with case-insensitive filesystems, but it can cause problems and is
> >> generally a good way to get unreliable results. Been there. Done that.
> >> Didn't like it... :)
> >>
> >> Did you maybe upgrade perl over an existing libnet install? That might
> >> cause you problems of some sort, and a reinstall can't hurt. It's
> >> certainly easy enough with PPM.
> >>
> >> Dan
> >>
> >> > "Timothy H. Schilbach" <tschilbach@aodinc.com> wrote in message
> >> > news:8i8su3$pc6$1@news.chatlink.com...
> >> >> Ok here is a simple question and some background. I have a script
that
> >> >> automatically activates user accounts when they signup for our
> > services.
> >> >> This works great except for the NET::SMTP section that is supposed
to
> >> > email
> >> >> the client and then the administrator when the account is activated.
I
> >> > keep
> >> >> getting this:
> >> >>
> >> >> Can't call method "mail" on an undefined value at
> >> >> I:\aodinc.com\cgi-bin\signup.pl line 298.
> >> >>
> >> >> Below I have imput the lines of code as well. For some reason its
not
> >> >> recognizing the "mail" command. Without this varable, the message
would
> >> > not
> >> >> be sent to the user. Any suggestions on how to overcome this? I have
> >> >> commented the troubled line.
> >> >>
> >> >> Code:
> >> >> sub sendmailtouser {
> >> >>
> >> >> if ($FORM{'email'} =~ /\@/) {
> >> >>
> >> >> use NET::SMTP;
> >> >>
> >> >> $smtp = Net::SMTP->new($server);
> >> >> $smtp->mail($ENV{USER}); # This is the line it says
it
> >> > cannot
> >> >> recognize
> >> >>
> >> >> $smtp->to("$FORM{'email'}\n");
> >> >>
> >> >> $SMTP->data();
> >> >> $SMTP->datasend("From: Automated Server\n");
> >> >> $SMTP->datasend("To: $FORM{'first_name'}\n");
> >> >> $SMTP->datasend("Subject: Internet Service Order Completed.\n");
> >> >> $SMTP->datasend("\n");
> >> >>
> >> >> $SMTP->datasend("Below is your account information\n");
> >> >> $SMTP->datasend("please print this out for your reference:\n\n");
> >> >> $SMTP->datasend("Dial-Up Username: ${dialuser}\n");
> >> >> $SMTP->datasend("Dial-Up Password: $FORM{'password'}\n");
> >> >> $SMTP->datasend("Access Numbers: $location\n\n");
> >> >>
> >> >> $SMTP->datasend("Newsgroup Username: newservice\n");
> >> >> $SMTP->datasend("Newsgroup Password: begin\n");
> >> >> $SMTP->datasend("Newsgroup Server: ${news}\n\n");
> >> >>
> >> >> if ($e =~ /1|3/) {
> >> >> $SMTP->datasend("Email Username: $FORM{'username'}\n");
> >> >> $SMTP->datasend("Email Password: $FORM{'password'}\n");
> >> >> }
> >> >>
> >> >> $SMTP->datasend("Incoming Mail Server: ${pop}\n");
> >> >> $SMTP->datasend("Outgoing Mail Server: ${smtp}\n\n");
> >> >>
> >> >> if ($e =~ /2|3/) {
> >> >> $SMTP->datasend("FTP Username: $FORM{'username'}\n");
> >> >> $SMTP->datasend("FTP Password: $FORM{'password'}\n");
> >> >> $SMTP->datasend("FTP Server: ${ftp}\n");
> >> >> $SMTP->datasend("Web Address:
> >> >> http://members.${domain}/$FORM{'username'}/\n");
> >> >> }
> >> >>
> >> >> $SMTP->datasend("If you have any problems, please call $phone\n");
> >> >> $SMTP->datasend();
> >> >>
> >> >> $SMTP->quit;
> >> >>
> >> >> } }
> >> >>
> >> >> --
> >> >> Timothy H. Schilbach
> >> >> Alpha Omega Design Inc.
> >> >> tschilbach@aodinc.com
> >> >> 1-877-263-7094
> >> >> Visit our website at www.aodinc.com
> >> >>
> >> >>
> >>
> >>
>
>
------------------------------
Date: Thu, 15 Jun 2000 12:40:29 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: NET::SMTP
Message-Id: <394906FD.7BD6509B@attglobal.net>
"Timothy H. Schilbach" wrote:
>
> Dan,
>
> Whats jeopardy posting? I am new to newsgroups and I am used to a formal
> support system. Sorry if I annoy you. But I am just searching for answers.
>
Normal human conversation follows the model of question->answer.
The TV Gameshow "Jeopardy" follows the model of answer->question.
Posting the reply above the question is considered Jeopardy posting.
This style makes it very difficult to follow the flow of the
conversation.
------------------------------
Date: 15 Jun 2000 16:44:16 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: NET::SMTP
Message-Id: <961086854.25840@itz.pp.sci.fi>
In article <8iak8r$o8t$1@nnrp1.deja.com>, Rodney Engdahl wrote:
>In article <8i8su3$pc6$1@news.chatlink.com>,
> "Timothy H. Schilbach" <tschilbach@aodinc.com> wrote:
>>
>> Can't call method "mail" on an undefined value at
>> I:\aodinc.com\cgi-bin\signup.pl line 298.
>>
>> $smtp->mail($ENV{USER}); # This is the line it says it
>> cannot recognize
>
>seems to me that the diagnostic is complaining about $ENV{USER}, not the
>'mail' method.
Did _either_ of you read perldiag? The message means that $smtp is
undefined. Since it is undefined, it is obviously not an object ref,
and therefore you can't call a method (such as "mail") on it.
The original poster should do something like this:
my $smtp = Net::SMTP->new($host)
or die "Can't connect to SMTP host $host!\n";
Now $smtp is not just properly lexically scoped, but - assuming the
program doesn't die - also guaranteed to be defined. (Actually, the
"or" checks for truth, not definedness, but any defined return value
should be an object reference, which are always true.)
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Thu, 15 Jun 2000 17:32:07 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: NET::SMTP
Message-Id: <8ib3un$595$1@nnrp1.deja.com>
In article <961086854.25840@itz.pp.sci.fi>,
Ilmari Karonen <usenet11123@itz.pp.sci.fi> wrote:
>
>
> Did _either_ of you read perldiag? The message means that $smtp is
> undefined. Since it is undefined, it is obviously not an object ref,
> and therefore you can't call a method (such as "mail") on it.
>
> The original poster should do something like this:
>
> my $smtp = Net::SMTP->new($host)
> or die "Can't connect to SMTP host $host!\n";
>
> Now $smtp is not just properly lexically scoped, but - assuming the
> program doesn't die - also guaranteed to be defined. (Actually, the
> "or" checks for truth, not definedness, but any defined return value
> should be an object reference, which are always true.)
>
Ooops! Sorry. You are, of course, right.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 15 Jun 2000 16:12:54 +0100
From: "Paul D.Smith" <pds@x-datcon.co.uk>
Subject: Re: NT vs Unix detection
Message-Id: <8iarpr$rdt$1@soap.pipex.net>
Will $OSNAME aka $^O do for you?
Paul DS
--
Please remove the "x-" if replying to sender.
"Larry R. Waibel" <lwaibel@cwia.com> wrote in message
news:VA.00000036.0c88e0c7@cwia.com...
> I've got some scripts that I want to be able to run on either NT or HP-UX.
> What's the general/accepted/best way for a Perl script to determine which
OS
> it's running under? Thanks!
>
------------------------------
Date: Thu, 15 Jun 2000 16:30:33 GMT
From: roeerubin@my-deja.com
Subject: Re: OLE and CGI ?? Not working !
Message-Id: <8ib0ba$29a$1@nnrp1.deja.com>
I tried the following ...
use CGI;
use OLE;
$co=new CGI;
print $co->header();
print $co->start_html;
$|=1;
$xl = CreateObject OLE "Excel.Application" || die "CreateObject: $!";
$xl->{Visible} = 1;
$xl->Workbooks->Add();
print "$xl";
print $co->end_html;
===========
It doesn't seem to work correctly. Excel is not visible at any point as
it should be from the $xl->{Visible} = 1 command.
I took a look at the task manager and excel process does start but does
not run as it should (as it does from the command line without the CGI)
I have had the same behavior using Outlook, IE, and SourceSafe objects.
Any moe thoughts on the issue??
In article <8ia66s$eq9$1@nnrp1.deja.com>,
Jeremy Gurney <c4jgurney@my-deja.com> wrote:
> In article <8i8rr5$gjv$1@nnrp1.deja.com>,
> rrubin@rotor.net wrote:
> > Hello,
> >
> > I am trying to run a CGi script that performs a certain function
> > using OLE. The script runs great from the command line but once I
> > embed the CGI calls into the script it doesn't work.
> >
> > I am currently running this on WIndows NT and
> > Personal Web Server.
> >
>
> The thing which catches most people out here is when you're running
the
> web server as a service. If the service is running under the
localsystem
> account your CGIs can use OLE but can't access NT networks, however if
> the service is running under a user account it can access the network
> but can't use OLE.
>
> If you're not running PWS as a service then the OLE should work just
> fine.
>
> The following should work as a minimal test of OLE if excel is
installed
> and should print 0 is there are no problems. Just wrap it up in a CGI
> and give it a whirl.
>
> use Win32::OLE;
> $ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;});
> print Win32::OLE->LastError();
> undef $ex;
>
> Cheers,
>
> Jeremy Gurney
> SAS Systems Analyst | Protherics Molecular Design Ltd.
> "When everything is coming your way, you're in the wrong lane."
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 15 Jun 2000 15:41:22 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: perl to read a given URL
Message-Id: <8iateu$vrh$1@nnrp1.deja.com>
In article <8iaqj5$mtk$1@vg170.it.volvo.se>,
"Tony Shrimpoton" <ts@relson.net> wrote:
> Hi All ,
>
> I need to write a bit of perl to go to a specific web page and
> then check for results on that page and then it needs to update our DB
> if specific fields are found. The DB bit if fine its just the part
> where i need to fetch the given url
>
> any suggestions where i can find any information on this?
>
Sounds like a job for the LWP module
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 15 Jun 2000 18:17:02 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Question: any ASP parser available?
Message-Id: <0avhkskep5tcdl6u5uor71ne8aacik2rjn@4ax.com>
On 14 Jun 2000 15:14:03 -0500, Eric Liao <ekliao@mediaone.net> wrote:
> Hi All,
>
> My work requires parsing *.asp files for identifying and extracting
> certain text strings for the purposes of translation (into foreign
> languages). Is there any ASP parser out there that is
> available/useful for such purposes? Any input welcome. Thanks.
ASP is not a language, so there is nothing to parse there.
It depends whether the strings are in the HTML context or the script
context of the page.
If in the script context, you will need to know what scripting language
is used (VBS, Jscript or even PerlScript).
You'll need to find out where those 'text strings' are.
(ASP writers can make quite a mess of these things)
Maybe HTML::Parser can sort out the script-bits and HTML-bits for you.
--
Good luck,
Abe
------------------------------
Date: Thu, 15 Jun 2000 16:53:34 GMT
From: rico28@my-deja.com
Subject: return process management in perl
Message-Id: <8ib1m4$3bd$1@nnrp1.deja.com>
Hi, I wrote some code that reads a string that gets copied to the
Windows clipboard, extracts a host name and pings the host. I am having
trouble getting the program to end if I run it from the command line.
If I run it from the command line, it hangs. However, if I double click
on a shortcut for the program it runs fine.
I also am having problems getting it to loop through the program. I
have tried several do, whiles, etc but none are working for me. As the
program stands, it only grabs the first instance of the desired string
(host), however there are 3 or 4 instances of the host I want to ping.
Any help is appreciated. The code and some sample data are below.
Code...
# This Perl script gets the contents of the clipboard copied from
Unicenter, parses the data and removes the server names. It then pings
# the servers in the list.
use Win32::Clipboard;
$text = Win32::Clipboard();
$text->Get(), "\n";
do{
# read the characters of the $text into the REGEX
variable
$_= $text->Get();
$_=~ /( is.*com )/i;
$hostName = $1;
print "hostname is $hostName";
use win32::Process;
Win32::Process::Create($Process,
'c:\winnt\system32\ping.exe',$hostName,0, DETACHED_PROCESS,
,".") ;
#use Win32;
#Win32::Spawn('c:\winnt\system32\ping.exe',
$hostName, $pid);
#$stop = $pid;
#}until ($pid =0);
}until (eof);
****************************************************************
Sample data...
E N 08:40:02 is006386.company.com NT AUTHORITY\SYSTEM
(null) SMSSystem_TRAP_Cri:is006386.bell-atl.com:Subtype:5719:Error
NETLOGON:1.3.6.1.4.1.311.1.4.1.1.0:No Windows NT Domain Controller is
available for domain BA_MD. (This event is expected and can be ignored
when booting with the 'No Net' Hardware Profile.) The following error
occurred: The RPC server is unavailable.
:1.3.6.1.4.1.311.1.4.1.2.0:Unknown:1.3.6.1.4.1.311.1.4.1.3.0:05119-FP-07
:1.3.6.1.4.1.311.1.4.1.4.0:1:1.3.6.1.4.1.311.1.4.1.5.0:0:1.3.6.1.4.1.311
.1.4.1.6.0:BA_MD:1.3.6.1.4.1.311.1.4.1.7.0:The RP: ( ClassName =
SMSSystem oldState = Unknown newState = Broken )
E N 08:40:08 is006384.company.com NT AUTHORITY\SYSTEM
(null) SMSSystem_TRAP_Cri:is006384.bell-atl.com:Subtype:5719:Error
NETLOGON:1.3.6.1.4.1.311.1.4.1.1.0:No Windows NT Domain Controller is
available for domain BA_MD. (This event is expected and can be ignored
when booting with the 'No Net' Hardware Profile.) The following error
occurred: The RPC server is unavailable.
:1.3.6.1.4.1.311.1.4.1.2.0:Unknown:1.3.6.1.4.1.311.1.4.1.3.0:05119-FP-06
:1.3.6.1.4.1.311.1.4.1.4.0:1:1.3.6.1.4.1.311.1.4.1.5.0:0:1.3.6.1.4.1.311
.1.4.1.6.0:BA_MD:1.3.6.1.4.1.311.1.4.1.7.0:The RP: ( ClassName =
SMSSystem oldState = Unknown newState = Broken )
E N 11:21:01 is002786.company.com NT AUTHORITY\SYSTEM
(null) NT Agent reports Physical Memory Critical ( ClassName =
NtMemPhys oldState = Warning newState = Critical )
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 15 Jun 2000 17:30:17 +0100
From: nobull@mail.com
Subject: Re: Securing script edited data on a public server
Message-Id: <u9u2eunbza.fsf@wcl-l.bham.ac.uk>
cLive ;-) <cliveNOclSPAM@thesource.org.uk.invalid> writes:
> I vaguely remember something about setting the effective
> user id(?) of the script to run as user rather than nobody,
> and then setting data file permissions to 700 to stop
> everyone else from reading the data.
>
> How close to the mark am I?
Dead-on. (except you mean 600 not 700 surely!)
This is a best handled as web server configuration/management issue
and as such has nothing to do with Perl. Check the docs for the web
server software.
Alternatively use setuid scripts (see "perldoc perlsec").
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 15 Jun 2000 13:50:56 -0400
From: "news" <smaharaj@bu.edu>
Subject: segmentation fault
Message-Id: <8ib524$fi8$1@news3.bu.edu>
I keep getting a SEGMENTATION FAULT (core dump ) error when running a perl
script on an AIX box. This scipt uses DBI and has some external subroutines
which use the mime and smtp modules. Upon running the script in debug mode i
can trace it to the following line...
DynaLoader::bootstrap(/usr/local/lib/perl5/5.00501/aix/DynaLoader.pm:110):
110: croak ("can't load module $module, dynamic loading
not available.......")
you may need to build a new perl executable...
I dunno if anyone else has run into this sort of problems when working on a
AIX box..
Any help or suggestions will be greatly appreciated.
thanks..
------------------------------
Date: Thu, 15 Jun 2000 15:48:14 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: simple array question
Message-Id: <3948fabd.5309$3a0@news.op.net>
In article <394843b8_1@news.bne.gil.com.au>,
Phil Sutcliffe <ils@gil.com.au> wrote:
>@fields=("GBH","QLD","1234");
>
>@names=("\$company","\$state","\$postcode");
@data{@names} = @fields
Then you can use
$data{'$state'}
to get back the state information.
------------------------------
Date: Thu, 15 Jun 2000 18:14:51 +0200
From: Jimmy Lantz <jimmy.lantz@ostas.lu.se>
To: Forum Macperl <macperl-forum@macperl.org>
Subject: Sorting a ':' delimeted file by a field value/surname.
Message-Id: <394900FB.7A147505@ostas.lu.se>
Hi,
I'm looking for a way to sort a text file (example below),
it's delimited by : I need to sort lines according to surname.
I'm working with Macperl, and I'm trying to do all the coding my self
(not using that many fancy Modules due to "portability".
Has anyone any Ideas on how to sort the lines in alphabetical order, A-Z
(to add extra spice I need to sort the swedish chars едц as well).
Is there a man on this, I've been browsing a lot looking for one.
So I have RTFM but I still dont see how I can make this work.
Could anyone give me any pointers on how to go about doing it ?
Also if someone know about some tutorials on how to make searches on
Datafiles I would appreciat a link or two.
############# Exampleline from file. ##############
KIN231:111111-1111:John:Burnes:jburnes@hotmail.com:555121212:greenway
21:PO 251:Bournesporth:Scolarship:YES
^^^^^^
Needs to sort file according to the fifth field in the line.
Yours sincerely
Jimmy Lantz
Sweden
---------------
I hope this isn't too much a newbie q for y'all.
------------------------------
Date: Thu, 15 Jun 2000 18:39:21 +0200
From: Marco Natoni <blah@nospam.com>
Subject: Re: Sorting a ':' delimeted file by a field value/surname.
Message-Id: <394906B9.16C27313@nospam.com>
Jimmy,
Jimmy Lantz wrote:
> I'm looking for a way to sort a text file (example below),
> it's delimited by : I need to sort lines according to =
> surname. I'm working with Macperl, and I'm trying to do all the =
> coding my self (not using that many fancy Modules due =
> to "portability". Has anyone any Ideas on how to sort the lines =
> in alphabetical order, A-Z (to add extra spice I need to sort =
> the swedish chars =E5=E4=F6 as well). Is there a man on this, I've =
> been browsing a lot looking for one. So I have RTFM but I still =
> dont see how I can make this work. Could anyone give me any =
> pointers on how to go about doing it ? Also if someone know about =
> some tutorials on how to make searches on Datafiles I would =
> appreciat a link or two.
> ############# Exampleline from file. ##############
> KIN231:111111-1111:John:Burnes:jburnes@hotmail.com:555121212:greenway
> 21:PO 251:Bournesporth:Scolarship:YES
> ^^^^^^
> Needs to sort file according to the fifth field in the line.
<code>
while (<>) { $sorted{(split /:/)[4]}=3D$_ }
foreach $key (sort keys %sorted) { print $sorted{$key} }
</code>
Anyway, I suggest you to look for the text-based DBD modules.
Best regards,
Marco
------------------------------
Date: Thu, 15 Jun 2000 11:47:24 -0500
From: "Michael D. Kirkpatrick" <wizard@psychodad.com>
Subject: Re: Sorting a ':' delimeted file by a field value/surname.
Message-Id: <3949089C.E3454D9E@psychodad.com>
Easiest way to do it is to put the entire file in an array.
Example:
open (DB, "your_file.db");
while (<DB>){
chop($_);
($trash,$trash,$trash,$trash,$key,$trash) = split (/\:/,$_);
#make the key your 5th item to be sorted by
$my_array{$key} = $_;
}
close (DB);
foreach $key(sort keys(%my_array)){
$current_record = $my_array{$key};
#do what ever you want with the record...
#as it loops through, all the records will be
#sorted in alphebetical order of the key.
}
Quick and easy...
Jimmy Lantz wrote:
> Hi,
> I'm looking for a way to sort a text file (example below),
> it's delimited by : I need to sort lines according to surname.
> I'm working with Macperl, and I'm trying to do all the coding my self
> (not using that many fancy Modules due to "portability".
> Has anyone any Ideas on how to sort the lines in alphabetical order, A-Z
> (to add extra spice I need to sort the swedish chars едц as well).
>
> Is there a man on this, I've been browsing a lot looking for one.
> So I have RTFM but I still dont see how I can make this work.
> Could anyone give me any pointers on how to go about doing it ?
>
> Also if someone know about some tutorials on how to make searches on
> Datafiles I would appreciat a link or two.
>
> ############# Exampleline from file. ##############
> KIN231:111111-1111:John:Burnes:jburnes@hotmail.com:555121212:greenway
> 21:PO 251:Bournesporth:Scolarship:YES
> ^^^^^^
> Needs to sort file according to the fifth field in the line.
>
> Yours sincerely
> Jimmy Lantz
> Sweden
>
> ---------------
> I hope this isn't too much a newbie q for y'all.
------------------------------
Date: Thu, 15 Jun 2000 10:28:48 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Sorting a ':' delimeted file by a field value/surname.
Message-Id: <MPG.13b2b2294633f1e398ab85@nntp.hpl.hp.com>
In article <394906B9.16C27313@nospam.com>, blah@nospam.com says...
> Jimmy Lantz wrote:
> > I'm looking for a way to sort a text file (example below),
> > it's delimited by : I need to sort lines according to =
> > surname. I'm working with Macperl, and I'm trying to do all the =
> > coding my self (not using that many fancy Modules due =
> > to "portability". Has anyone any Ideas on how to sort the lines =
> > in alphabetical order, A-Z (to add extra spice I need to sort =
> > the swedish chars =E5=E4=F6 as well).
Unless those characters are already in the correct sequence relative
to each other and to the ASCII characters,you cannot do that with the
default lexicograpic sort. You will need to tailor a sortsub to your
needs.
> Is there a man on this, I've =
> > been browsing a lot looking for one. So I have RTFM but I still =
> > dont see how I can make this work. Could anyone give me any =
> > pointers on how to go about doing it ?
Start with perlfaq4: "How do I sort an array by (anything)?"
> Also if someone know about =
> > some tutorials on how to make searches on Datafiles I would =
> > appreciat a link or two.
> > ############# Exampleline from file. ##############
> > KIN231:111111-1111:John:Burnes:jburnes@hotmail.com:555121212:greenway
> > 21:PO 251:Bournesporth:Scolarship:YES
> > ^^^^^^
> > Needs to sort file according to the fifth field in the line.
^^^^^
fourth
> <code>
> while (<>) { $sorted{(split /:/)[4]}=3D$_ }
^
3
> foreach $key (sort keys %sorted) { print $sorted{$key} }
> </code>
...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 15 Jun 2000 10:15:20 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: sorting an array
Message-Id: <3948F308.53CFE30E@texas.net>
Russ Jones wrote:
>
> Tom Briles wrote:
> >
> > Larry Rosler wrote:
> > >
> > > Instead of using the SQL 'ORDER BY' capability -- which imposes the
> > > computational burden on the database daemon (which may be on a separate
> > > machine, and may be handling several requests simultaneously) -- I
> > > prefer to sort in the application that requests the data. I know how to
> > > do sorting in Perl efficiently (-:) and more flexibly than SQL can.
> > >
> > > I would be interested in other experiences with this kind of tradeoff
> > > between the Perl program and the database server.
> >
> > I don't think that it's quantifiable in a general way.
> >
>
> I did a bunch of benchmarking of various sort methods, including
> Perl's sort, the HP-UX and Sequent command line sort, SQL 'ORDER BY'
> and SyncSort for Unix. We tried to take into account such factors as
> number of records to sort, record length, sort key, collating sequence
> (numeric, alpha, etc.), original "sortedness" of the data, network
> traffic when the data was on another server from the sort program,
> caches and buffers, etc. to make it a fair comparison of apples and
> oranges as was possible.
But a database that is properly configured (i.e., indexed) for the
workload is *pre*sorted. So using Perl (or 'sort', etc.) to sort the
results of the query seems rather silly.
And just bunching 'SQL ORDER BY', without consideration of the database
engine, seems silly too.
I maintain my previous assertion.
- Tom (Perl hacker by night, Oracle DBA by day)
------------------------------
Date: Thu, 15 Jun 2000 17:26:17 GMT
From: Tzadik Vanderhoof <tzadikv@my-deja.com>
Subject: Taryag Perl
Message-Id: <8ib3j1$4su$1@nnrp1.deja.com>
Is it just a coincidence that ActiveState's lastest release is "build
613"? I think not.... :)
--
Tzadik
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 15 Jun 2000 12:58:33 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Taryag Perl
Message-Id: <87wvjqj06u.fsf@limey.hpcc.uh.edu>
>> On Thu, 15 Jun 2000 17:26:17 GMT,
>> Tzadik Vanderhoof <tzadikv@my-deja.com> said:
> Is it just a coincidence that ActiveState's lastest
> release is "build 613"? I think not.... :)
A coincidence with what?
t
--
"Trying is the first step towards failure"
Homer Simpson
------------------------------
Date: Thu, 15 Jun 2000 12:29:24 -0400
From: Lance E Sloan <lsloan@umich.edu>
Subject: Re: trouble installing manpages
Message-Id: <39490464.B2AA3386@umich.edu>
Nnickee wrote:
> On 14 Jun 2000 15:13:10 GMT, someone claiming to be
> steveharvey@geocities.com (Steve Harvey) said:
>
> >In article <394797F1.AB7B2822@umich.edu>, Lance E Sloan wrote:
> >>I'd appreciate it if responses could be emailed to me as well as
> >>posted to this newsgroup.
>
> >Two gentle, civilized suggestions:
>
> >2. As a general point of netiquette, some folks consider it rude when
> > people request answers to their questions to be emailed directly.
> > Sort of like that if people are going to take the time to answer
> > your question, you can at least take the time to check back on the
> > newsgroup for responses. Plus, somebody else might benefit from
> > the same info.
>
> Steve, that was indeed very gentle, and I agree with you, but... Lance
> asked for email *as well as* posted to the group... I used to do that
> too when I had a yucky newsserver that didn't get all the posts.
> Maybe that's why Lance asked...
> Just a thought :)
> Nnickee
Yes, thank you, that's it exactly. In the past I had breached netiquette
by
simply asking people to email me a response. I soon learned the nce
thing to
do it to request the email in addition to the newsgroup posting. Since
I've
done that, nobody's complained until now. Anyway, my request was just
that, a request and not a command.
Anyway, perhaps my question seems OS- or AFS-specific. All I really
want to know is, why does the script for installing manpages use find and
why does it apparently start at the root directory (/)? If nobody can
answer
me that, maybe I'll just throw caution to the wind and install the
manpages
another way, probably by hacking the script.
------------------------------
Date: Fri, 16 Jun 2000 00:08:32 +0800
From: "Lucas" <wstsoi@hongkong.com>
Subject: uploading files problem
Message-Id: <8iaure$og3@imsp212.netvigator.com>
Hi all, i got some problems about uploading files (as the code attached).
It seemed work initially, but later i found that the authority of
the files that i upload are set to "nobody" as "group", "users" as "user",
I cant even delete it manually unless login as root.
That make i have no ideas on record deleting function.
Is that there are other better ways for uploading files?
Thanks very much....
-----------------------------------------------------------
open (OUTFILE, ">$basedir/$fileName");
my($total)=0;
while (my $bytesread = read($file, my $buffer, 1024))
{
$total += $bytesread;
if ( $total > $img_size)
{
$err = "Photo size: $total, exceeds 500KB.";
close(OUTFILE);
return 0;
}
print OUTFILE $buffer;
}
close (OUTFILE);
-----------------------------------------------------
------------------------------
Date: Thu, 15 Jun 2000 12:34:39 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: uploading files problem
Message-Id: <3949059F.9EA0C13D@attglobal.net>
Lucas wrote:
>
> Hi all, i got some problems about uploading files (as the code attached).
>
> It seemed work initially, but later i found that the authority of
> the files that i upload are set to "nobody" as "group", "users" as "user",
> I cant even delete it manually unless login as root.
> That make i have no ideas on record deleting function.
>
> Is that there are other better ways for uploading files?
>
This really has nothing to do with the actual uploading process,
but instead is a consequence of the OS. You are creating a file
on a UNIX system. Just as would happen if you logged on to the
system directly, files created are owned initially by the UID
that created them.
Check the docs for the "chown" function.
------------------------------
Date: Thu, 15 Jun 2000 15:45:22 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: uses for PERL
Message-Id: <3948fa11.52b3$1c3@news.op.net>
In article <3948554e$0$1493$726baab@news.execpc.com>,
Mark Kaehny <kaehny@earth.execpc.com> wrote:
>I asked everyone I met on the Perl Whirl what was the LAST program or
>piece of code you wrote in perl and what was it for and < 1% were cgi or
>web related. This included ... MJD...
Yeah, but in that case you asked the wrong question, since I spent
1994-1999 writing CGI programs and other interactive web stuff, mostly
in Perl, as my main job. I got sick of it and quit last year.
>
------------------------------
Date: Thu, 15 Jun 2000 09:59:33 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: uses for PERL
Message-Id: <Pine.GSO.4.10.10006150958320.5301-100000@user2.teleport.com>
On 14 Jun 2000, Mark Kaehny wrote:
> I asked everyone I met on the Perl Whirl what was the LAST program or
> piece of code you wrote in perl and what was it for and < 1% were cgi
> or web related. This included Sarathy, Larry, Tom C. Randall, MJD,
> Andreas Koenig, etc. I thought it was quite a statement, but perhaps
> says more about the people on the trip.
Of course, Randal may write web-related stuff more often than you might
expect if you don't take his columns into account.
http://www.stonehenge.com/merlyn/WebTechniques/
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 15 Jun 2000 15:51:54 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: uses for PERL
Message-Id: <3948fb9a.536a$3ae@news.op.net>
In article <skam18qhh5157@corp.supernews.com>,
Craig Berry <cberry@cinenet.net> wrote:
>(*) Note that a true Turing-complete language demands infinite memory
>storage, a sticking point which is normally ignored.
No, it only demands unbounded memory storage. An ordinary tape drive
will serve, as long as the program will pause and wait for you to find
another blank tape when it needs one.
------------------------------
Date: 15 Jun 2000 10:25:21 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: uses for PERL
Message-Id: <m1ya46yhz2.fsf@halfdome.holdit.com>
>>>>> "Mark" == Mark Kaehny <kaehny@earth.execpc.com> writes:
Mark> I asked everyone I met on the Perl Whirl what was the LAST program or
Mark> piece of code you wrote in perl and what was it for and < 1% were cgi or
Mark> web related. This included Sarathy, Larry, Tom C. Randall, MJD, Andreas
Mark> Koenig, etc. I thought it was quite a statement, but perhaps says more
Mark> about the people on the trip.
You didn't ask me. Nor could you have asked 100 people to get less
than 1 percent to be CGI. Therefore, I think you are exaggerating a
gazillion times more than you need to achieve your point.
I'd consider Tim Bray's entire talk about XML processing to be about
"the web", and he was one of the few "featured" speakers. What does
*that* tell you?
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Thu, 15 Jun 2000 17:16:58 +0100
From: "redhotant" <dbigger@redhotant.com>
Subject: want some money???
Message-Id: <3949022d$1@news.jakinternet.co.uk>
im lazy and so I need your help. set up my ffa at www.ffauk.com (basic
scripts will do - nothing fancy) and I'll join you under some program or
other or pay for membership to anything cheaper than $20 (one off payment).
Or if you accept credit card payment (im in the uk) I might risk that. But
would prefer joining under a program to make the money back myself
anyway.... email me.... dbigger@redhotant.com
dick
------------------------------
Date: Thu, 15 Jun 2000 12:36:51 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: want some money???
Message-Id: <39490623.BCC080FD@attglobal.net>
redhotant wrote:
>
> im lazy and so I need your help. set up my ffa at www.ffauk.com (basic
> scripts will do - nothing fancy) and I'll join you under some program or
> other or pay for membership to anything cheaper than $20 (one off payment).
>
> Or if you accept credit card payment (im in the uk) I might risk that. But
> would prefer joining under a program to make the money back myself
>
> anyway.... email me.... dbigger@redhotant.com
>
> dick
Too lazy to even compose a post that describes what you want done?
And $20.00?
------------------------------
Date: Thu, 15 Jun 2000 17:27:12 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: works without strict but not with why ????
Message-Id: <jushksojn1nfebg2fg0r8pskm2gfqgggog@4ax.com>
[some quoting of what you are responding to might make this easier to
follow]
On Wed, 14 Jun 2000 22:10:30 GMT, "Daniel van den Oord"
<danielxx@bart.nl> wrote:
[from my post]
> On Wed, 14 Jun 2000 23:57:56 +0200, Abe Timmerman <abe@ztreet.demon.nl> wrote:
...
> ...
> > @months =
> > ("January","February","March","April","May","June","July","August","Septembe
> > r","October","November","December");
> > ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$dst) =
> > localtime(time()-1*3600);
> > $mon = $mon + 1;
> > ...
> > $timestamp = "$months[$mon] $mday, $year $hour:$min:$sec";
> ^^^^
> That's a bug.
> $timestamp = "$months[$mon - 1] $mday, $year $hour:$min:$sec";
>
[now your reply]
> works just fine with me !!!!
Then you didn't show us your _real_ code. Try this:
#!/usr/bin/perl -w
use strict;
my @months = qw(
January February March April May June July
August September October November December);
my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time()-1*3600);
++$mon; $year += 1900;
my $date2 = sprintf "%d%02d%02d", $year, $mon, $mday;
my $timestamp = sprintf "%s %02d, %d %02d:%02d:%02d",
$months[$mon], $mday, $year, $hour, $min, $sec;
my $correct = sprintf "%s %02d, %d %02d:%02d:%02d",
$months[$mon - 1], $mday, $year, $hour, $min, $sec;
print "$date2 => $timestamp\n";
print "$date2 => $correct\n";
__END__
--
Good luck,
Abe
------------------------------
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 3374
**************************************