another way to show results ?

2002-07-25 Thread alpha

hi all 
i am new in perl and want to know can a perl cgi , return results in other way ? 
i know cgi script return result in new webpage . but i dont want a new  page open . 
i want it return result in same page and in row i call it . 
like a counter or other web tools 

thank u in advance
ali




Re: another way to show results ?

2002-07-25 Thread Connie Chan


- Original Message - 
From: alpha [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 25, 2002 6:30 AM
Subject: another way to show results ?


hi all 
i am new in perl and want to know can a perl cgi , return results in other way ? 

It depends on how you activate the perl script. by SSI or new page as you mensioned 
below.

i know cgi script return result in new webpage . but i dont want a new  page open . 
i want it return result in same page and in row i call it . 

So you will use IFRAME, ILAYER method, or by SSI Method. but I don't know
what is in row i call it. In case, you can have some method that let javascript
to activate the script.

like a counter or other web tools 

Counter like return is a Single Process independ from your entire page.
The counter script return a boolean data which is called from the IMG tag, 
so as EMBED.

If I treat EMBED and IMG is an object, and say, you can plug any object anywhere
anytime you want. So, Iframe and iLayer are object too.

1 thing more, you may try to return the result to a frame along you current window,
if you have frames assigned.

Rgds,
Connie





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Finding the country

2002-07-25 Thread Connie Chan


- Original Message - 
From: Hytham Shehab [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 25, 2002 4:21 AM
Subject: Re: Finding the country


 Randal L. Schwartz wrote:
  If you're using it to force the language of the page, no.  Use the
  browser specification instead.
 
 thanks v. much for that Randal, but *how* ?
 how i can use the browser specification?

my $browser = $ENV{'HTTP_USER_AGENT'};
my $lang = $ENV{'HTTP_ACCEPT_LANGUAGE'};

you can also get this by javascript too.

However, that's a problem case if I am using a Chinese Win, 
and I use a English Netscape. You can get my system language 
if I use IE, however, you can't get it when I use Netscape, 
unless the user had set the browser accept other language too.

Rgds,
Connie


 
 --
 Hytham Shehab
 
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Weekly list FAQ posting

2002-07-25 Thread casey

NAME
beginners-faq - FAQ for the beginners-cgi mailing list

1 -  Administriva
  1.1 - I'm not subscribed - how do I subscribe?

Send mail to [EMAIL PROTECTED]

You can also specify your subscription email address by sending email to
(assuming [EMAIL PROTECTED] is your email address):

[EMAIL PROTECTED].

  1.2 -  How do I unsubscribe?

Now, why would you want to do that? Send mail to
[EMAIL PROTECTED], and wait for a response. Once you
reply to the response, you'll be unsubscribed. If that doesn't work,
find the email address which you are subscribed from and send an email
like the following (let's assume your email is [EMAIL PROTECTED]):

[EMAIL PROTECTED]

  1.3 - There is too much traffic on this list. Is there a digest?

Yes. To subscribe to the digest version of this list send an email to:

[EMAIL PROTECTED]

To unsubscribe from the digest, send an email to:

[EMAIL PROTECTED]

  1.4 - Is there an archive on the web?

Yes, there is. It is located at:

http://archive.develooper.com/beginners-cgi%40perl.org/

  1.5 - How can I get this FAQ?

This document will be emailed to the list once a month, and will be
available online in the archives, and at http://beginners.perl.org/

  1.6 - I don't see something in the FAQ, how can I make a suggestion?

Send an email to [EMAIL PROTECTED] with your suggestion.

  1.7 - Is there a supporting website for this list?

Yes, there is. It is located at:

http://beginners.perl.org/

  1.8 - Who owns this list?  Who do I complain to?

Casey West owns the beginners-cgi list. You can contact him at
[EMAIL PROTECTED]

  1.9 - Who currently maintains the FAQ?

Kevin Meltzer, who can be reached at the email address (for FAQ
suggestions only) in question 1.6

  1.10 - Who will maintain peace and flow on the list?

Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large,
yet padded, clue-sticks to maintain peace and order on the list. If you
are privately emailed by one of these folks for flaming, being
off-topic, etc... please listen to what they say. If you see a message
sent to the list by one of these people saying that a thread is closed,
do not continue to post to the list on that thread! If you do, you will
not only meet face to face with a XQJ-37 nuclear powered pansexual
roto-plooker, but you may also be taken off of the list. These people
simply want to make sure the list stays topical, and above-all, useful
to Perl/CGI beginners.

  1.11 - When was this FAQ last updated?

Sept 07, 2001

2 -  Questions about the 'beginners-cgi' list.
  2.1 - What is the list for?

A list for beginning Perl programmers to ask questions in a friendly
atmosphere. The topic of the list is, of course, CGI with Perl.

  2.2 - What is this list _not_ for?

* SPAM
* Homework
* Solicitation
* Things that aren't Perl related
* Non Perl/CGI questions or issues
* Lemurs
  2.3 - Are there any rules?

Yes. As with most communities, there are rules. Not many, and ones that
shouldn't need to be mentioned, but they are.

* Be nice
* No flaming
* Have fun
  2.4 - What topics are allowed on this list?

Basically, if it has to do with Perl/CGI , then it is allowed. If your
question has nothing at all to do with Perl/CGI, it will likely be
ignored.

  2.5 - I want to help, what should I do?

Subscribe to the list! If you see a question which you can give an
idiomatic and Good answer to, answer away! If you do not know the
answer, wait for someone to answer, and learn a little.

  2.6 - Is there anything I should keep in mind while answering?

We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the
beginner to the place in the FM they should R :)

  2.7 - I don't want to post a question if it is in an FAQ. Where should I
look first?

Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it.
It can save everyone time if you look in the Perl FAQs first, instead of
having a list of people refer you to the Perl FAQs :) You can learn
about 'perldoc' by typing:

perldoc perldoc

At your command prompt. You can also view documentation online at:

http://www.perldoc.com and http://www.perl.com

3 - Other Resources
  3.1 - What other websites may be useful to a beginner ?

* Perl Home Page - http://www.perl.com
* PerlMonks - http://www.perlmonks.org
* Perldoc - http://www.perldoc.com
* Perl Archives - http://www.perlarchives.com
  3.2 - What resources may be harmful to a beginner?

Beware of Perl4-like code-- You might find some script archives and
unauthorized mirrors with old Perl4 versions of Selena Sol and Matt
Wright scripts. Don't use those scripts. They are outdated and may even
in some cases contain bugs or security problems since many may not have
been updated in 

Re: Upgrade to Perl

2002-07-25 Thread drieux


On Wednesday, July 24, 2002, at 10:53 , Soheil Shaghaghi wrote:
[..]

 2. I see so many Perl executables, and don't know which one the latest one
 is, or what I should do at this point to get the server to report Perl to 
 be
 5.6.1

 /usr/bin/perlCreated: 12/25/2000
[..]
 /usr/bin/perl5.6.0Created: 12/25/2000

 /usr/local/bin/perlCreated: 07/24/2002
 /usr/local/bin/perl5.6.0 Created: 12/22/2000
 /usr/local/bin/perl5.6.1 Created: 07/24/2002

there is your basic problem - you have the older version
in the /usr/bin - hence in the /usr side of the game,
and the newer version was configured to use /usr/local...

hence you will find that there is a

/usr/lib/perl5

and a

/usr/local/lib/perl5

and I'm willing to almost bet that you PATH is rigged
to have

/usr/bin:/usr/local/bin


let's try this another way around:

vladimir: 58:] pwd ; ls -li perl* /usr/bin/perl | sort
/usr/local/bin
 558805 -rwxr-xr-x   3 root other1175680 Mar 19 15:31 /usr/bin/
perl
 558805 -rwxr-xr-x   3 root other1175680 Mar 19 15:31 perl
 558805 -rwxr-xr-x   3 root other1175680 Mar 19 15:31 perl5.6.1
 558810 -rwxr-xr-x   1 root other  35477 Mar 19 15:31 perlbug
 558811 -rwxr-xr-x   1 root other  22655 Mar 19 15:31 perldoc
 558814 -rwxr-xr-x   1 root other  16932 Mar 19 15:31 perlcc
 558839 -rwxr-xr-x   1 root other 422100 Nov 17  1996 perl4.035
 558908 -rwxr-xr-x   1 root other 737352 Jun 14  1998 
perl5.00404
 558911 -rwxr-xr-x   1 root other 642576 Feb  8  1998 perl5.003
vladimir: 59:]

As you will note we have three 'linked' players -

/usr/bin/perl
/usr/local/bin/perl
/usr/local/bin/perl/5.6.1

Only one of them is the 'actual file' as it were...

One of the 'silly bits' that is in play here is that perl came up
with a great way to allow for both

#!/usr/local/bin/perl

as well as running against a specific instance of perl by name...

God alone only knows why I would want to expressly call out

#!/usr/local/bin/perl4.035

but in theory I can do it...

 3. Is there a configuration somewhere I need to change?

check how you did the 'make' and configure stage

and decide which way you want to 'swing' in all of this.

either you want to install so that everything goes into

/usr/lib/perl5

or into

/usr/local/lib/perl5


 When I run perl -V, here is what I get:
 perl -V
 Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:

[..]

this may be the imfamous 'oopsie' - where you installed
a copy of the 5.6.1 version in a way that it is not
the 'default' perl in your path

do a 'which perl' and/or 'whereis perl'

eg:

vladimir: 60:] which perl
/usr/local/bin/perl
vladimir: 61:] whereis perl
perl: /usr/bin/perl /usr/local/bin/perl4.035 /usr/local/bin/perl 
/usr/local/bin/perl5.003 /usr/local/bin/perl5.00404
vladimir: 62:]

IF you did the oopsie I have done - you installed the new version
into say /usr/ without actually dealing with the fact
that you have an instance of the whole installation in /usr/local

hence rather than having 'links' playing the game of

/usr/bin/perl  == /usr/local/bin/perl

one of them is STILL the old version...

The fun is that while your 'path' may be set up to call the
'older version' at the command line - eg:

/usr/local/bin:/usr/bin

if your scripts call out

#!/usr/bin/perl

then they will be calling the 'newer' version...

it is best to go back and sort out which is the real player
that you installed

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Page embedded script

2002-07-25 Thread Lon Lentz


  I have inherited a project based on more scripting languages than I knew
existed, and I have very little Perl experience. I have a CGI script that is
calling an HTML template (to display). The html template has the following
script embedded in it. It doesn't appear to behave like Perl. I am trying to
add a simple if statement to another similar section but it's not
cooperating. Any help would be much appreciated.


{{IF domains}}
{{LOOP domains}}
  {{IF tld eq COM}}
  tr
  td class=sansb{{term}}/b/td
  {{/IF}}
  {{IF avail}}
  td class=sans valign=middle align=center
input type=checkbox name=domain value={{domain}}
  /td
  {{ELSE}}
  td class=sans bgcolor=E0E0E0
bfont color=FFSOLD!/font/b
  /td
  {{/IF}}
{{IF tld eq ORG}}
/tr
{{/IF}}
{{/LOOP}}
{{/IF}}


__
Lon Lentz
Applications Developer
EXImpact.com



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Upgrade to Perl

2002-07-25 Thread Bob Showalter

 -Original Message-
 From: Soheil Shaghaghi [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 1:53 AM
 To: [EMAIL PROTECTED]
 Subject: Upgrade to Perl
 
 
 Hi List,
 I have been running Perl 5.6.0 for a while now, and today I decide to
 upgrade to 5.6.1!
 Everything works very good, but after the upgrade I can't see 
 any changes to
 the system!
 I installed the upgrade in the same directory as Perl 5.6.0
 Now, here are my problems, if anyone can please help me:
 1. Perl still reports to be Version 5.6.0
 
 2. I see so many Perl executables, and don't know which one 
 the latest one
 is, or what I should do at this point to get the server to 
 report Perl to be
 5.6.1
 
 /usr/bin/perlCreated: 12/25/2000
 /usr/bin/perl5  Created: 11/20/2000
 /usr/bin/perl5.00503Created: 11/20/2000
 /usr/bin/perl5.6.0Created: 12/25/2000
 
 /usr/local/bin/perlCreated: 07/24/2002
 /usr/local/bin/perl5.6.0 Created: 12/22/2000
 /usr/local/bin/perl5.6.1 Created: 07/24/2002
 
 3. Is there a configuration somewhere I need to change?
 
 
 When I run perl -V, here is what I get:
 perl -V
 Summary of my perl5 (revision 5.0 version 6 subversion 0) 
 configuration:
   Platform:
 osname=freebsd, osvers=4.2-release, archname=i386-freebsd
 uname='freebsd www.domain.com 4.2-release freebsd 
 4.2-release #0: mon
 nov 20 13:02:55 gmt 2000 
 [EMAIL PROTECTED]:usrsrcsyscompilegeneric i386
 '
 config_args=''
 hint=recommended, useposix=true, d_sigaction=define
 usethreads=undef use5005threads=undef useithreads=undef
 usemultiplicity=undef
 useperlio=undef d_sfio=undef uselargefiles=define
 use64bitint=undef use64bitall=undef uselongdouble=undef 
 usesocks=undef
   Compiler:
 cc='gcc', optimize='-O', gccversion=2.95.2 19991024 (release)
 cppflags='-fno-strict-aliasing -I/usr/local/include'
 ccflags ='-fno-strict-aliasing -I/usr/local/include'
 stdchar='char', d_stdstdio=undef, usevfork=true
 intsize=4, longsize=4, ptrsize=4, doublesize=8
 d_longlong=define, longlongsize=8, d_longdbl=define, 
 longdblsize=12
 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
 lseeksize=8
 alignbytes=4, usemymalloc=n, prototype=define
   Linker and Libraries:
 ld='gcc', ldflags ='-Wl,-E  -L/usr/local/lib'
 libpth=/usr/lib /usr/local/lib
 libs=-lm -lc -lcrypt
 libc=, so=so, useshrplib=false, libperl=libperl.a
   Dynamic Linking:
 dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
 cccdlflags='-DPIC -fpic', lddlflags='-shared  -L/usr/local/lib'
 
 
 Characteristics of this binary (from libperl):
   Compile-time options: USE_LARGE_FILES
   Built under freebsd
   Compiled at Dec 25 2000 02:07:40
   @INC:
 /usr/lib/perl5/5.6.0/i386-freebsd
 /usr/lib/perl5/5.6.0
 /usr/lib/perl5/site_perl/5.6.0/i386-freebsd
 /usr/lib/perl5/site_perl/5.6.0
 /usr/lib/perl5/site_perl

Since you're on FreeBSD, here's the correct way to do it:

FreeBSD comes with Perl 5.005 in the base installation. To
install and use Perl 5.6.1, you (as root):

   # cd /usr/ports/lang/perl5
   # make install clean
   # use.perl port

(Be sure to update your ports collection if you haven't done
so recently.)

The use.perl script is provided to switch between the system
5.005 version and the port 5.6.1 version. It adjusts the link
in /usr/bin/perl to point to the correct version and also makes
changes in your /etc/make.conf, so future ports you build for
perl modules will install them to the correct location.

If you already installed 5.6.1 using the port, just type
use.perl port as root and you're all set. If not, I would
suggest you go ahead and reinstall via the port and then do
the use.perl port. That will make everything just work.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Partially success

2002-07-25 Thread Octavian Rasnita

Hello all,

Thank you for your help regarding that script for downloading then deleting
the downloaded file.

I've made the script and after downloading the file, it deletes it from the
server.
This works fine.

The problem is that the file is not deleted if the visitor cancels the file
download.

If the download is interrupted, the script is also interrupted I think, and
it can't delete the file.

Do you have any idea what could I do to delete the file if the download is
cancelled?

And now another little problem with the script.
The problem is somewhere between Internet Explorer and the script, and I
think that modifying the script I can solve it.

I run the script with the ?fileName query string to download the fileName
file.
The download finishes fine, and the script deletes the fileName file from
the server.

Then in the same Internet Explorer window, I run again the script with the
anotherFileName query string, for downloading another file.

internet Explorer prompts me to download the second file, I choose save
but it doesn't appear that window for choosing a file name.
Instead, it appears an error message telling me that the server localhost
cannot be contacted to download the file script_name.pl.

If I close Internet Explorer, and open another window, it works fine without
any problem.

I've tried all the things from this message using Apache 2.0.36 in Windows,
and Apache 1.3 in Linux, with the same results.

Please advise me how can I solve these 2 problems, especially the first one.

Thank you very much.

Here is the script:

#!/perl/bin/perl
#!/usr/bin/perl

$| = 1;

my $filename = $ENV{'QUERY_STRING'};
my $docroot = $ENV{'DOCUMENT_ROOT'};
my $file = $docroot/shopping/$filename;

print eof;
Content-type: application/zip
Content-Disposition: attachment; filename=$filename

eof

open (FH, $file);
binmode(FH);
binmode(STDOUT);

until (eof FH) {
read (FH, my $buf, 1024);
print $buf;
}
close FH;

unlink $file;


Teddy Center: http://teddy.fcc.ro/
Mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: sending bulk emails in perl/sendmail

2002-07-25 Thread zentara

On Thu, 25 Jul 2002 06:36:40 -0700 (PDT), [EMAIL PROTECTED] (Shao-Ju
Chao) wrote:

I wonder if there is a safer and better way sending email messages to a group of 
people.
For example, there is a text file that has all the recipient email addresses: 

You can specify your list, 1 email per line in bulkmaillist
#
#!/usr/bin/perl
use strict;
use warnings;
use Mail::Bulkmail;

my $email = '[EMAIL PROTECTED]';

#eval {
my $bulk = Mail::Bulkmail-new(
#   LIST  = ['[EMAIL PROTECTED]','[EMAIL PROTECTED]'],
LIST  = ./bulkmaillist,
GOOD = \good,
BAD = \bad,
From= $email,
Subject = 'Test of Bulkmail',
Message = Hi there, NAME.  Mail::Bulkmail seems to work
fine!,
X-test = Bulkmail test!
 ) or die Mail::Bulkmail-error();
 $bulk-bulkmail;

#};
sub good {print Mail successfully sent to (@_)}
sub bad {print Mail did not send to (@_)}

print ...error: $@ if $@;

##


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




malformed header from script???

2002-07-25 Thread webster

I'm getting this error:

malformed header from script.  Bad header=EHLO stanislaw

if I turn off use strict, I get the error

Premature end of script headers


my code is posted below, and it runs all the way through because it sends the 
email - and the email has 

The error codes dont have line numbers with them, so Im not sure where to 
look.   Any help??

here is my code. Its purpose is to take information from a form and email it 
to someone...try not to laugh at it
__

#!/usr/bin/perl -w
use strict;
use CGI;
use XML::Twig;
use Date::Calc qw( System_Clock );
use SendMail;



#---path stuff - you need to set these to values appropriate to your system
my $pathToAssignNum = /usr/local/httpd/htdocs/summer/xml/assignNum.txt;
my $pathToReport_xml = /usr/local/httpd/htdocs/summer/xml/report.xml;
my $genWorkReport_URL = http://somehostname.edu/cgi-bin/genWorkReport.cgi;;



my $query = new CGI;

#---setup SendMail
my $sm = new SendMail();
$sm-setDebug($sm-ON);
$sm-To( Jeremy Webster jwebster\@olemiss.edu );
$sm-Subject(Work Order);

my $email = $query-param('email');
$sm-From($email);
$sm-ReplyTo($email);


my $assignName  = $query-param('assName'); #pull in some values from the a/v 
form
my $description = $query-param('description');
#convert newline chars to br so it displays nice on webpage
my $eol = chr(13).chr(10);  #CR/LF
if($description =~ m/$eol/){
$description=~s/$eol/br \//g;
}

my $commissioner = $query-param('commissioners');
if ($commissioner eq Other) {$commissioner = $query-param('otherComish');}
my $acctExec= $query-param('AcctExec');

my $ddlMonth= $query-param('ddlMonth');
my $ddlDay  = $query-param('ddlDay');
my $ddlYear = $query-param('ddlYear');
my $ddlDeadline = $ddlMonth. .$ddlDay., .$ddlYear;

my $aeMonth = $query-param('aeMonth');
my $aeDay   = $query-param('aeDay');
my $aeYear  = $query-param('aeYear');
my $aeDeadline  = $aeMonth. .$aeDay., .$aeYear;

my $ihMonth = $query-param('ihMonth');
my $ihDay   = $query-param('ihDay');
my $ihYear  = $query-param('ihYear');
my $ihDeadline  = $ihMonth. .$ihDay., .$ihYear;

my $dimensions  = $query-param('dim');
my $pageCount   = $query-param('PageCount');
my $quantity= $query-param('Quantity');
my $sides   = $query-param('sides');
my $colorSpecs  = $query-param('colorSpec');
my $dicut   = $query-param('Dicut');
my $binding = $query-param('BindingSelect');
my $art = $query-param('artSelect');
my $laminate= $query-param('LaminSelect');

my $paper   = $query-param('Paper');
my $otherPaper  = $query-param('otherPaper');
if($paper eq Other) {$paper = $otherPaper;}

my $envelopes   = $query-param('Envelopes');

my $special = ;
$special= $query-param('special');
if($special =~ m/$eol/){
$special=~s/$eol/br \//g;
}

my $artist  = $query-param('artFrom');
my $newGuy  = $query-param('otherName');

my @people = $query-param('per');
my $seeList =;
my $person =;;
foreach $person(@people){
if($person eq otherPer){
$seeList .= $newGuy;
}else{
$seeList .= $person., ;
}
}


my ($year,$month, $day, $hour, $min, $sec, $doy, $dst);
($year, $month, $day, $hour, $min, $sec, $doy, $dst) = System_Clock();
my $date = $month./.$day./.$year;
my $time = $hour.:.$min.:.$sec;



#check to make sure fields are filled in properly
unless($email){
print $query-header;
print Please fill in the Email field and try again;
die No email entered;
}

unless($assignName){
print $query-header;
print Please fill in the Assignment Name field and try again;
die No name entered;
}

unless($description){
print $query-header;
print Please fill in the description field and try again;
die No description entered;
}

unless($acctExec){
print $query-header;
print Please fill in a value for the Account Executive and try again;
die No account executive entered;
}

unless($dimensions){
print $query-header;
print Please fill in values for the dimensions of the project and try 
again;
die No dimensions entered;
}

unless($dicut){
print $query-header;
print you forgot to choose a value for Dicut.  Please return to form and 
choose yes or no;
die No dicut entered;
}

unless($pageCount){
print $query-header;
print you forgot to specify the Page Count. Please return to form and try 
again;
die No page Count entered;
}

unless($quantity){
print $query-header;
print you forgot to specify the quantity.  Please return to form try again;
die No quantity entered;
}

unless($sides){
print $query-header;
print you forgot to specify the number of sides.  Please return to form try 
again;
die No quantity entered;
}

unless($paper){
print 

Re: malformed header from script???

2002-07-25 Thread perl-dvd

Webster,
Looks like your content-type is not being printed soon enough.  You should 
consider placing it
at the very top of your script unless you expect print some other kind of header (like 
a Location).
print Content-Type: text/html\n\n;

Regards,
David


- Original Message -
From: webster [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 25, 2002 1:10 PM
Subject: malformed header from script???


I'm getting this error:

malformed header from script.  Bad header=EHLO stanislaw

if I turn off use strict, I get the error

Premature end of script headers


my code is posted below, and it runs all the way through because it sends the
email - and the email has

The error codes dont have line numbers with them, so Im not sure where to
look.   Any help??

here is my code. Its purpose is to take information from a form and email it
to someone...try not to laugh at it
__

#!/usr/bin/perl -w
use strict;
use CGI;
use XML::Twig;
use Date::Calc qw( System_Clock );
use SendMail;



#---path stuff - you need to set these to values appropriate to your system
my $pathToAssignNum = /usr/local/httpd/htdocs/summer/xml/assignNum.txt;
my $pathToReport_xml = /usr/local/httpd/htdocs/summer/xml/report.xml;
my $genWorkReport_URL = http://somehostname.edu/cgi-bin/genWorkReport.cgi;;



my $query = new CGI;

#---setup SendMail
my $sm = new SendMail();
$sm-setDebug($sm-ON);
$sm-To( Jeremy Webster jwebster\@olemiss.edu );
$sm-Subject(Work Order);

my $email = $query-param('email');
$sm-From($email);
$sm-ReplyTo($email);


my $assignName  = $query-param('assName'); #pull in some values from the a/v
form
my $description = $query-param('description');
#convert newline chars to br so it displays nice on webpage
my $eol = chr(13).chr(10);  #CR/LF
if($description =~ m/$eol/){
$description=~s/$eol/br \//g;
}

my $commissioner = $query-param('commissioners');
if ($commissioner eq Other) {$commissioner = $query-param('otherComish');}
my $acctExec = $query-param('AcctExec');

my $ddlMonth = $query-param('ddlMonth');
my $ddlDay = $query-param('ddlDay');
my $ddlYear = $query-param('ddlYear');
my $ddlDeadline = $ddlMonth. .$ddlDay., .$ddlYear;

my $aeMonth = $query-param('aeMonth');
my $aeDay = $query-param('aeDay');
my $aeYear = $query-param('aeYear');
my $aeDeadline  = $aeMonth. .$aeDay., .$aeYear;

my $ihMonth = $query-param('ihMonth');
my $ihDay = $query-param('ihDay');
my $ihYear = $query-param('ihYear');
my $ihDeadline  = $ihMonth. .$ihDay., .$ihYear;

my $dimensions  = $query-param('dim');
my $pageCount = $query-param('PageCount');
my $quantity = $query-param('Quantity');
my $sides = $query-param('sides');
my $colorSpecs = $query-param('colorSpec');
my $dicut = $query-param('Dicut');
my $binding = $query-param('BindingSelect');
my $art = $query-param('artSelect');
my $laminate = $query-param('LaminSelect');

my $paper = $query-param('Paper');
my $otherPaper = $query-param('otherPaper');
if($paper eq Other) {$paper = $otherPaper;}

my $envelopes = $query-param('Envelopes');

my $special = ;
$special = $query-param('special');
if($special =~ m/$eol/){
$special=~s/$eol/br \//g;
}

my $artist = $query-param('artFrom');
my $newGuy = $query-param('otherName');

my @people = $query-param('per');
my $seeList =;
my $person =;;
foreach $person(@people){
if($person eq otherPer){
$seeList .= $newGuy;
}else{
$seeList .= $person., ;
}
}


my ($year,$month, $day, $hour, $min, $sec, $doy, $dst);
($year, $month, $day, $hour, $min, $sec, $doy, $dst) = System_Clock();
my $date = $month./.$day./.$year;
my $time = $hour.:.$min.:.$sec;



#check to make sure fields are filled in properly
unless($email){
print $query-header;
print Please fill in the Email field and try again;
die No email entered;
}

unless($assignName){
print $query-header;
print Please fill in the Assignment Name field and try again;
die No name entered;
}

unless($description){
print $query-header;
print Please fill in the description field and try again;
die No description entered;
}

unless($acctExec){
print $query-header;
print Please fill in a value for the Account Executive and try again;
die No account executive entered;
}

unless($dimensions){
print $query-header;
print Please fill in values for the dimensions of the project and try
again;
die No dimensions entered;
}

unless($dicut){
print $query-header;
print you forgot to choose a value for Dicut.  Please return to form and
choose yes or no;
die No dicut entered;
}

unless($pageCount){
print $query-header;
print you forgot to specify the Page Count. Please return to form and try
again;
die No page Count entered;
}

unless($quantity){
print $query-header;
print you forgot to specify the quantity.  Please return to form try again;
die No quantity entered;
}

unless($sides){
print $query-header;
print you forgot to specify the number of sides.  Please return to form try
again;
die No quantity entered;
}

unless($paper){
print $query-header;
print you 

Re: another way to show results ?

2002-07-25 Thread Simon K. Chan

Hi Ali,

I hope I understood your question correctly.

A user fills out a form, and you want the results to be displayed on the same page 
(URL) ?

If that's the case, read up on subroutines.  Subroutines are kind of like bins that 
hold perl
code.

Here's some pseudocode:

if (some_condition){

   run_subroutine_1

} else {

   run_subroutine_2

}

sub run_subroutine_1 {

# do something

}

sub run_subroutine_2 {

# do something

}

run_subroutine_1 could display a form, for example.
And run_subroutine_2 could process those results.

All done on the same page.

HTH,
simon

--- alpha [EMAIL PROTECTED] wrote:
 hi all 
 i am new in perl and want to know can a perl cgi , return results in other way ? 
 i know cgi script return result in new webpage . but i dont want a new  page open . 
 i want it return result in same page and in row i call it . 
 like a counter or other web tools 
 
 thank u in advance
 ali
 
 


=
#

Warmest Regards,
Simon K. Chan - [EMAIL PROTECTED]

Great spirits have always encountered violent opposition from mediocre minds.  - 
Albert Einstein

__
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: malformed header from script???

2002-07-25 Thread webster

hmmm, ok, I moved the Content-Type line up in the program, and that got rid of 
the error.  Now, however, it dumps the raw text of the email - 

220 stanislaw.blah.blah.edu ESMTP Sendmail 8.12.2/8.12.2/SuSE Linux 0.6; Thu, 
25 Jul 2002 14:38:05 -0500 EHLO stanislaw 250-stanislaw.blah.blah.edu Hello 
localhost [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 
250-PIPELINING 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-DELIVERBY 250 HELP 
MAIL FROM: 250 2.1.0 ... Sender ok RCPT TO: 250 2.1.5 ... Recipient ok DATA 
354 E... 

- to a the browser window.  This, of course, isnt desired.  What's going on?  
I guess I dont really understand what this Content-Type line is doing.  If I 
take it out all together, my error comes back.  I thought it was just a line 
to tell whatever viewing program recieves the text how to process it.  Is 
there a webpage with a good explanation of what's going on?

Also, i should say that after i send the email i want to create a confirmation 
page that will be sent to the browser.



On Thursday 25 July 2002 14:12, [EMAIL PROTECTED] wrote:
 Webster,
 Looks like your content-type is not being printed soon enough.  You
 should consider placing it at the very top of your script unless you expect
 print some other kind of header (like a Location). print Content-Type:
 text/html\n\n;

 Regards,
 David


 - Original Message -
 From: webster [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, July 25, 2002 1:10 PM
 Subject: malformed header from script???


 I'm getting this error:

 malformed header from script.  Bad header=EHLO stanislaw

 if I turn off use strict, I get the error

 Premature end of script headers


 my code is posted below, and it runs all the way through because it sends
 the email - and the email has

 The error codes dont have line numbers with them, so Im not sure where to
 look.   Any help??

 here is my code. Its purpose is to take information from a form and email
 it to someone...try not to laugh at it
 __

 #!/usr/bin/perl -w
 use strict;
 use CGI;
 use XML::Twig;
 use Date::Calc qw( System_Clock );
 use SendMail;



 #---path stuff - you need to set these to values appropriate to your system
 my $pathToAssignNum = /usr/local/httpd/htdocs/summer/xml/assignNum.txt;
 my $pathToReport_xml = /usr/local/httpd/htdocs/summer/xml/report.xml;
 my $genWorkReport_URL =
 http://somehostname.edu/cgi-bin/genWorkReport.cgi;;



 my $query = new CGI;

 #---setup SendMail
 my $sm = new SendMail();
 $sm-setDebug($sm-ON);
 $sm-To( Jeremy Webster jwebster\@olemiss.edu );
 $sm-Subject(Work Order);

 my $email = $query-param('email');
 $sm-From($email);
 $sm-ReplyTo($email);


 my $assignName  = $query-param('assName'); #pull in some values from the
 a/v form
 my $description = $query-param('description');
 #convert newline chars to br so it displays nice on webpage
 my $eol = chr(13).chr(10);  #CR/LF
 if($description =~ m/$eol/){
 $description=~s/$eol/br \//g;
 }

 my $commissioner = $query-param('commissioners');
 if ($commissioner eq Other) {$commissioner =
 $query-param('otherComish');} my $acctExec = $query-param('AcctExec');

 my $ddlMonth = $query-param('ddlMonth');
 my $ddlDay = $query-param('ddlDay');
 my $ddlYear = $query-param('ddlYear');
 my $ddlDeadline = $ddlMonth. .$ddlDay., .$ddlYear;

 my $aeMonth = $query-param('aeMonth');
 my $aeDay = $query-param('aeDay');
 my $aeYear = $query-param('aeYear');
 my $aeDeadline  = $aeMonth. .$aeDay., .$aeYear;

 my $ihMonth = $query-param('ihMonth');
 my $ihDay = $query-param('ihDay');
 my $ihYear = $query-param('ihYear');
 my $ihDeadline  = $ihMonth. .$ihDay., .$ihYear;

 my $dimensions  = $query-param('dim');
 my $pageCount = $query-param('PageCount');
 my $quantity = $query-param('Quantity');
 my $sides = $query-param('sides');
 my $colorSpecs = $query-param('colorSpec');
 my $dicut = $query-param('Dicut');
 my $binding = $query-param('BindingSelect');
 my $art = $query-param('artSelect');
 my $laminate = $query-param('LaminSelect');

 my $paper = $query-param('Paper');
 my $otherPaper = $query-param('otherPaper');
 if($paper eq Other) {$paper = $otherPaper;}

 my $envelopes = $query-param('Envelopes');

 my $special = ;
 $special = $query-param('special');
 if($special =~ m/$eol/){
 $special=~s/$eol/br \//g;
 }

 my $artist = $query-param('artFrom');
 my $newGuy = $query-param('otherName');

 my @people = $query-param('per');
 my $seeList =;
 my $person =;;
 foreach $person(@people){
 if($person eq otherPer){
 $seeList .= $newGuy;
 }else{
 $seeList .= $person., ;
 }
 }


 my ($year,$month, $day, $hour, $min, $sec, $doy, $dst);
 ($year, $month, $day, $hour, $min, $sec, $doy, $dst) = System_Clock();
 my $date = $month./.$day./.$year;
 my $time = $hour.:.$min.:.$sec;



 #check to make sure fields are filled in properly
 unless($email){
 print $query-header;
 print Please fill in the Email field and try again;
 die No email entered;
 }

 

RE: malformed header from script???

2002-07-25 Thread Bob Showalter



 -Original Message-
 From: webster [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 4:02 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: malformed header from script???
 
 
 hmmm, ok, I moved the Content-Type line up in the program, 
 and that got rid of 
 the error.  Now, however, it dumps the raw text of the email - 
 
 220 stanislaw.blah.blah.edu ESMTP Sendmail 8.12.2/8.12.2/SuSE 
 Linux 0.6; Thu, 
 25 Jul 2002 14:38:05 -0500 EHLO stanislaw 
 250-stanislaw.blah.blah.edu Hello 
 localhost [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 
 250-PIPELINING 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 
 250-DELIVERBY 250 HELP 
 MAIL FROM: 250 2.1.0 ... Sender ok RCPT TO: 250 2.1.5 ... 
 Recipient ok DATA 
 354 E... 
 
 - to a the browser window.  This, of course, isnt desired.  
 What's going on?  

That's not the email, it's the conversation with sendmail.

Perhaps this line is doing it:

   $sm-setDebug($sm-ON);

 I guess I dont really understand what this Content-Type line 
 is doing.  If I 
 take it out all together, my error comes back.  I thought it 
 was just a line 
 to tell whatever viewing program recieves the text how to 
 process it.  Is 
 there a webpage with a good explanation of what's going on?

It's required by the HTTP protocol. RFC 2616.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: malformed header from script???

2002-07-25 Thread Jake

That was it...I shoulda picked it up myself, but im a bit fuzzyheaded today.

thanks a million


 Perhaps this line is doing it:

$sm-setDebug($sm-ON);



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Print entire single column of csv-file using split

2002-07-25 Thread Richard Krause

Hello

I'd like to print the country-column of the follwing csv-file:

eastwood;clint;usa
kinski;klaus;germany
wayne;john;usa

This is the script I wrote:

#!c:/perl/bin/perl -w
use diagnostics;
use strict;

open(ADDRESSLIST,addresslist.csv);
my @list = ADDRESSLIST;

close (ADDRESSLIST);

foreach (@list) {
   @list = split (/;/);
  }

foreach (@list) {
   print \n.$_.\n;}

When I execute the script it's printing only the value of the second column
in the first row (clint) instead of something like:

usa
germany
usa

What am I doing wrong? I've been working for 16hrs. on this now and read
that many threads dealing with split and the camel book all over again,
but somehow I just don't get it ...
Thanks for any hints!
Richard



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




del files

2002-07-25 Thread Javeed SAR




I want to  delete files.

I am not able to delete , what is the wrong thing I am doing here.
I am able to see the file in privates


I am getting following output:


0 deleted
Attempting to delete M:\jav_test\train\k k k.mkelem.mkelem



#!c:\perl\bin\perl 
privates =`cleartool lsprivate  -tag jav_test -other`;
#print privates;
#print Enter a  pattern:;
#my $pattern =;
#chomp $pattern;
foreach (privates)
{
print \nAttempting to delete $_\n;
 $delo=unlink private;  
print \n $delo deleted;
}



RE: del files

2002-07-25 Thread Timothy Johnson

 
Your script states Attempting to delete $_, but when you actually go to
delete it, you have unlink @private, which translates to unlink a file
whose name is the number of elements in @private.  I think you want to
change that line to unlink $_, followed by $_ deleted.

-Original Message-
From: Javeed SAR
To: [EMAIL PROTECTED]
Sent: 7/24/02 11:46 PM
Subject: del files




I want to  delete files.

I am not able to delete , what is the wrong thing I am doing here.
I am able to see the file in @privates


I am getting following output:


0 deleted
Attempting to delete M:\jav_test\train\k k k.mkelem.mkelem



#!c:\perl\bin\perl 
@privates =`cleartool lsprivate  -tag jav_test -other`;
#print @privates;
#print Enter a  pattern:;
#my $pattern =;
#chomp $pattern;
foreach (@privates)
{
print \nAttempting to delete $_\n;
 $delo=unlink @private;  
print \n $delo deleted;
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: del files

2002-07-25 Thread Sudarshan Raghavan

On Thu, 25 Jul 2002, Timothy Johnson wrote:

  
 Your script states Attempting to delete $_, but when you actually go to
 delete it, you have unlink @private, which translates to unlink a file
 whose name is the number of elements in @private.

No, unlink takes a list of files to delete and returns the number of files
successfully deleted. His statement is just fine.

Javeed,

Not sure how the output of cleartool lsprivate looks like, the reason for 
unlink returning a 0 maybe the presence of newlines in the output. If so
you will have to chomp them off.
 

  I think you want to
 change that line to unlink $_, followed by $_ deleted.
 
 -Original Message-
 From: Javeed SAR
 To: [EMAIL PROTECTED]
 Sent: 7/24/02 11:46 PM
 Subject: del files
 
 
 
 
 I want to  delete files.
 
 I am not able to delete , what is the wrong thing I am doing here.
 I am able to see the file in @privates
 
 
 I am getting following output:
 
 
 0 deleted
 Attempting to delete M:\jav_test\train\k k k.mkelem.mkelem
 
 
 
 #!c:\perl\bin\perl 
 @privates =`cleartool lsprivate  -tag jav_test -other`;
 #print @privates;
 #print Enter a  pattern:;
 #my $pattern =;
 #chomp $pattern;
 foreach (@privates)
 {
 print \nAttempting to delete $_\n;
  $delo=unlink @private;  
 print \n $delo deleted;
 }
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Percent % completed?

2002-07-25 Thread David Samuelsson (PAC)

Hello again out there.

Is there anyway to get perl to do a counter so it counts in the command shell how many 
% that is done? I have a script that runs a check on a database, its just 1 command 
and it spits out some information. Can i parse this information from when its printing 
out this information, and insted capture some variabels and make it count like 0 % 
ready, 25 % ready or similar? its hard since its just 1 command and that spits out all 
the infomation if the database is at good health, but the check can take a really long 
time for some databses and a very short time for not so big databases.  But the out 
put is always the same for the databses unless there is an error in them.

Processing key file: vob_db.k01(1), total of 444 nodes


--

Processing key file: vob_db.k02(2), total of 840 nodes


--

Processing key file: vob_db.k03(5), total of 1 node


--

Processing key file: vob_db.k04(6), total of 1 node


--

Processing data file: vob_db.d01(0), total of 37651 records


--

Processing data file: vob_db.d02(3), total of 20628 records


--

Processing data file: vob_db.d03(4), total of 1 record


Database consistency check completed

0 errors were encountered in 0 records/nodes

This is the output from the command.  Anyone got a clue on how to make it count for 
each line or something?

Thanks for any info or similar scripting techniqes.

//Dave

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: del files

2002-07-25 Thread Felix Geerinckx

on Thu, 25 Jul 2002 06:58:03 GMT, Javeed Sar wrote:

If you had used strict, Perl would have noticed the problem.

 #!c:\perl\bin\perl 
 @privates =`cleartool lsprivate  -tag jav_test -other`;
 #print @privates;
 #print Enter a  pattern:;
 #my $pattern =;
 #chomp $pattern;
 foreach (@privates)
 {
 print \nAttempting to delete $_\n;
  $delo=unlink @private; 
   ^^^

Did you mean to write '@privates'? But then your program logic isn't 
right. Perhaps you meant '$_', which tries to delete each file from 
'@privates' in turn?
  
 print \n $delo deleted;
 }

-- 
felix

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: del files

2002-07-25 Thread Connie Chan

for (@privates)
{   chomp; 
print Attemp to del $_\n;
unlink ($_) ? 
{print $_ unable to del } :
{print $_ deleted };
}

I didn't ever tried unlink @array like method, 
perhaps the problem is there.

and you got 0 delete is the fail signal send
back from the unlink action. you will got 1 deleted
if the unlink is success.

Rgds,
Connie


- Original Message - 
From: Javeed SAR [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 25, 2002 2:46 PM
Subject: del files


 
 
 
 I want to  delete files.
 
 I am not able to delete , what is the wrong thing I am doing here.
 I am able to see the file in @privates
 
 
 I am getting following output:
 
 
 0 deleted
 Attempting to delete M:\jav_test\train\k k k.mkelem.mkelem
 
 
 
 #!c:\perl\bin\perl 
 @privates =`cleartool lsprivate  -tag jav_test -other`;
 #print @privates;
 #print Enter a  pattern:;
 #my $pattern =;
 #chomp $pattern;
 foreach (@privates)
 {
 print \nAttempting to delete $_\n;
  $delo=unlink @private;  
 print \n $delo deleted;
 }
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: del files

2002-07-25 Thread Connie Chan




 What about if there r space in file names?

There is no problem for unlink to handle filename with spaceS.
The issue is on how you get the file list to the array.

Rgds, 
Connie





 
 
 -Original Message-
 From: Connie Chan [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 2:07 PM
 To: Javeed SAR; [EMAIL PROTECTED]
 Subject: Re: del files
 
 for (@privates)
 {   chomp;
 print Attemp to del $_\n;
 unlink ($_) ?
 {print $_ unable to del } :
 {print $_ deleted };
 }
 
 I didn't ever tried unlink @array like method,
 perhaps the problem is there.
 
 and you got 0 delete is the fail signal send
 back from the unlink action. you will got 1 deleted
 if the unlink is success.
 
 Rgds,
 Connie
 
 
 - Original Message -
 From: Javeed SAR [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, July 25, 2002 2:46 PM
 Subject: del files
 
 
 
 
 
  I want to  delete files.
 
  I am not able to delete , what is the wrong thing I am doing here.
  I am able to see the file in @privates
 
 
  I am getting following output:
 
 
  0 deleted
  Attempting to delete M:\jav_test\train\k k k.mkelem.mkelem
 
 
 
  #!c:\perl\bin\perl
  @privates =`cleartool lsprivate  -tag jav_test -other`;
  #print @privates;
  #print Enter a  pattern:;
  #my $pattern =;
  #chomp $pattern;
  foreach (@privates)
  {
  print \nAttempting to delete $_\n;
   $delo=unlink @private; 
  print \n $delo deleted;
  }
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




function for finding the index of an element in an array?

2002-07-25 Thread Daniel David

Hi,
I couldn't seem to find a built-in function for finding the index
of an element in an array...so I wrote this one:



#  position_of returns the position of a string in an array of strings,
#  and -1 if the string is not a member of the array.

sub position_of {
   my ($x,@y) = @_;
   foreach $z (0..$#y) {
  if (@y[$z] eq $x) {
 return ($z);
  }
   }

   return -1;
}
--

it works but somehow i feel there's a built in function for this

thanks.

_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Interaction whith the OS: System command or better ?

2002-07-25 Thread Jean Berthold

Hello everybody,

This is my first post on this list ...
Currently I try to learn Perl language ...

I want to rewrite a Korn Shell script wich is make a full system backup,

by using the system tools available under Solaris 8: fssnap/ufsdump

The Korn Shell script does the following tasks:

1. The snapshot path is stored in the SnapRoot variable:
  SnapRoot=$(fssnap -F ufs -o backing-store=/home/SNAP /)
   Value for SnapRoot is now, for example: /dev/fssnap/3
   Return value for fssnap command is tested by :
  SnapRoot=$(fssnap -F ufs -o backing-store=/home/SNAP /)
  if (( $? != 0 ))
  then
print Erreur dans la creation du snapshot pour: /  $LOGFILE
cat $LOGFILE | mailx -s $SubjectAlarm $MAILDEST
exit 1
  fi
2. Dump is made directly on a tape:
   ufsdump 0f /dev/rmt/0n  $SnapRoot
   Return value for ufsdump is tested too :
   ufsdump 0f /dev/rmt/0n  $SnapRoot
   if (( $? != 0 ))
   ...
   ...

My perl script try to do the same things ... but :

I need to do that, (like for my shell-script) to get the value of the
path
of my snapshot in the SnapRoot variable:
my $SnapRoot =`fssnap -F ufs -o backing-store=/home/SNAP /`;

If I try to use the perl system function:
my $SnapRoot=system(fssnap -F ufs -o backing-store=/home/SNAP /);
SnapRoot variable will be filled by the return status from system( ).

I need to get return status for the fssnap command AND its value
(in my example: /dev/fssnap/3 ).

if ( ( system(fssnap ...) )  )
{

}
For testing the return value for this command that's  ok but I would
like
to store the backup path in the SnapRoot variable  ...

How to do that ?

If we need instruction like:
my $SnapRoot =`fssnap -F ufs -o backing-store=/home/SNAP /`;
(using backstits) I don't know where is the benefice to use perl instead

of shell scripts for theses tasks...

Thank for your help and have a nice day !

--


Jean Berthold
EOS - energie ouest suisse
Chemin de Mornex 10 , CP 570
CH-1001 Lausanne , Switzerland
Tel. : +41 (0)21 341 24 58
Fax  : +41 (0)21 341 20 49
E-Mail : [EMAIL PROTECTED]





Weekly list FAQ posting

2002-07-25 Thread casey

NAME
beginners-faq - FAQ for the beginners mailing list

1 -  Administriva
  1.1 - I'm not subscribed - how do I subscribe?

Send mail to [EMAIL PROTECTED]

You can also specify your subscription email address by sending email to
(assuming [EMAIL PROTECTED] is your email address):

[EMAIL PROTECTED].

  1.2 -  How do I unsubscribe?

Now, why would you want to do that? Send mail to
[EMAIL PROTECTED], and wait for a response. Once you
reply to the response, you'll be unsubscribed. If that doesn't work,
find the email address which you are subscribed from and send an email
like the following (let's assume your email is [EMAIL PROTECTED]):

[EMAIL PROTECTED]

  1.3 - There is too much traffic on this list. Is there a digest?

Yes. To subscribe to the digest version of this list send an email to:

[EMAIL PROTECTED]

To unsubscribe from the digest, send an email to:

[EMAIL PROTECTED]

This is a high traffic list (100+ messages per day), so please subscribe
in the way which is best for you.

  1.4 - Is there an archive on the web?

Yes, there is. It is located at:

http://archive.develooper.com/beginners%40perl.org/

  1.5 - How can I get this FAQ?

This document will be emailed to the list once a week, and will be
available online in the archives, and at http://learn.perl.org/

  1.6 - I don't see something in the FAQ, how can I make a suggestion?

Send an email to [EMAIL PROTECTED] with your suggestion.

  1.7 - Is there a supporting website for this list?

Yes, there is. It is located at:

http://beginners.perl.org/

  1.8 - Who owns this list?  Who do I complain to?

Casey West owns the beginners list. You can contact him at
[EMAIL PROTECTED]

  1.9 - Who currently maintains the FAQ?

Kevin Meltzer, who can be reached at the email address (for FAQ
suggestions only) in question 1.6

  1.10 - Who will maintain peace and flow on the list?

Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large,
yet padded, clue-sticks to maintain peace and order on the list. If you
are privately emailed by one of these folks for flaming, being
off-topic, etc... please listen to what they say. If you see a message
sent to the list by one of these people saying that a thread is closed,
do not continue to post to the list on that thread! If you do, you will
not only meet face to face with a XQJ-37 nuclear powered pansexual
roto-plooker, but you may also be taken off of the list. These people
simply want to make sure the list stays topical, and above-all, useful
to Perl beginners.

  1.11 - When was this FAQ last updated?

Sept 07, 2001

2 -  Questions about the 'beginners' list.
  2.1 - What is the list for?

A list for beginning Perl programmers to ask questions in a friendly
atmosphere.

  2.2 - What is this list _not_ for?

* SPAM
* Homework
* Solicitation
* Things that aren't Perl related
* Monkeys
* Monkeys solicitating homework on non-Perl related SPAM.
  2.3 - Are there any rules?

Yes. As with most communities, there are rules. Not many, and ones that
shouldn't need to be mentioned, but they are.

* Be nice
* No flaming
* Have fun
  2.4 - What topics are allowed on this list?

Basically, if it has to do with Perl, then it is allowed. You can ask
CGI, networking, syntax, style, etc... types of questions. If your
question has nothing at all to do with Perl, it will likely be ignored.
If it has anything to do with Perl, it will likely be answered.

  2.5 - I want to help, what should I do?

Subscribe to the list! If you see a question which you can give an
idiomatic and Good answer to, answer away! If you do not know the
answer, wait for someone to answer, and learn a little.

  2.6 - Is there anything I should keep in mind while answering?

We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the
beginner to the place in the FM they should R :)

Please do not quote the documentation unless you have something to add
to it. It is better to direct someone to the documentation so they
hopefully will read documentation above and beyond that which answers
their question. It also helps teach them how to use the documentation.

  2.7 - I don't want to post a question if it is in an FAQ. Where should I
look first?

Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it.
It can save everyone time if you look in the Perl FAQs first, instead of
having a list of people refer you to the Perl FAQs :) You can learn
about 'perldoc' by typing:

perldoc perldoc

At your command prompt. You can also view documentation online at:

http://www.perldoc.com and http://www.perl.com

  2.8 Is this a high traffic list?

YES! You have been warned! If you don't want to get ~100 emails per day
from this list, 

Re: function for finding the index of an element in an array?

2002-07-25 Thread Sudarshan Raghavan

On Thu, 25 Jul 2002, Daniel David wrote:

 Hi,
 I couldn't seem to find a built-in function for finding the index
 of an element in an array...so I wrote this one:
 
 
 
 #  position_of returns the position of a string in an array of strings,
 #  and -1 if the string is not a member of the array.

For an 'is it present' kind of operation a hash might be a better option. 
You will have explain as to what you need this for to decide that? Store 
your values as hash keys and a simple if (defined $hash{$value}) would do.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: function for finding the index of an element in an array?

2002-07-25 Thread Sudarshan Raghavan

On Thu, 25 Jul 2002, Sudarshan Raghavan wrote:

 On Thu, 25 Jul 2002, Daniel David wrote:
 
  Hi,
  I couldn't seem to find a built-in function for finding the index
  of an element in an array...so I wrote this one:
  
  
  
  #  position_of returns the position of a string in an array of strings,
  #  and -1 if the string is not a member of the array.
 
 For an 'is it present' kind of operation a hash might be a better option. 
 You will have explain as to what you need this for to decide that? Store 
 your values as hash keys and a simple if (defined $hash{$value}) would do.

Sorry, that should be if (exists $hash{$value}) 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: del files

2002-07-25 Thread Connie Chan

1. in the array

Method 1
for (my $x = 0; $x = $#privates; $x++)
{  $privates[$x] =~ s/^(.+)$/$1/ }

Method 2
for (0..$#privates)
{ my $temp = shift(@privates);
 $temp = ''.$temp.'';
 push (@privates, $temp)
}

I believe there should be a simpiler way, 
anybody in list can tell ?

2. in the unlink loop
[...]
print \$_\;
[...]

Rgds,
Connie



- Original Message - 
From: Javeed SAR [EMAIL PROTECTED]
To: Connie Chan [EMAIL PROTECTED]
Sent: Thursday, July 25, 2002 7:15 PM
Subject: RE: del files


 Ok, can u tell me  this
 
 Hi All,
 
 my @privates =`cleartool lsprivate  -tag jav_test -other -invob \\train`;
 print @privates;
 
 
 I get this output when I execute the above  script:
 
 M:\jav_test\train\chet chet.mkelem
 
 
 I want  put  this output  in double quotes,how to do that in perl?? Like
 this
 
 M:\jav_test\train\chet chet.mkelem
 
 
 
 -Original Message-
 From: Connie Chan [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 2:28 PM
 To: Javeed SAR
 Cc: [EMAIL PROTECTED]
 Subject: Re: del files
 
 
 
  What about if there r space in file names?
 
 There is no problem for unlink to handle filename with spaceS.
 The issue is on how you get the file list to the array.
 
 Rgds,
 Connie
 
 
 
 
 
 
 
  -Original Message-
  From: Connie Chan [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, July 25, 2002 2:07 PM
  To: Javeed SAR; [EMAIL PROTECTED]
  Subject: Re: del files
 
  for (@privates)
  {   chomp;
  print Attemp to del $_\n;
  unlink ($_) ?
  {print $_ unable to del } :
  {print $_ deleted };
  }
 
  I didn't ever tried unlink @array like method,
  perhaps the problem is there.
 
  and you got 0 delete is the fail signal send
  back from the unlink action. you will got 1 deleted
  if the unlink is success.
 
  Rgds,
  Connie
 
 
  - Original Message -
  From: Javeed SAR [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Thursday, July 25, 2002 2:46 PM
  Subject: del files
 
 
  
  
  
   I want to  delete files.
  
   I am not able to delete , what is the wrong thing I am doing here.
   I am able to see the file in @privates
  
  
   I am getting following output:
  
  
   0 deleted
   Attempting to delete M:\jav_test\train\k k k.mkelem.mkelem
  
  
  
   #!c:\perl\bin\perl
   @privates =`cleartool lsprivate  -tag jav_test -other`;
   #print @privates;
   #print Enter a  pattern:;
   #my $pattern =;
   #chomp $pattern;
   foreach (@privates)
   {
   print \nAttempting to delete $_\n;
$delo=unlink @private;
   print \n $delo deleted;
   }
  
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: another sort question (flame away)

2002-07-25 Thread Bob Showalter

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 24, 2002 5:31 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: RE: another sort question (flame away)
 
 
   This should not matter what the size is but would 
 expect a number at
 the beginning:
 
 foreach my $MyKey (sort {$a-[1] = $b-[1]} 
   map{[ $_, /^(\d+)/ ]} 
   keys %final_list) {
printf %-s\n, $MyKey-[0];
  }

Given the behavior of = with strings beginning with
a number, isn't this unecessary?

What if the string contains a negative or floating-point
number? Leading blanks?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: function for finding the index of an element in an array?

2002-07-25 Thread Connie Chan

Right! I have the same idea as you, and I have this :

my @list = ('1234', '4567', '789A', 'BCDE', 'FGHI');
my $GetLocation = 0;
my $value = 'BCDE';
 
for (my $atLoc = 0; $atLoc = $#list and ! $GetLocation ; $atLoc++) 
{ $GetLocation = $atLoc if ($value eq  $list[$atLoc])  }
 
And I finally got the same ans. =)
Deal with it by a hash is the only choice

Rgds,
Connie



- Original Message - 
From: Daniel David [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 25, 2002 6:00 PM
Subject: function for finding the index of an element in an array?


 Hi,
 I couldn't seem to find a built-in function for finding the index
 of an element in an array...so I wrote this one:
 
 
 
 #  position_of returns the position of a string in an array of strings,
 #  and -1 if the string is not a member of the array.
 
 sub position_of {
my ($x,@y) = @_;
foreach $z (0..$#y) {
   if (@y[$z] eq $x) {
  return ($z);
   }
}
 
return -1;
 }
 --
 
 it works but somehow i feel there's a built in function for this
 
 thanks.
 
 _
 MSN Photos is the easiest way to share and print your photos: 
 http://photos.msn.com/support/worldwide.aspx
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




re: directory scanning

2002-07-25 Thread Sudarshan Raghavan

On Thu, 25 Jul 2002, William Black wrote:

 Hi All,
 
 I need an idea on how to approach a script.  Say I had a directory X with 50 
 files in it and I have another directory Y that is suppose to have the same 
 exact files in it as X.  How could someone approach checking directory Y 
 aginst X to see if they had the same files?

By the same file if you mean same contents, check out File::Compare
The approach would be something like this.

use File::Compare;
opendir (DIRX, $dirX) or die .;
while (my $xfile = readdir(DIRX)) {
  if (compare($xfile, $dirY/$xfile) != 0) {
print Your error messages;
  }
}
closedir (DIRX);

Note, you will have to add a check to see if the number of files in dir X 
and dir Y are the same.

 
 Thks,
 
 
 William Black
 
 
 
 _
 MSN Photos is the easiest way to share and print your photos: 
 http://photos.msn.com/support/worldwide.aspx
 
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: directory scanning

2002-07-25 Thread Nikola Janceski

Funny. I wrote a script that does that, but recursively for all subdirs too.
Here's a good place to start: File::Find


 -Original Message-
 From: Sudarshan Raghavan [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 8:56 AM
 To: Perl beginners
 Subject: re: directory scanning
 
 
 On Thu, 25 Jul 2002, William Black wrote:
 
  Hi All,
  
  I need an idea on how to approach a script.  Say I had a 
 directory X with 50 
  files in it and I have another directory Y that is suppose 
 to have the same 
  exact files in it as X.  How could someone approach 
 checking directory Y 
  aginst X to see if they had the same files?
 
 By the same file if you mean same contents, check out File::Compare
 The approach would be something like this.
 
 use File::Compare;
 opendir (DIRX, $dirX) or die .;
 while (my $xfile = readdir(DIRX)) {
   if (compare($xfile, $dirY/$xfile) != 0) {
 print Your error messages;
   }
 }
 closedir (DIRX);
 
 Note, you will have to add a check to see if the number of 
 files in dir X 
 and dir Y are the same.
 
  
  Thks,
  
  
  William Black
  
  
  
  _
  MSN Photos is the easiest way to share and print your photos: 
  http://photos.msn.com/support/worldwide.aspx
  
  
  
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: function for finding the index of an element in an array?

2002-07-25 Thread Kay Bieri


 Right! I have the same idea as you, and I have this :

 my @list = ('1234', '4567', '789A', 'BCDE', 'FGHI');
 my $GetLocation = 0;
 my $value = 'BCDE';

 for (my $atLoc = 0; $atLoc = $#list and ! $GetLocation ; $atLoc++)
 { $GetLocation = $atLoc if ($value eq  $list[$atLoc])  }

 And I finally got the same ans. =)
 Deal with it by a hash is the only choice


Your script does have some problems. For instance, if the string you're
looking for is in the first (index = 0) position and also in a later
position, the for loop will only find the latter. Also if $GetLocation
stays 0, you don't know whether the string is not present in the array at
all or whether it is just in the beginning position.


Kay




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: function for finding the index of an element in an array?

2002-07-25 Thread Robin Norwood

Kay Bieri [EMAIL PROTECTED] writes:

  Right! I have the same idea as you, and I have this :
 
  my @list = ('1234', '4567', '789A', 'BCDE', 'FGHI');
  my $GetLocation = 0;
  my $value = 'BCDE';
 
  for (my $atLoc = 0; $atLoc = $#list and ! $GetLocation ; $atLoc++)
  { $GetLocation = $atLoc if ($value eq  $list[$atLoc])  }
 
  And I finally got the same ans. =)
  Deal with it by a hash is the only choice
 
 
 Your script does have some problems. For instance, if the string you're
 looking for is in the first (index = 0) position and also in a later
 position, the for loop will only find the latter. Also if $GetLocation
 stays 0, you don't know whether the string is not present in the array at
 all or whether it is just in the beginning position.

Try this instead:

#!/usr/bin/perl -wl

my @list = qw/BCDE 1234 4567 789A BCDE FGHI/;

my $value = 'BCDE';

my @locations = grep { $list[$_] eq $value } (0 .. $#list);

if (@locations) {
  print String '$value' found at index(es):  . join(, , @locations);
}
else {
  print String '$value' not found.;
}


display:
String 'BCDE' found at: 0, 4


If you find yourself using 'for', it's often best to stop and think
for a bit about a more 'perlish' way to do the same thing with map,
grep, or foreach.  Look to `perldoc -f grep` or the camel book for
more interesting examples of grep usage.

-RN


-- 

Robin Norwood
Red Hat, Inc.

The Sage does nothing, yet nothing remains undone.
-Lao Tzu, Te Tao Ching

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: That seems interesting ? but I don't know why ?

2002-07-25 Thread Chas Owens

snip
 Drieux might provide us with some benchmarks about which one's faster
 these days... ;-)
/snip

I beat him to it.  Interestingly enough, I either have a bug in my code
(and I don't think I do) or xor is dangerous in relation to negative
numbers (without the integer pragma).  The results seem to favor xor
except for long strings, but since xor is dangerous for negative doubles
and temp came in a close second or first every time I would suggest the
use of a temporary variable if you are concerned with speed.

output
Testing string type swaps
list
a = [this is one] :: b = [this is two]
a = [this is two] :: b = [this is one]
xor
a = [this is one] :: b = [this is two]
a = [this is two] :: b = [this is one]
c_inout
a = [this is one] :: b = [this is two]
a = [this is two] :: b = [this is one]
temp
a = [this is one] :: b = [this is two]
a = [this is two] :: b = [this is one]
Testing integer type swaps
list
a = [123] :: b = [-345]
a = [-345] :: b = [123]
xor
a = [123] :: b = [-345]
a = [4294966951] :: b = [123]
c_inout
a = [123] :: b = [-345]
a = [-345] :: b = [123]
temp
a = [123] :: b = [-345]
a = [-345] :: b = [123]
Testing double type swaps
list
a = [123.345] :: b = [-345.457]
a = [-345.457] :: b = [123.345]
xor
a = [123.345] :: b = [-345.457]
a = [4294966951] :: b = [123]
c_inout
a = [123.345] :: b = [-345.457]
a = [-345.457] :: b = [123.345]
temp
a = [123.345] :: b = [-345.457]
a = [-345.457] :: b = [123.345]
Benchmarking string swaps
Ratelist c_inouttemp xor
list241920/s  ---16%-54%-55%
c_inout 287630/s 19%  ---45%-47%
temp527651/s118% 83%  -- -2%
xor 539312/s123% 88%  2%  --
Benchmarking long_string swaps
Ratelist c_inout xortemp
list177932/s  ---15%-40%-44%
c_inout 208521/s 17%  ---29%-35%
xor 294637/s 66% 41%  -- -8%
temp319670/s 80% 53%  8%  --
Benchmarking integer swaps
Ratelist c_inouttemp xor
list514623/s  ---13%-40%-41%
c_inout 594074/s 15%  ---31%-32%
temp863985/s 68% 45%  -- -1%
xor 872933/s 70% 47%  1%  --
Benchmarking double swaps
Ratelist c_inouttemp xor
list508858/s  -- -7%-40%-42%
c_inout 549703/s  8%  ---35%-38%
temp843806/s 66% 54%  -- -5%
xor 883833/s 74% 61%  5%  --
output

code
#!/usr/bin/perl

use strict;
use warnings;
use Benchmark;
use Inline 'C';

my $a;
my $b;

my %sub = (
xor = sub {
$a ^= $b;
$b ^= $a;
$a ^= $b;
},
list = sub {
($a, $b) = ($b, $a);
},
temp = sub {
my $temp = $a;
$a   = $b;
$b   = $temp;
},
c_inout = sub {
c_inout($a, $b);
}
);

my %run = (
integer  = [123, -345],
double   = [123.345, -345.457],
string   = [this is one, this is two],
long_string  = [
this is the first very long string, and a very long string it is
indead for I remember few strings longer or as long than this one, maybe
way back in aught one the was a string close to this size, but I think
that was just an optical illusion because this string is just way too
freaking huge to be compared with paltry little strings like 'this is
one' or 'this is two' and the like.,
this is the second very long string, and a very long string it is
indead for I remember few strings longer or as long than this one, maybe
way back in aught one the was a string close to this size, but I think
that was just an optical illusion because this string is just way too
freaking huge to be compared with paltry little strings like 'this is
one' or 'this is two' and the like.,
],
);

foreach my $run (keys %run) {
next if $run eq 'long_string';
print Testing $run type swaps\n;
foreach my $sub (keys %sub) {
print \t$sub\n;
($a, $b) = ($run{$run}[0], $run{$run}[1]);
print \t\ta = [$a] :: b = [$b]\n;
$sub{$sub}-();
print \t\ta = [$a] :: b = [$b]\n;
}
}

foreach my $run (keys %run) {
print Benchmarking $run swaps\n;
($a, $b) = ($run{$run}[0], $run{$run}[1]);

RE: That seems interesting ? but I don't know why ?

2002-07-25 Thread Bob Showalter

 -Original Message-
 From: John W. Krahn [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 24, 2002 4:30 PM
 To: [EMAIL PROTECTED]
 Subject: Re: That seems interesting ? but I don't know why ?
 
 
 Bob Showalter wrote:
  
  Well, it only works for integers. It's because of the way ^
  (bitwise xor) works. Given x=0 and y=1, for instance:
  
 x = x ^ yy = y ^ x   x = x ^ y
 x = 0 ^ 1y = 1 ^ 1   x = 1 ^ 0
 x = 1y = 0   x = 1
 
 Actually in perl it works with strings as well.  :-)
 
 $ perl -le'
 $x = abcde; $y = fgh;
 print \$x = $x  \$y = $y;
 $x ^= $y;
 $y ^= $x;
 $x ^= $y;
 print \$x = $x  \$y = $y;
 '
 $x = abcde  $y = fgh
 $x = fgh  $y = abcde

Neat-o! I had to look that one up, under perldoc perlop, Bitwise
String Operators. Great for vector operations.

But there's a lurking danger when applied to general-purpose
swapping. Consider:

$ perl -le'
$x = abcde; $y = 123;
print \$x = $x  \$y = $y;
$x ^= $y;
$y ^= $x;
$x ^= $y;
print \$x = $x  \$y = $y;
'
$x = abcde  $y = 123
$x = 123  $y = 0  --- Oops! What happened to abcde?

And yet, setting $y = 123 works.

Also, if either is undef, the result becomes  or 0, depending
on the other value.

($x, $y) = ($y, $x) remains the foolproof solution, I think...

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: function for finding the index of an element in an array?

2002-07-25 Thread Connie Chan

Ooops... =)

I 've posted the bug version, which should set the beginning with -1. 
Thanks for remind =)

Rgds,
Connie

- Original Message - 
From: Kay Bieri [EMAIL PROTECTED]
To: Connie Chan [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Thursday, July 25, 2002 9:07 PM
Subject: Re: function for finding the index of an element in an array?


 
  Right! I have the same idea as you, and I have this :
 
  my @list = ('1234', '4567', '789A', 'BCDE', 'FGHI');
  my $GetLocation = 0;
  my $value = 'BCDE';
 
  for (my $atLoc = 0; $atLoc = $#list and ! $GetLocation ; $atLoc++)
  { $GetLocation = $atLoc if ($value eq  $list[$atLoc])  }
 
  And I finally got the same ans. =)
  Deal with it by a hash is the only choice
 
 
 Your script does have some problems. For instance, if the string you're
 looking for is in the first (index = 0) position and also in a later
 position, the for loop will only find the latter. Also if $GetLocation
 stays 0, you don't know whether the string is not present in the array at
 all or whether it is just in the beginning position.
 
 
 Kay
 
 
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: another sort question (flame away)

2002-07-25 Thread David . Wagner

Depends on what the user is really after. To me it is a starting
point for the developer to continue from there.  With minor changes, it
should be able to handle all that the developer wants, but it was stated
that this was a Key into a hash.

Wags ;)

-Original Message-
From: Bob Showalter [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 25, 2002 05:45
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: another sort question (flame away)


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 24, 2002 5:31 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: RE: another sort question (flame away)
 
 
   This should not matter what the size is but would 
 expect a number at
 the beginning:
 
 foreach my $MyKey (sort {$a-[1] = $b-[1]} 
   map{[ $_, /^(\d+)/ ]} 
   keys %final_list) {
printf %-s\n, $MyKey-[0];
  }

Given the behavior of = with strings beginning with
a number, isn't this unecessary?

What if the string contains a negative or floating-point
number? Leading blanks?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: function for finding the index of an element in an array?

2002-07-25 Thread Janek Schleicher

Daniel David wrote at Thu, 25 Jul 2002 12:00:29 +0200:

 I couldn't seem to find a built-in function for finding the index of an element in 
an array...so I
 wrote this one:
 ...
 
 it works but somehow i feel there's a built in function for this

You could also exploit the List::Util module:

use List::Util qw/first/;

my @array = ('a' .. 'z');
my $element = 'q';

print first {$array[$_] eq $element} (0 .. $#array);


Greetings,
Janek

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




on a lighter note

2002-07-25 Thread nkuipers

a bit of humour in appreciation for the help I've gotten on this mailing list.


#!/usr/bin/perl

no strict; $rules;

my %hash = (smells = 'good'); for $i (@drag) {
open EYES, $i.must or warn groovy man;
print Once again, my hash makes me one with the Llama;
}
close EYES and sleep;

You want me to do WHAT?!
~every programmer since the dawn of computing



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: directory scanning

2002-07-25 Thread zentara

On Thu, 25 Jul 2002 08:09:17 -0400, [EMAIL PROTECTED] (William
Black) wrote:

Hi All,

I need an idea on how to approach a script.  Say I had a directory X with 50 
files in it and I have another directory Y that is suppose to have the same 
exact files in it as X.  How could someone approach checking directory Y 
aginst X to see if they had the same files?

Here, this will get you most of the way there.
I'm stumped. To test this, I copied some files
from X to Y, but the md5_hex sums don't agree.
?
I checked the files with a hexdiff program and
they are identical. I wonder if Digest::MD5 can
be trusted???


#!/usr/bin/perl
use Digest::MD5 qw(md5_hex);

$path= '/home/zentara/X/';
$path1='/home/zentara/Y/';

opendir DIR, $path or die can't ls $path: $!;
@X= grep { $_ ne . and $_ ne .. } readdir DIR;
close DIR;
opendir DIR, $path1 or die can't ls $path: $!;
@Y= grep { $_ ne . and $_ ne .. } readdir DIR;
close DIR;

#print @X\n@Y\n;

foreach $file (@X){
  $file1= $path1.$file;
  print $file1\n;
  print md5_hex($file),\n;
  print md5_hex($file1),\n;

if ( md5_hex($file) ne md5_hex($file1)){
print $file is not identical\n}
}


%Z = map { $_ = 1 } @Y;
@diff = grep { not $Z{$_} } @X;
print $path1 is missing @diff\n;



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: directory scanning

2002-07-25 Thread Bob Showalter

 -Original Message-
 From: zentara [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 12:18 PM
 To: [EMAIL PROTECTED]
 Subject: Re: directory scanning
 
 
 On Thu, 25 Jul 2002 08:09:17 -0400, [EMAIL PROTECTED] (William
 Black) wrote:
 
 Hi All,
 
 I need an idea on how to approach a script.  Say I had a 
 directory X with 50 
 files in it and I have another directory Y that is suppose 
 to have the same 
 exact files in it as X.  How could someone approach checking 
 directory Y 
 aginst X to see if they had the same files?
 
 Here, this will get you most of the way there.
 I'm stumped. To test this, I copied some files
 from X to Y, but the md5_hex sums don't agree.
 ?
 I checked the files with a hexdiff program and
 they are identical. I wonder if Digest::MD5 can
 be trusted???

It's fine. See below.

 
 
 #!/usr/bin/perl
 use Digest::MD5 qw(md5_hex);
 
 $path= '/home/zentara/X/';
 $path1='/home/zentara/Y/';
 
 opendir DIR, $path or die can't ls $path: $!;
 @X= grep { $_ ne . and $_ ne .. } readdir DIR;
 close DIR;
 opendir DIR, $path1 or die can't ls $path: $!;
 @Y= grep { $_ ne . and $_ ne .. } readdir DIR;
 close DIR;
 
 #print @X\n@Y\n;
 
 foreach $file (@X){
   $file1= $path1.$file;
   print $file1\n;
   print md5_hex($file),\n;
   print md5_hex($file1),\n;
 
 if ( md5_hex($file) ne md5_hex($file1)){

Uh, you're running the digest on the file *names* and not
the file *contents*. Obviously, the file *names* aren't the
same!

 print $file is not identical\n}
 }
 
 
 %Z = map { $_ = 1 } @Y;
 @diff = grep { not $Z{$_} } @X;
 print $path1 is missing @diff\n;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: directory scanning

2002-07-25 Thread Felix Geerinckx

on Thu, 25 Jul 2002 16:18:00 GMT, Zentara wrote:

 I checked the files with a hexdiff program and
 they are identical. I wonder if Digest::MD5 can
 be trusted???

Oh yes, it can. You should reread

perldoc Digest::MD5

the md5_hex function expects data as its argument, not a filename.

You could use (direct quote from above-mentioned docs):

use Digest::MD5;

my $file = shift || /etc/passwd;
open(FILE, $file) or die Can't open '$file': $!;
binmode(FILE);

print Digest::MD5-new-addfile(*FILE)-hexdigest,  $file\n;

-- 
felix



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: directory scanning

2002-07-25 Thread zentara

On Thu, 25 Jul 2002 12:25:06 -0400, [EMAIL PROTECTED] (Bob
Showalter) wrote:

Uh, you're running the digest on the file *names* and not
the file *contents*. Obviously, the file *names* aren't the
same!

Thanks Bob, I gloss over the details sometimes. :-)
This one works fine:
##
#!/usr/bin/perl
use Digest::MD5 qw(md5_hex);

$path= '/home/zentara/X/';
$path1='/home/zentara/Y/';

opendir DIR, $path or die can't ls $path: $!;
@X= grep { $_ ne . and $_ ne .. } readdir DIR;
close DIR;
opendir DIR, $path1 or die can't ls $path: $!;
@Y= grep { $_ ne . and $_ ne .. } readdir DIR;
close DIR;

$/=undef;
foreach $file (@X){
   $file1= $path1.$file;
   open (FH,$file);
   $file_slurp= (FH);
   close FH;
   open (FH1,$file1);
   $file1_slurp=(FH1);
   close FH1;

if ( md5_hex($file_slurp) ne md5_hex($file1_slurp)){
print $file is not identical\n}
}


%Z = map { $_ = 1 } @Y;
@diff = grep { not $Z{$_} } @X;
print $path1 is missing @diff\n;




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Percent % completed?

2002-07-25 Thread Timothy Johnson


Perhaps you could open the command to a filehandle

open(COMMAND,|command);

and figure out something from there.  I've never done it, so I'm not sure,
and I have to run, but that might get you started.
-Original Message-
From: David Samuelsson (PAC) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 25, 2002 12:28 AM
To: '[EMAIL PROTECTED]'
Subject: Percent % completed?


Hello again out there.

Is there anyway to get perl to do a counter so it counts in the command
shell how many % that is done? I have a script that runs a check on a
database, its just 1 command and it spits out some information. Can i parse
this information from when its printing out this information, and insted
capture some variabels and make it count like 0 % ready, 25 % ready or
similar? its hard since its just 1 command and that spits out all the
infomation if the database is at good health, but the check can take a
really long time for some databses and a very short time for not so big
databases.  But the out put is always the same for the databses unless there
is an error in them.

Processing key file: vob_db.k01(1), total of 444 nodes


--

Processing key file: vob_db.k02(2), total of 840 nodes


--

Processing key file: vob_db.k03(5), total of 1 node


--

Processing key file: vob_db.k04(6), total of 1 node


--

Processing data file: vob_db.d01(0), total of 37651 records


--

Processing data file: vob_db.d02(3), total of 20628 records


--

Processing data file: vob_db.d03(4), total of 1 record


Database consistency check completed

0 errors were encountered in 0 records/nodes

This is the output from the command.  Anyone got a clue on how to make it
count for each line or something?

Thanks for any info or similar scripting techniqes.

//Dave

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Percent % completed?

2002-07-25 Thread Nikola Janceski

I think Tim meant:

open(COMMAND, command |) or die $!;

while (COMMAND){
#here will come each line of output in $_ while the command runs and
until the command ends.
}
close COMMAND;

 -Original Message-
 From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 1:18 PM
 To: 'David Samuelsson (PAC)'; '[EMAIL PROTECTED]'
 Subject: RE: Percent % completed?
 
 
 
 Perhaps you could open the command to a filehandle
 
 open(COMMAND,|command);
 
 and figure out something from there.  I've never done it, so 
 I'm not sure,
 and I have to run, but that might get you started.
 -Original Message-
 From: David Samuelsson (PAC) [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 12:28 AM
 To: '[EMAIL PROTECTED]'
 Subject: Percent % completed?
 
 
 Hello again out there.
 
 Is there anyway to get perl to do a counter so it counts in 
 the command
 shell how many % that is done? I have a script that runs a check on a
 database, its just 1 command and it spits out some 
 information. Can i parse
 this information from when its printing out this information, 
 and insted
 capture some variabels and make it count like 0 % ready, 25 % ready or
 similar? its hard since its just 1 command and that spits out all the
 infomation if the database is at good health, but the check can take a
 really long time for some databses and a very short time for 
 not so big
 databases.  But the out put is always the same for the 
 databses unless there
 is an error in them.
 
 Processing key file: vob_db.k01(1), total of 444 nodes
 
 
 --
 
 Processing key file: vob_db.k02(2), total of 840 nodes
 
 
 --
 
 Processing key file: vob_db.k03(5), total of 1 node
 
 
 --
 
 Processing key file: vob_db.k04(6), total of 1 node
 
 
 --
 
 Processing data file: vob_db.d01(0), total of 37651 records
 
 
 --
 
 Processing data file: vob_db.d02(3), total of 20628 records
 
 
 --
 
 Processing data file: vob_db.d03(4), total of 1 record
 
 
 Database consistency check completed
 
 0 errors were encountered in 0 records/nodes
 
 This is the output from the command.  Anyone got a clue on 
 how to make it
 count for each line or something?
 
 Thanks for any info or similar scripting techniqes.
 
 //Dave
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Percent % completed?

2002-07-25 Thread Timothy Johnson


That's the one. :)

-Original Message-
From: Nikola Janceski [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 25, 2002 10:40 AM
To: 'Timothy Johnson'; 'David Samuelsson (PAC)'; '[EMAIL PROTECTED]'
Subject: RE: Percent % completed?


I think Tim meant:

open(COMMAND, command |) or die $!;

while (COMMAND){
#here will come each line of output in $_ while the command runs and
until the command ends.
}
close COMMAND;

 -Original Message-
 From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 1:18 PM
 To: 'David Samuelsson (PAC)'; '[EMAIL PROTECTED]'
 Subject: RE: Percent % completed?
 
 
 
 Perhaps you could open the command to a filehandle
 
 open(COMMAND,|command);
 
 and figure out something from there.  I've never done it, so 
 I'm not sure,
 and I have to run, but that might get you started.
 -Original Message-
 From: David Samuelsson (PAC) [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 12:28 AM
 To: '[EMAIL PROTECTED]'
 Subject: Percent % completed?
 
 
 Hello again out there.
 
 Is there anyway to get perl to do a counter so it counts in 
 the command
 shell how many % that is done? I have a script that runs a check on a
 database, its just 1 command and it spits out some 
 information. Can i parse
 this information from when its printing out this information, 
 and insted
 capture some variabels and make it count like 0 % ready, 25 % ready or
 similar? its hard since its just 1 command and that spits out all the
 infomation if the database is at good health, but the check can take a
 really long time for some databses and a very short time for 
 not so big
 databases.  But the out put is always the same for the 
 databses unless there
 is an error in them.
 
 Processing key file: vob_db.k01(1), total of 444 nodes
 
 
 --
 
 Processing key file: vob_db.k02(2), total of 840 nodes
 
 
 --
 
 Processing key file: vob_db.k03(5), total of 1 node
 
 
 --
 
 Processing key file: vob_db.k04(6), total of 1 node
 
 
 --
 
 Processing data file: vob_db.d01(0), total of 37651 records
 
 
 --
 
 Processing data file: vob_db.d02(3), total of 20628 records
 
 
 --
 
 Processing data file: vob_db.d03(4), total of 1 record
 
 
 Database consistency check completed
 
 0 errors were encountered in 0 records/nodes
 
 This is the output from the command.  Anyone got a clue on 
 how to make it
 count for each line or something?
 
 Thanks for any info or similar scripting techniqes.
 
 //Dave
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Jes new to List

2002-07-25 Thread [EMAIL PROTECTED]

Strolling thru' Learning Perl and already have a few q's in mind:

I couldn't quite follow this program off the book. The parts not quite 
clear to me are (the hwole program is given below):

$i = 0;
$correct = maybe; {
while ($correct eq maybe)
{
if ($words[$i] eq $guess){
$correct = yes;
}
elsif ($i  2) {
$i = $i + 1;
Anyone would like to help?


--the whole program---
#!/usr/bin/perl
@words = qw (llama camel alpaca);
print what is your name\n;
$name = stdin;
chomp $name;
if ($name eq tan) {
print hey man\n;
}
else
{
print hi, $name\n;
print enter the password\n;
$guess = stdin;
chomp $guess;
$i = 0;
$correct = maybe; {
while ($correct eq maybe)
{
if ($words[$i] eq $guess){
$correct = yes;
}
elsif ($i  2) {
$i = $i + 1;
}
else
{
print wrong. try again\n;
$guess = stdin;
chomp $guess;
$i = 0;
}
}
}}
#EOF.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: little help

2002-07-25 Thread Nikola Janceski

No offense intended, but you could start by making the varible names a
little more descriptive.
Then use at least use strict, but it's only a suggestion.
Now see inline comments

 -Original Message-
 From: William Black [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 1:39 PM
 To: [EMAIL PROTECTED]
 Subject: re: little help
 
 
 Can someone tell me why the below code can't won't work.
 
 Essentially, there is a directory full of files and I wanted 
 to compare them
 to names I stored in a file.  If the name of the file is not 
 found I just
 want to say file not found, etc...
 
 A liitle help please
 
 $bin_dir = '...';
 
 
 open(FILE,'ck') or die Could not open file! ;
 $ct=0;
 while(FILE){$tmp = $_;chomp($tmp); $array[$ct] = $tmp;$ct++;}
#better written as:
while(FILE){
chomp;
push @array, $_;
}

 close(FILE);
 
 
 chdir($bin_dir);
 opendir(BINDIR,$bin_dir) or die Could not open $trillium=@array;
# this looks like a typo. shouldn't it be:
opendir(BINDIR,$bin_dir) or die Could not open: $!; # $! tells you why it
died
$trillium = @array; ## you really don't need this and you will see why.

 $laurel = @binfiles;
## where did @binfiles come from

 foreach $file(@binfiles){
## shouldn't it be
## foreach $file (@array){ #
## or 
foreach $file (readdir BINDIR){ #???

print $file was not found in ck.\n unless grep $file eq $_, @array;
}

## what the heck is this while loop? use grep (see above)
$marker=0;
$count=0;
while($count = ($trillium-1)){
if($file eq $array[$count]){
$marker=1;
last;
}
 
   $count++;
}#while
 
if($marker == 0){print$file was not found\n;}
 }
 
 
 
 
 
 William Black
 
 
 
 William Black
 
 
 
 _
 Send and receive Hotmail on your mobile device: http://mobile.msn.com
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Problem with UNPACK

2002-07-25 Thread Tin-Shan Chau


I have run into the following problem: If I concatenate the packed values of a list to 
a string, when I use the unpack operation to put the values back into an array, the 
last element is missing.  I can only get around the problem by specifying the exact 
number of elements to unpack.  And if I don't have that available, I would have to do 
two unpack operations, the first one to find out how many elements are in the array of 
packed values, the second to get the last value.  This seems rather a waste to me.  Is 
there any way to solve this problem.  Your help would be greatly appreciated.  Thanks 
in advance.


The following program illustrates the problem I am having:

$TBLXCOL_FORMAT = 'I/a*';
$lines[0] = CLASSCOUNT PSOPRDEFN   8 2 SMALLINT N;
$lines[1] = OPERPSWD   PSOPRDEFN   932 CHAR N;
$lines[2] = ENCRYPTED  PSOPRDEFN  10 2 SMALLINT N;
$lines[3] = SYMBOLICID PSOPRDEFN  11 8 CHAR N;
for ($i=0;$i4;$i++) {
   ($column, $table) = split / +/, $lines[$i];
   if (!exists($tblxcol{uc($table)})) {
  $tblxcol{uc($table)} = pack ($TBLXCOL_FORMAT, $column);
   }
   else {
  $tblxcol{uc($table)} .= pack ($TBLXCOL_FORMAT, $column);
   }
}
print 1st example\n;
array = unpack $TBLXCOL_FORMAT x 500, $tblxcol{PSOPRDEFN};
printf (Array size: %ld\n, $#array+1);
$i = 0;
foreach $item (array) {
   $i++;
   print $i   $item\n;
}
print \n2nd example\n;
array = unpack $TBLXCOL_FORMAT x ($#array+1), $tblxcol{PSOPRDEFN};
$i = 0;
foreach $item (array) {
   $i++;
   print $i   $item\n;
}
exit 0;





Re: Jes new to List

2002-07-25 Thread Joe Raube

So what part are you having trouble with

Tell us what you don't understand.

-Joe

--- [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Strolling thru' Learning Perl and already have a few q's in mind:
 
 I couldn't quite follow this program off the book. The parts not
 quite 
 clear to me are (the hwole program is given below):
 
 $i = 0;
 $correct = maybe; {
 while ($correct eq maybe)
 {
 if ($words[$i] eq $guess){
 $correct = yes;
 }
 elsif ($i  2) {
 $i = $i + 1;
 Anyone would like to help?
 
 
 --the whole program---
 #!/usr/bin/perl
 @words = qw (llama camel alpaca);
 print what is your name\n;
 $name = stdin;
 chomp $name;
 if ($name eq tan) {
 print hey man\n;
 }
 else
 {
 print hi, $name\n;
 print enter the password\n;
 $guess = stdin;
 chomp $guess;
 $i = 0;
 $correct = maybe; {
 while ($correct eq maybe)
 {
 if ($words[$i] eq $guess){
 $correct = yes;
 }
 elsif ($i  2) {
 $i = $i + 1;
 }
 else
 {
 print wrong. try again\n;
 $guess = stdin;
 chomp $guess;
 $i = 0;
 }
 }
 }}
 #EOF.
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


__
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




time comparison

2002-07-25 Thread lz

Hi guys,

I am extracting the following expiration time from a
certificate, and I get expiration time from the
certificate in the following format.
   notAfter=Nov 16 23:59:59 2002 GMT

I need to compare system date with the date from a
certificate to find out whether certificate has
already been expired or within 4 weeks of expiration.

Does anyone have any good pointers on how do it?

Thanks a lot!

__
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Checking if a file is downloading

2002-07-25 Thread Yupapa

Hi,

Does this work ah?

#!/usr/bin/perl
use strict;

my($Bytes,$fhandle,$Buffer);
my $file = 'yourfile.ext';
open(FILE, $file) or die print Could not open $file: $!\n;
while ($Bytes = read($fhandle,$Buffer,1024)) {
print FILE $Buffer;
}
close($fhandle);
close(FILE);

__END__



Connie Chan [EMAIL PROTECTED] wrote in message
001d01c23336$1140b8a0$[EMAIL PROTECTED]">news:001d01c23336$1140b8a0$[EMAIL PROTECTED]...
  Content-type: application/octet-stream
  Content-Disposition: attachment\; filename=$file

 This seems IE way, if I don't remember it wrongly,
 this does not work at NS


 Anyway, how about this ?

 $| = 1;

 my $file = 'yourfile.ext';

 print Content-type: application/(your file type)\r\n\r\n;

 open FH, $file;
 binmode(FH); binmode(STDOUT);
 until (eof FH) { read (FH, my $buf, 1) ; print $buf }
 close (FH);

 unlink ($file);

 #
 Code not tested, try it if you would like to =)

 Rgds,
 Connie







-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Command line Password

2002-07-25 Thread Richard Lowe

Hi,

I'm trying to read in a password from the command prompt, but want to either
mask the typed characters with the '*' character, or 'disconnect' the input
from the screen so the characters don't appear at all, but the input is
still captured.

The systems I'm using are Win32, and I'd rather not have to use any CPAN
modules - I've been looking into tied filehandles, but can't work out what's
required in the subroutines.

Any help greatfully received.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: on a lighter note

2002-07-25 Thread Chris Garaffa

Have you submitted to http://www.perlmonks.org/index.pl?node=Perl%20Poetry
(Perl Poetry @ perlmonks.org)?


He who calles himself nkuipers (from [EMAIL PROTECTED]) wrote on 7/25/02
11:47 AM:

 a bit of humour in appreciation for the help I've gotten on this mailing list.
 
 
 #!/usr/bin/perl
 
 no strict; $rules;
 
 my %hash = (smells = 'good'); for $i (@drag) {
 open EYES, $i.must or warn groovy man;
 print Once again, my hash makes me one with the Llama;
 }
 close EYES and sleep;
 
 You want me to do WHAT?!
 ~every programmer since the dawn of computing
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Jes new to List

2002-07-25 Thread Janek Schleicher

[EMAIL PROTECTED] wrote at Fri, 26 Jul 2002 07:18:00 +0200:

 Strolling thru' Learning Perl and already have a few q's in mind:
 
 I couldn't quite follow this program off the book. The parts not quite clear to me 
are (the hwole
 program is given below):
 
 $i = 0;
 $correct = maybe; {
 while ($correct eq maybe)
 {
 if ($words[$i] eq $guess){
 $correct = yes;
 }
 elsif ($i  2) {
 $i = $i + 1;

What don't do you understand ?
All lines ?

I'm afraid we only can help you,
if you're a little more specific.
Especially as there are from my point of view,
more complicated structures in the whole script.


BTW: In the whole program posted,
 there's a line I don't understand:

 $name = stdin;

 stdin should be uppercase: STDIN


Cheerio,
Janek


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: time comparison

2002-07-25 Thread Nikola Janceski

Date::Calc

And any other Date module you can find on search.cpan.org


 -Original Message-
 From: lz [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 2:02 PM
 To: [EMAIL PROTECTED]
 Subject: time comparison
 
 
 Hi guys,
 
 I am extracting the following expiration time from a
 certificate, and I get expiration time from the
 certificate in the following format.
notAfter=Nov 16 23:59:59 2002 GMT
 
 I need to compare system date with the date from a
 certificate to find out whether certificate has
 already been expired or within 4 weeks of expiration.
 
 Does anyone have any good pointers on how do it?
 
 Thanks a lot!
 
 __
 Do You Yahoo!?
 Yahoo! Health - Feel better, live better
 http://health.yahoo.com
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Jes new to List

2002-07-25 Thread Mark Anderson


I couldn't quite follow this program off the book. The parts not quite
clear to me are (the hwole program is given below):

I'll go through them block by block, and then you can ask deeper questions
about the ones that I don't explain well enough.

$i = 0;

I'm guessing that you know that $i is a variable.  Here we set it to 0.
This is because we are going to count with it later in the program.

$correct = maybe; {

We're again initializing a variable, in this case $correct has the value
maybe assigned to it.

while ($correct eq maybe)
{
if ($words[$i] eq $guess){
$correct = yes;
}

As long as $correct still has the value maybe, look at element $i of the
@words array and compare it to the value of the variable $guess, if they are
the same, change the value of $correct to yes, thereby breaking us out of
the while loop.

elsif ($i  2) {
$i = $i + 1;
}

If the $i th element of @wordss is not the same as guess and the value of $i
is 0 or 1, then we add 1 to $i.  This is because @words is hardcoded with 3
responses, and we're using $i to loop through the @words array in the if.

It also helps to indent everything within a set of braces {} so that you can
see where loops and conditionals begin and end:

--the whole program---
#!/usr/bin/perl

@words = qw (llama camel alpaca);
print what is your name\n;
$name = stdin;
chomp $name;
if ($name eq tan) {
print hey man\n;
} else {
print hi, $name\n;
print enter the password\n;
$guess = stdin;
chomp $guess;
$i = 0;
$correct = maybe; {
while ($correct eq maybe) {
if ($words[$i] eq $guess){
$correct = yes;
} elsif ($i  2) {
$i = $i + 1;
} else {
print wrong. try again\n;
$guess = stdin;
chomp $guess;
$i = 0;
}
}
}
}
#EOF.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Command line Password

2002-07-25 Thread drieux


On Thursday, July 25, 2002, at 02:57 , Richard Lowe wrote:

 The systems I'm using are Win32, and I'd rather not have to use any CPAN
 modules - I've been looking into tied filehandles, but can't work out 
 what's
 required in the subroutines.

I presume that you are doing this in a 'dos command window'
vice in say a cygwin window ???

You might want to think about 'popping' a window in that
case and stay within the standard microsoft style approach
to dealing with this - cf:

perl/tk

if your version of Win32 has something like stty - that
can allow you to 'set no echo' on the command line - that
is normally what is done in most of these types of cases.

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Command line Password

2002-07-25 Thread Bob Showalter

 -Original Message-
 From: Richard Lowe [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 25, 2002 5:57 AM
 To: [EMAIL PROTECTED]
 Subject: Command line Password
 
 
 Hi,
 
 I'm trying to read in a password from the command prompt, but 
 want to either
 mask the typed characters with the '*' character, or 
 'disconnect' the input
 from the screen so the characters don't appear at all, but 
 the input is
 still captured.

First check the FAQ, as it addresses this question:

   perldoc -q password

 
 The systems I'm using are Win32, 

My condolences. But there is a nice Win32::Console module.

 and I'd rather not have to use any CPAN modules 

I think you're going to have to, unless you plan to reinvent
the wheel and write your own module.

 - I've been looking into tied filehandles, but can't 
 work out what's
 required in the subroutines.

I don't think that will help you. The echoing is happening
upstream of Perl's filehandles.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: del files

2002-07-25 Thread John W. Krahn

[ Please don't top-post
  Please remove unwanted lines from your post.
  ( 122 lines trimmed )
]


Connie Chan wrote:
 
 1. in the array
 
 Method 1
 for (my $x = 0; $x = $#privates; $x++)
 {  $privates[$x] =~ s/^(.+)$/$1/ }
 
 Method 2
 for (0..$#privates)
 { my $temp = shift(@privates);
  $temp = ''.$temp.'';
  push (@privates, $temp)
 }
 
 I believe there should be a simpiler way,
 anybody in list can tell ?


$_ = qq($_) for @privates;


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: another sort question (flame away)

2002-07-25 Thread John W. Krahn

Bob Showalter wrote:
 
  From: [EMAIL PROTECTED]
 
This should not matter what the size is but would
  expect a number at
  the beginning:
 
  foreach my $MyKey (sort {$a-[1] = $b-[1]}
map{[ $_, /^(\d+)/ ]}
keys %final_list) {
 printf %-s\n, $MyKey-[0];
   }
 
 Given the behavior of = with strings beginning with
 a number, isn't this unecessary?
 
 What if the string contains a negative or floating-point
 number? Leading blanks?

Also, this only sorts the numerical half of the key, it doesn't sort the
whole key.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




named-pipes limited to 1 line?

2002-07-25 Thread zentara

Hi, 
I'm starting to check out IPC with named pipes.
In the following example, my
pipe-writer dosn't work from inside a loop. It only
sends one line and then it all closes. Is this a limitation
of named pipes?  How do you keep the pipe open?


First I create the named-pipe:
#!/bin/sh
mkfifo named-pipe

Then here is the pipe-reader:
#
#!/usr/bin/perl
open(FIFO, named-pipe)  or die $!;
while (FIFO) {
print Got: $_;
}
close(FIFO);
##

Here is the pipe-writer:

#!/usr/bin/perl
open(FIFO,  named-pipe) or die $!;
$|=1;
#while(1){ #will not work in this loop
$input = STDIN;
print $input;
print FIFO $input;
#}

close(FIFO);



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Hi, newbie question

2002-07-25 Thread Robert Thompson

In vi, you have to type ctrl-v ctrl-m. This will tell vi you mean control-m and not 
carrot-m.

:%s/ctrl-vcrtl-m//g

=-= Robert Thompson

  Even in vi when i do a search for ^M by doing '/^M' it says that no matches were 
found. The ^M is not two characters but one. Can anyone out there please help me?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




determining whether Net::FTP module present: version 5.005_03on Solaris

2002-07-25 Thread McCormick, Rob E

All,

I'm scratching my head trying to determine whether perldoc isn't working
correctly or if Net::FTP just isn't present?

If I need to obtain Net::FTP from CPAN , how would I install as not root
and use it?  I wouldn't simply be able to:

use Net::FTP;   # would I?

Tried: /bin perldoc -m Net::FTP
No documentation found for Net::FTP.

My path is set in .bashrc: /usr/bin:/usr/sbin:/usr/perl5/bin

/bin perl -v

shows:  This is perl, version 5.005_03 built for sun4-solaris

/bin perl -V also shows

libpth=/lib /usr/lib /usr/ccs/lib

  @INC:
/usr/perl5/5.00503/sun4-solaris
/usr/perl5/5.00503
/usr/perl5/site_perl/5.005/sun4-solaris
/usr/perl5/site_perl/5.005

I attempted to look for *.pm with:

bin find /usr/perl5 -name [Ff]*.pm -print
/usr/perl5/5.00503/CGI/Fast.pm
/usr/perl5/5.00503/CPAN/FirstTime.pm
/usr/perl5/5.00503/File/Find.pm
/usr/perl5/5.00503/Pod/Functions.pm
/usr/perl5/5.00503/sun4-solaris/IO/File.pm
/usr/perl5/5.00503/sun4-solaris/Fcntl.pm
/usr/perl5/5.00503/Fatal.pm
/usr/perl5/5.00503/FileCache.pm
/usr/perl5/5.00503/FileHandle.pm
/usr/perl5/5.00503/FindBin.pm
/usr/perl5/5.00503/fields.pm


Rob
--
Rob McCormick 




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: time comparison

2002-07-25 Thread Timothy Johnson


You can try using Time::Local to convert it to time() format and then just
subtract the number of seconds to see if it is expired...

-Original Message-
From: lz [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 25, 2002 11:02 AM
To: [EMAIL PROTECTED]
Subject: time comparison


Hi guys,

I am extracting the following expiration time from a
certificate, and I get expiration time from the
certificate in the following format.
   notAfter=Nov 16 23:59:59 2002 GMT

I need to compare system date with the date from a
certificate to find out whether certificate has
already been expired or within 4 weeks of expiration.

Does anyone have any good pointers on how do it?

Thanks a lot!

__
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: determining whether Net::FTP module present: version 5.005_03on Solaris

2002-07-25 Thread nkuipers

I learned just today actually how to install a module when not root.

So, you have your module tarball all good to go:

mkdir ~/lib
tar -zxvf modulename.tar.gz
perl Makefile.PL LIB=~/lib
make test
make
make install

and you should be fine

the link where I found the above is: 
http://perlmonks.org/index.pl?node_id=128077



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]