RE: regular expresion question.

2003-08-14 Thread Jas Grewal \(DHL UK\)
Thanks Rob and James,

I used the match for everything after and including the slash up until the
white space and it works a treat.

-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: 13 August 2003 14:47
To: [EMAIL PROTECTED]
Subject: Re: regular expresion question.


Jas Grewal wrote:
>
> I am trying to write a regular expresion to get a file path from
> a cron file, I have issolated the required lines, but am having
> problems with extracting just the file path and name.
>
> The line is as follows :
>
> 30 23 * * * /usr/lbin/sa/sa1 600 6
>
> I inned to extract just the '/usr/bin/sa/sa1' section.
>
> Any guidance would be appreciated.

Hi Jas.

Take a look at the code below. It will find the first sequence
of non-space characters starting with a slash. Is that what
you need? It depends on what is in the '* * *' stuff.

HTH,

Rob


  use strict;
  use warnings;

  my $line = '30 23 * * * /usr/lbin/sa/sa1 600 6';
  my ($path) = $line =~ m{(/\S+)};
  print $path, "\n";

OUTPUT

  /usr/lbin/sa/sa1





--
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: regular expresion question.

2003-08-14 Thread Rob Dixon
Jas Grewal wrote:
>
> I am trying to write a regular expresion to get a file path from
> a cron file, I have issolated the required lines, but am having
> problems with extracting just the file path and name.
>
> The line is as follows :
>
> 30 23 * * * /usr/lbin/sa/sa1 600 6
>
> I inned to extract just the '/usr/bin/sa/sa1' section.
>
> Any guidance would be appreciated.

Hi Jas.

Take a look at the code below. It will find the first sequence
of non-space characters starting with a slash. Is that what
you need? It depends on what is in the '* * *' stuff.

HTH,

Rob


  use strict;
  use warnings;

  my $line = '30 23 * * * /usr/lbin/sa/sa1 600 6';
  my ($path) = $line =~ m{(/\S+)};
  print $path, "\n";

OUTPUT

  /usr/lbin/sa/sa1





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



RE: regular expresion question.

2003-08-14 Thread Darbesio Eugenio
Try
 
$a = "30 23 * * * /usr/lbin/sa/sa1 600 6";
 
$a =~ m|[^\/]+(.*\/[^\/\s]+)\s[^\/]+|i; 
 
$path = $1;
 
print $path ;
 
 
E.
 
LOQUENDO S.p.A. 
 Vocal Technology and Services 
  www.loquendo.it   
  [EMAIL PROTECTED] 



-Original Message-
From: Jas Grewal (DHL UK) [mailto:[EMAIL PROTECTED]
Sent: mercoledì 13 agosto 2003 15.29
To: [EMAIL PROTECTED] Org
Subject: regular expresion question.


Hi all,
 
I am trying to write a regular expresion to get a file path from a cron file, I have 
issolated the required lines, but am having problems with extracting just the file 
path and name.
 
The line is as follows :
 
30 23 * * * /usr/lbin/sa/sa1 600 6
 
I inned to extract just the '/usr/bin/sa/sa1' section.
 
Any guidance would be appreciated.
 
Jas
 
 




CONFIDENTIALITY NOTICE
This message and its attachments are addressed solely to the persons
above and may contain confidential information. If you have received
the message in error, be informed that any use of the content hereof
is prohibited. Please return it immediately to the sender and delete
the message. Should you have any questions, please contact us by
replying to [EMAIL PROTECTED] Thank you



RE: regular expresion question.

2003-08-14 Thread EUROSPACE SZARINDAR
you also could try this
 
while ()  {
my $FilePath = (split)[5];
print "\$FilePath = $FilePath \n";
 }
 
__DATA__
30 23 * * * /usr/lbin/sa/sa1 600 6
 
 
Michel

-Message d'origine-
De: Jas Grewal (DHL UK) [mailto:[EMAIL PROTECTED]
Date: mercredi 13 août 2003 15:29
À: [EMAIL PROTECTED] Org
Objet: regular expresion question.


Hi all,
 
I am trying to write a regular expresion to get a file path from a cron
file, I have issolated the required lines, but am having problems with
extracting just the file path and name.
 
The line is as follows :
 
30 23 * * * /usr/lbin/sa/sa1 600 6
 
I inned to extract just the '/usr/bin/sa/sa1' section.
 
Any guidance would be appreciated.
 
Jas
 
 


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



Re: regular expresion question.

2003-08-14 Thread James Edward Gray II
On Wednesday, August 13, 2003, at 08:28  AM, Jas Grewal ((DHL UK)) 
wrote:

Hi all,
Howdy.

I am trying to write a regular expresion to get a file path from a 
cron file, I have issolated the required lines, but am having problems 
with extracting just the file path and name.
 
The line is as follows :
 
30 23 * * * /usr/lbin/sa/sa1 600 6
 
I inned to extract just the '/usr/bin/sa/sa1' section.
 
Any guidance would be appreciated.
Not knowing much about your file, I'll assume no entries contain 
whitespace characters.  If this is not true, you'll need to find 
another way.  Given that, if you have a line in $line, try this:

my $path = (split ' ', $line)[5];

That just splits the line on whitespace and chooses the 6th element of 
the resulting list to put in $path.

Hope that helps.

James Gray

Jas
 
 
--
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]