[12713] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 123 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 13 19:27:25 1999

Date: Tue, 13 Jul 1999 16:22:37 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 13 Jul 1999     Volume: 9 Number: 123

Today's topics:
        checking if variable is already a memeber of an array? <r2-d2@REMOVEbigfoot.com>
    Re: checking if variable is already a memeber of an arr <martin@adoma.se>
    Re: checking if variable is already a memeber of an arr (Abigail)
    Re: checking if variable is already a memeber of an arr <gellyfish@gellyfish.com>
    Re: checking if variable is already a memeber of an arr (A.J. Norman)
    Re: checking if variable is already a memeber of an arr (Tad McClellan)
    Re: checking if variable is already a memeber of an arr (Larry Rosler)
    Re: checking if variable is already a memeber of an arr <flash@pobox.com>
    Re: checking if variable is already a memeber of an arr <emschwar@rmi.net>
    Re: checking if variable is already a memeber of an arr (Sitaram Chamarty)
    Re: checking if variable is already a memeber of an arr (Abigail)
    Re: checking Perl offline <dhenders@cpsgroup.com>
        Could somebody sort me out please? <ian@no-spam4site.co.uk>
    Re: Could somebody sort me out please? <pkg@studbox.uni-stuttgart.de>
    Re: Could somebody sort me out please? <cbrown@rmi.nospam.net>
        Create Thumbnails with Perl !? (Ryan Ngi)
    Re: Create Thumbnails with Perl !? (brian d foy)
        Creating Thumbnail with Perl (Ryan Ngi)
    Re: Creating Thumbnail with Perl (brian d foy)
    Re: Creating Thumbnail with Perl <swiftkid@bigfoot.com>
    Re: Date conversions between Perl & Access <sb@sdm.de>
    Re: date format <gellyfish@gellyfish.com>
        date under win 95/98/NT skyfaye@my-deja.com
    Re: date under win 95/98/NT (Larry Rosler)
    Re: date under win 95/98/NT <marshalc@americasm01.nt.com>
        date under windows 95/98/NT skyfaye@my-deja.com
    Re: date under windows 95/98/NT (Larry Rosler)
        DBI NT installation problem <paragmehta@hotmail.com>
        decimal to binary <carter@computer.org>
    Re: decimal to binary <jrennie@mitre.org>
    Re: decimal to binary (Larry Rosler)
        deleting files <jean.zoch@utoronto.ca>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 13 Jul 1999 11:14:29 +0100
From: "Artoo" <r2-d2@REMOVEbigfoot.com>
Subject: checking if variable is already a memeber of an array?
Message-Id: <378b14d7.0@london.netkonect.net>

Hi All

How can you check whether a variable is already a member of an array with
out using any form of loop?

Thanks for any help
Artoo




------------------------------

Date: Tue, 13 Jul 1999 13:33:55 +0100
From: Martin Quensel <martin@adoma.se>
Subject: Re: checking if variable is already a memeber of an array?
Message-Id: <378B3233.2106E0FF@adoma.se>



Artoo wrote:
> 
> Hi All
> 
> How can you check whether a variable is already a member of an array with
> out using any form of loop?
> 
use a hash instead of an array, might solve it

cheers 
Martin Quensel


------------------------------

Date: 13 Jul 1999 08:34:45 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: checking if variable is already a memeber of an array?
Message-Id: <slrn7omg2s.h7.abigail@alexandra.delanet.com>

Artoo (r2-d2@REMOVEbigfoot.com) wrote on MMCXLII September MCMXCIII in
<URL:news:378b14d7.0@london.netkonect.net>:
** 
** How can you check whether a variable is already a member of an array with
** out using any form of loop?


That question was recently asked here, and its discussion can be found
in deja.com. The answer is 'of course not'. What do you have against
loops anyway? Your question sounds like 'can I write a novel in English
without using verbs?'.

How to check the variable against the array by using a loop is explained
in the FAQ.


Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: 13 Jul 1999 14:41:58 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: checking if variable is already a memeber of an array?
Message-Id: <378b4226@newsread3.dircon.co.uk>

Artoo <r2-d2@REMOVEbigfoot.com> wrote:
> Hi All
> 
> How can you check whether a variable is already a member of an array with
> out using any form of loop?
> 

I would recommend putting the array into a hash:

my @array = qw(blah woof rhubarb caramba zebedee);

my %hash;

@hash{@array} = 1 ;

print "Yow !\n" if exists $hash{'blah'};
print "Aw !\n" if not exists $hash{'zebra'};

/J\
-- 
"Malcolm, what have I told you about putting chocolate near your
crotch?" - Mrs Merton


------------------------------

Date: 13 Jul 1999 15:30:07 +0100
From: nja@le.ac.uk (A.J. Norman)
Subject: Re: checking if variable is already a memeber of an array?
Message-Id: <7mfihf$ih@harrier.le.ac.uk>

 In article <378b4226@newsread3.dircon.co.uk>, Jonathan Stowe 
 <gellyfish@gellyfish.com> wrote: 
 
 > I would recommend putting the array into a hash: 

 M3 T00 - but what if the array can contain multiple copies of the 
 same string, or if the order is important (e.g. a queue or stack, 
 which have to be implemented with lists rather than hashes)?  I can't 
 think of any loop-free method of checking that.  
 

-- 
Andrew Norman, Leicester, England
nja@le.ac.uk || andrew.norman@le.ac.uk
http://www.le.ac.uk/engineering/nja/


------------------------------

Date: Tue, 13 Jul 1999 05:42:11 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: checking if variable is already a memeber of an array?
Message-Id: <jl1fm7.spg.ln@magna.metronet.com>

Artoo (r2-d2@REMOVEbigfoot.com) wrote:

: How can you check whether a variable is already a member of an array with
                            ^^^^^^^^^^

   eh?

   I guess you meant to say "the value of a variable" there.


: out using any form of loop?


   No.

   You must (maybe implicitly though) examine all of the elements
   is a list to see if the one you want is there or not.


   You _can_ find out if the value of a variable is a hash key
   without looping.

   That's what the hash data structure was created for.


   But you already knew that, since you checked the Perl FAQ before
   posting to the Perl newsgroup as good 'net citizens do...


   So what is wrong with the technique given in the FAQ?


   Perl FAQ, part 4:

      "How can I tell whether a list or array contains a certain element?"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 13 Jul 1999 08:07:35 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: checking if variable is already a memeber of an array?
Message-Id: <MPG.11f4f615fae150f9989cb5@nntp.hpl.hp.com>

In article <7mfihf$ih@harrier.le.ac.uk> on 13 Jul 1999 15:30:07 +0100, 
A.J. Norman <nja@le.ac.uk> says...
>  In article <378b4226@newsread3.dircon.co.uk>, Jonathan Stowe 
>  <gellyfish@gellyfish.com> wrote: 
>  
>  > I would recommend putting the array into a hash: 
> 
>  M3 T00 - but what if the array can contain multiple copies of the 
>  same string, or if the order is important (e.g. a queue or stack, 
>  which have to be implemented with lists rather than hashes)?  I can't 
>  think of any loop-free method of checking that.  

Sure, there has to be a loop.  But it can be hidden inside the 'grep' 
function, for example, or inside an implicit join:

  do { local $" = $;; index("$;@array$;", "$;$string$;") >= 0 }

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 13 Jul 1999 16:12:18 GMT
From: Flash Sheridan <flash@pobox.com>
Subject: Re: checking if variable is already a memeber of an array?
Message-Id: <7mfoh2$sqv$1@samba.rahul.net>

In article <slrn7omg2s.h7.abigail@alexandra.delanet.com>,
Abigail <abigail@delanet.com> wrote:
>Artoo (r2-d2@REMOVEbigfoot.com) wrote on MMCXLII September MCMXCIII in
><URL:news:378b14d7.0@london.netkonect.net>:
>** 
>** How can you check whether a variable is already a member of an array with
>** out using any form of loop?
>...
>The answer is 'of course not'. What do you have against
>loops anyway? 

     They're unnecessarily complicated, and prone to programmer error,
when used for what ought to be a language primitive.  Or do you also
eschew multiplication, in favor of addition in a loop? 
     Yes, I know the Cookbook has tolerable solutions; the one I ended up
using was one that it recommended against, since it suited my current
purposes.  A high-level language is supposed to make such questionable
decisions unnecessary, in favor of a standard, safe, and acceptably-
optimized solution. 

Disclaimer: I used to be a set theorist, so I'm obviously biased about
whether membership is primitive.
-- 
<LI><a href="http://pobox.com/~flash">Flash Sheridan</a>
<LI><a href="http://pobox.com/~spug">Stanford PalmPilot User Group</a>


------------------------------

Date: 13 Jul 1999 12:10:32 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: checking if variable is already a memeber of an array?
Message-Id: <xkfvhbol8tj.fsf@valdemar.col.hp.com>

Flash Sheridan <flash@pobox.com> writes:
> Disclaimer: I used to be a set theorist, so I'm obviously biased about
> whether membership is primitive.

Yes, but an array is not a set-- an important distinction which you, as a 
former set theorist, ought to be aware of.  

For more "set-like" behaviour, use a hash.  exists() is a "primitive"
(predefined function, more like, but close enough), it doesn't burden you
with annoying things like ordering your set elements for you, and
operations like intersection and difference are not terribly different
from their array equivalents.

-=Eric


------------------------------

Date: Tue, 13 Jul 1999 21:28:58 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: checking if variable is already a memeber of an array?
Message-Id: <slrn7omttk.pq2.sitaram@diac.com>

On Tue, 13 Jul 1999 11:14:29 +0100, Artoo <r2-d2@REMOVEbigfoot.com> wrote:

>How can you check whether a variable is already a member of an array with
>out using any form of loop?

Without even an implicit loop, this is possible only for hashes,
not for arrays.

Without an explicit loop - well just use grep.


------------------------------

Date: 13 Jul 1999 17:55:14 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: checking if variable is already a memeber of an array?
Message-Id: <slrn7ongtm.h7.abigail@alexandra.delanet.com>

Flash Sheridan (flash@pobox.com) wrote on MMCXLII September MCMXCIII in
<URL:news:7mfoh2$sqv$1@samba.rahul.net>:
<> In article <slrn7omg2s.h7.abigail@alexandra.delanet.com>,
<> Abigail <abigail@delanet.com> wrote:
<> >Artoo (r2-d2@REMOVEbigfoot.com) wrote on MMCXLII September MCMXCIII in
<> ><URL:news:378b14d7.0@london.netkonect.net>:
<> >** 
<> >** How can you check whether a variable is already a member of an array with
<> >** out using any form of loop?
<> >...
<> >The answer is 'of course not'. What do you have against
<> >loops anyway? 
<> 
<>      They're unnecessarily complicated, and prone to programmer error,
<> when used for what ought to be a language primitive.  Or do you also
<> eschew multiplication, in favor of addition in a loop? 

Silly analogon.

<>      Yes, I know the Cookbook has tolerable solutions; the one I ended up
<> using was one that it recommended against, since it suited my current
<> purposes.  A high-level language is supposed to make such questionable
<> decisions unnecessary, in favor of a standard, safe, and acceptably-
<> optimized solution. 
<> 
<> Disclaimer: I used to be a set theorist, so I'm obviously biased about
<> whether membership is primitive.

You can call things a primitive all you want, fact is, you still need
to loop. I can make code that doesn't make it obvious you are using
a loop, and you can hide the implementation in a module and treat it
as a primitive, you still need to loop.

Heck, grep *is* a Perl primitive, but it still loops. You can build a
hash and use fast lookups, but building the hash still requires a loop,
even if you use a map or a slice for it.

I'd be interested in seeing a computational model where one can implement
set membership as a primitive, without using a loop to either find the
element, or to build a datastructure.



Abigail
-- 
sub A::TIESCALAR{bless\my$x=>A};package B;@q=qw/Hacker Another
Perl Just/;use overload'""'=>sub{pop @q};sub A::FETCH{bless\my
$y=>B}; tie my $shoe => 'A';print "$shoe $shoe $shoe $shoe\n";


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: 13 Jul 1999 16:48:41 -0500
From: Dale Henderson <dhenders@cpsgroup.com>
Subject: Re: checking Perl offline
Message-Id: <87k8s4gr0m.fsf@camel.cpsgroup.com>

>>>>> "Tom" == Tom Christiansen <tchrist@mox.perl.com> writes:

    Tom> Just lately I heard on the radio "Log on to something.com"
    Tom> when all the mean is "Connect to http://www.something.com"!
    Tom> These people wouldn't know a login if they saw it.  GRRR!

     heh. One of my pet peeves (sp?) is email me at
     http://www.foobar.com.  Somehow I don't think apache is very good
     at recieving email.






------------------------------

Date: Tue, 13 Jul 1999 07:13:18 GMT
From: "Ian Wilkinson" <ian@no-spam4site.co.uk>
Subject: Could somebody sort me out please?
Message-Id: <01beccfe$8b1c4dc0$0100007f@quibhrgm>

I'll try to be brief - and thanks for any help received.

I'm trying to sort the rows of a flat file database into order, by two different fields - location and price.  I want prices
sorted in descending numeric order within each location, ordered alphabetically, thus:-

East
  50000
  35000
  3500
South
  200000
  12345
  9876

The trick I'm using at the moment is to add the location and price data to the beginning of each record, sort alphabetically,
then remove the prefixed data.  This gives me a partial solution, ie the data is sorted alphabetically by location, then by
price - but the prices are in ascending order.  

How can I get the prices in descending order, please?

Part of my code looks like this:-

#########################################################
# Database fields
# price|location|address|description|telephone|photo|sold|time|who|group|db_id

sub display_property_list {                   ## warts and all !!
                                              # I know this isn't very pretty
                                              # but I only have a small brain
  open(DATAFILE, "$data_file_path") ||
    &file_open_error("$data_file_path",
      "Read Database",__FILE__,__LINE__);

  while(($line = <DATAFILE>)) 
    {
    chop($line); # Chop off extraneous newline
    push(@database_rows, $line);
    } 
  close (DATAFILE);
  
print "<tr><td colspan=4>";
  foreach $row (@database_rows)
    {
    $pad = "";
    @row = split (/\|/, $row);
    $sortable_field1 = $row[1];
    $sortable_field2 = $row[0];
    $price_len = length($sortable_field2);        # Yes. I know!
    for ($i=1; $i <=(10-$price_len); $i++) {      #
    $pad .= "0";                                  #
    }                                             #
    $price = $pad.$row[0];                        # but it works!
    unshift (@row, $price);
    unshift (@row, $sortable_field1);
    $new_row = join ("\|", @row);
    push (@new_rows, $new_row);
    }

   @database_rows = ();
                
#  @sorted_rows = sort { $a <=> $b } (@new_rows); ## ascending numeric
#  @sorted_rows = sort { $b <=> $a } (@new_rows); ## decending numeric

  @sorted_rows = sort { $a cmp $b } (@new_rows);  #  ascending alpha
  
  foreach $sorted_row (@sorted_rows)
    {
    @row = split (/\|/, $sorted_row);

   if ($row[7] eq "yes") { 
     $pic = "<img src=\"http://www.4site.co.uk/homes/media/$row[12]t";
     $pic .= ".jpg\"";  
   } else { 
     $pic = "not available"; 
   }
    shift (@row);
    shift (@row);
    print qq~<tr><td colspan=4><font face="arial"><b>$row[1]</b></font></td><tr>~ if ($row[1] ne $location);
    print qq~
    <tr><td><font face="arial" size="-1">£$row[0]</font>~;

    if ($row[6] eq "yes") {print qq~<br><img src="http://www.4site.co.uk/homes/media/$sold_image">~}
    print qq~
    </td>
    <td><font face="arial" size="-1"><a href="$this_script_url?property=$row[10]">$row[2]</a></font></td>
    <td align="center"><font face="arial" size="-1">$row[4]</font></td>
    <td align="center"><font face="arial" size="-1">$pic</font></td>
    <tr>
    ~;
    }
}
###########################################################

Thanks in anticipation.

-- 
Ian Wilkinson
s/no-spam//i



------------------------------

Date: Tue, 13 Jul 1999 12:47:08 +0200
From: Pete Gilbert <pkg@studbox.uni-stuttgart.de>
Subject: Re: Could somebody sort me out please?
Message-Id: <378B192C.EC37D55E@studbox.uni-stuttgart.de>

Ian Wilkinson wrote:
> 
> I'll try to be brief - and thanks for any help received.
> 
> I'm trying to sort the rows of a flat file database into order, by two different fields - location and price.  I want prices
> sorted in descending numeric order within each location, ordered alphabetically, thus:-

not exactly sure what all your code does, but you might try something
along the lines of:

@row = split (/\|/, $row);
push(@all_rows, \@row);
@sorted_rows = sort { $a->[0] cmp $b->[0] || $a->[1] <=> $b->[1] }
(@all_rows);

--
Pete Gilbert  *** email: pkg@studbox.uni-stuttgart.de


------------------------------

Date: 13 Jul 1999 15:45:27 GMT
From: Brownie  <cbrown@rmi.nospam.net>
Subject: Re: Could somebody sort me out please?
Message-Id: <7mfmun$iqs$2@news1.rmi.net>

Ian Wilkinson <ian@no-spam4site.co.uk> wrote:

> I'm trying to sort the rows of a flat file database 

I see this time and again.
What the hell is a "flat file database"?
sheeesh...


------------------------------

Date: Tue, 13 Jul 1999 15:41:23 GMT
From: ryanngi@hotmail.com (Ryan Ngi)
Subject: Create Thumbnails with Perl !?
Message-Id: <37884e6c.65015078@news.inet.co.th>

which module of perl can resize images for creating thumbnails (both
JPEG and GIF) ? :- O


------------------------------

Date: Tue, 13 Jul 1999 11:01:02 -0500
From: brian@pm.org (brian d foy)
Subject: Re: Create Thumbnails with Perl !?
Message-Id: <brian-1307991101030001@62.bloominton-01rs13-14rt.il.dial-access.att.net>

In article <37884e6c.65015078@news.inet.co.th>, ryanngi@hotmail.com (Ryan
Ngi) wrote:

>which module of perl can resize images for creating thumbnails (both
>JPEG and GIF) ? :- O

Image::Magick

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


------------------------------

Date: Tue, 13 Jul 1999 15:41:26 GMT
From: ryanngi@hotmail.com (Ryan Ngi)
Subject: Creating Thumbnail with Perl
Message-Id: <37892e69.2154201@news.inet.co.th>

Is there any module can resizing images for creating thumbnails !?


------------------------------

Date: Tue, 13 Jul 1999 11:01:42 -0500
From: brian@pm.org (brian d foy)
Subject: Re: Creating Thumbnail with Perl
Message-Id: <brian-1307991101430001@62.bloominton-01rs13-14rt.il.dial-access.att.net>

In article <37892e69.2154201@news.inet.co.th>, ryanngi@hotmail.com (Ryan
Ngi) wrote:

>Is there any module can resizing images for creating thumbnails !?

it's same module i mentioned to your other post with the same question.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


------------------------------

Date: Tue, 13 Jul 1999 20:59:56 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Creating Thumbnail with Perl
Message-Id: <7mgr38$2a03@news.cyber.net.pk>

Ryan Ngi <ryanngi@hotmail.com> wrote in message
news:37892e69.2154201@news.inet.co.th...
: Is there any module can resizing images for creating thumbnails !?

checkout ImageMagick and PerlMagick




------------------------------

Date: 13 Jul 1999 08:11:11 GMT
From: Steffen Beyer <sb@sdm.de>
Subject: Re: Date conversions between Perl & Access
Message-Id: <7mesav$g27$1@solti3.sdm.de>

In article <Pine.LNX.3.96.990712171734.27292C-100000@soolin.ecs.soton.ac.uk>, Dylan Beattie <dmb197@ecs.soton.ac.uk> wrote:

> I'm writing some Perl CGI stuff to talk to an Access database via the
> Win32::ODBC package - it's all working real nicely, except Access and Perl
> use different date formats and it looks like it could be a bit tricky
> converting between the two. Before I dive in and do all the hard work
> myself, anyone know if there's a module that handles it or even just
> script fragment?

There's a recipe in the documentation of Date::Calc which deals with
this (it's intended for Visual Basic, though). I don't know wether
it works for you the way it is, but it might at least give you an
idea how to proceed.

See my sig below for URLs where to download this module from.

Hope this helps!

Regards,
-- 
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/whoami/
    http://www.engelschall.com/u/sb/download/
    http://www.perl.com/CPAN/authors/id/STBEY/


------------------------------

Date: 12 Jul 1999 21:52:29 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: date format
Message-Id: <7mdo2t$4h3$1@gellyfish.btinternet.com>

On Mon, 12 Jul 1999 17:38:32 GMT hoz wrote:
> On Sun, 11 Jul 1999 12:29:18 -0400, tadmc@metronet.com (Tad McClellan)
> wrote:
> 
>>hoz (hoz@rocketmail.com) wrote:
>>
>>: how do I in perl get a date format (YYYYMMDD) that resembles this is
>>: shell `date +%Y%m%d`
>>
>>
>>      my ($mday,$mon,$year) = (localtime)[3..5];
>>      my $date = sprintf "%d%02d%02d", $year+1900, $mon+1, $mday;
>>
>>
> thanks tad,
> you must be a windows perl programmer because when I run your code on
> windows its cool but on a solaris box it blows...
> 

Eh ?  It works fine for me on Linux - there is no reason for it not to
work on any platform - Perhaps you are using a version of Perl earlier than
5 on your Solaris machine ...

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


------------------------------

Date: Tue, 13 Jul 1999 20:20:07 GMT
From: skyfaye@my-deja.com
Subject: date under win 95/98/NT
Message-Id: <7mg71a$teb$1@nnrp1.deja.com>

I'm using the window operating system.  I need to get the current date.
I tried using the command 'date' in my script but it also prompts for
the new date.  I have to press return to ignore it so my script can
continue running.  Is there another command that just returns the
current date?

Thanks,
Hung


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Tue, 13 Jul 1999 13:54:53 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: date under win 95/98/NT
Message-Id: <MPG.11f5477765f50b3989cc1@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7mg71a$teb$1@nnrp1.deja.com> on Tue, 13 Jul 1999 20:20:07 
GMT, skyfaye@my-deja.com <skyfaye@my-deja.com> says...
> I'm using the window operating system.  I need to get the current date.
> I tried using the command 'date' in my script but it also prompts for
> the new date.  I have to press return to ignore it so my script can
> continue running.  Is there another command that just returns the
> current date?

Well, this is formatted better than your first try.  But couldn't you 
have tried to cancel one of them?

You switched from

X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)

to

X-Http-User-Agent: Mozilla/4.61 [en] (X11; I; SunOS 5.5.1 sun4m)

but I'll bet that either of them could have cancelled the article.  Of 
course, you might also consider using a real newsreader instead of a 
browser.  There are many choices.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Tue, 13 Jul 1999 15:57:23 -0500
From: Marshall Culpepper <marshalc@americasm01.nt.com>
Subject: Re: date under win 95/98/NT
Message-Id: <378BA832.90C89A7F@americasm01.nt.com>

($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst)=localtime;

~marshall




------------------------------

Date: Tue, 13 Jul 1999 20:16:43 GMT
From: skyfaye@my-deja.com
Subject: date under windows 95/98/NT
Message-Id: <7mg6qu$tcf$1@nnrp1.deja.com>

I'm using the windows os and I need to get the
date.  I tried using the command
  system("date > date.out").  It returns the date
but it also prompt for a new date.  As a result,
my script won't continue running until I hit
return to ignore it.  Is there a command that
returns the date only?

Thanks,
hungqt




Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Tue, 13 Jul 1999 13:50:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: date under windows 95/98/NT
Message-Id: <MPG.11f546589a6af6b5989cc0@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7mg6qu$tcf$1@nnrp1.deja.com> on Tue, 13 Jul 1999 20:16:43 
GMT, skyfaye@my-deja.com <skyfaye@my-deja.com> says...
> I'm using the windows os and I need to get the
> date.  I tried using the command
>   system("date > date.out").  It returns the date
> but it also prompt for a new date.  As a result,
> my script won't continue running until I hit
> return to ignore it.  Is there a command that
> returns the date only?

Let Perl do it.  `perldoc -f localtime`.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Tue, 13 Jul 1999 14:04:41 -0400
From: Parag Mehta <paragmehta@hotmail.com>
Subject: DBI NT installation problem
Message-Id: <378B7FB8.1F950247@hotmail.com>

Hi,

I am trying to install DBI on win NT and get the following error when I
do make after makefile.pl:

Can't find string terminator "]" anywhere before EOF at -e line 1.
make: *** [pm_to_blib] Error 2

I have cygwin and perl already installed.  I also get the same error
when I do make test and make install and for any other modules I install

the perl way (makefile.pl, make, make test, make install way).

Anyone knows the problem.

Thanks for looking into.

:-)
Regards
Parag
paragmehta@hotmail.com





------------------------------

Date: Tue, 13 Jul 1999 15:05:02 -0400
From: Carter Hamilton <carter@computer.org>
Subject: decimal to binary
Message-Id: <378B8DDE.F00ECE4A@computer.org>

Is there an easy way to convert an integer value to its binary
equivalent?

Carter



------------------------------

Date: Tue, 13 Jul 1999 15:21:27 -0400
From: "Jason D. Rennie" <jrennie@mitre.org>
To: Carter Hamilton <carter@computer.org>
Subject: Re: decimal to binary
Message-Id: <378B91B7.44CF9ADB@mitre.org>

Carter Hamilton wrote:
> 
> Is there an easy way to convert an integer value to its binary
> equivalent?
> 
> Carter

Yes:

  $num = 28474;
  
  while ($num >= 1)
  {
      unshift @digits, $num % 2;
      $num /= 2;
  }
  print @digits;

where $num is the number that you want to convert.

Jason Rennie
781-271-7281
jrennie@mitre.org
http://www.andrew.cmu.edu/~jr6b/


------------------------------

Date: Tue, 13 Jul 1999 13:35:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: decimal to binary
Message-Id: <MPG.11f542d41541c1d6989cbc@nntp.hpl.hp.com>

In article <378B91B7.44CF9ADB@mitre.org> on Tue, 13 Jul 1999 15:21:27 -
0400, Jason D. Rennie <jrennie@mitre.org> says...
> Carter Hamilton wrote:
> > Is there an easy way to convert an integer value to its binary
> > equivalent?
> > 
> > Carter
> 
> Yes:
> 
>   $num = 28474;
>   
>   while ($num >= 1)
>   {
>       unshift @digits, $num % 2;
>       $num /= 2;
>   }
>   print @digits;
> 
> where $num is the number that you want to convert.

The following might well be easier.  It's certainly fewer lines, and 
it's more than 10 times faster according to a quick benchmark:

  print unpack 'B*', pack 'N', $num;

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Tue, 13 Jul 1999 20:31:47 GMT
From: "Jean" <jean.zoch@utoronto.ca>
Subject: deleting files
Message-Id: <FEtt3B.E4u@campus-news-reading.utoronto.ca>

Hi,

I would like to write a perl script that deletes text files in a directory.
The filenames are numbers (like 996134274.txt) and only those which are less
than a certain number (say 997000000.txt) should be deleted.

My problem is that I can't figure out a way to compare my filename with the
number.

How can I store the filename in a temporary variable (so I am able to
compare it)? Also, how can I check each text file in the directory (so that
I can delete all necessary files)?

Any help will be greatly appreciated.

Thanks,
Jean




------------------------------

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 123
*************************************


home help back first fref pref prev next nref lref last post