There's one caveat to be aware of with doing a "@array = " type
of file read. If you end up having to work with very large files (or you
don't have a whole lot of RAM to work with), you could be slowing down your
program, maybe drastically if you try to load the entire file into memory
at once,
Rafaqat Ali Chaudhary wrote:
> Got another problem:
>
> Following line of code fails if directory contains more than 1400
> or so files:
>
> 1. my @filelist = glob("input/switch1*.evt");
>
> Any help will be highly appreciated.
>
The following code will do the same thing.
use strict;
use warn
Hello Ling,
> I am doing an xml parser to manage my list of
> mp3s...say after reading my xml file, my variable
> reads:
> $tmp = 'artist#1
> songtitle...'
>
> anyway, you get the idea...now, I want to extract the
> artist...so I do:
>
> $tmp =~ /.*?<\/artist>/;
> $artist = substr($tmp,$-[0]+8,$
> $tmp = 'artist#1
> songtitle...'
If you define this function:
sub get_container {
local ($name, $src) = @_;
$src =~ m/<$name>(.*?)<\/$name>/i;
return $1;
}
Then you can use it as follow:
$artist = get_container('artist', $tmp);
$artist = get_container('title', $tmp);
.
Greetings all,
Given this code:
my $TOKEN_DELIMS = qr/[^\w\-'\$]/;
my $text = # string containing the contents of an mbox file
my @tokens = split /$TOKEN_DELIMS/o, $text;
I end up with a large number of null strings ('') in @tokens. After
RTFMing on split, I assume this is because I am m
Hello,
the problem is, that your regex doesnt seach at beginning or end (for a split a not so
good idea anyway),
but it is a negated character class because of the square brackets and the circumflex
as the first character in it.
It uses any non-word character, apostrophe, '-' or '$' to split th
On Jul 12, Ling F. Zhang said:
>I am doing an xml parser to manage my list of
>mp3s...say after reading my xml file, my variable
>reads:
>$tmp = 'artist#1
>songtitle...'
It might be wiser to use a real XML parser (written in Perl, of course)
instead of writing your own regexes to deal with your i
On Jul 13, David Storrs said:
>Given this code:
>
> my $TOKEN_DELIMS = qr/[^\w\-'\$]/;
> my $text = # string containing the contents of an mbox file
>
> my @tokens = split /$TOKEN_DELIMS/o, $text;
>
>I end up with a large number of null strings ('') in @tokens. After
>RTFMing on split, I assum
> This should be:
>
> open (HANDLE, $listelem) or die "open: $listelem: $!";
>
> That way if the open fails for any reason you'll get a sensible
> error message. (And it avoids the race condition.)
>
Thank you. This is about the 6th version I have tried for
this command, and I like this one
Hi,
I hold the visual studio .net professional CD. How do I install perl on it? Installed
the windows compenents cd. Now I can see a setup page with checkboxes I have to choose
from. Things like:
Path
Languege tools
Etc.
docomuntaation
What to choose, what not.
How to continue after?
Ronen
On Jul 13, Mike Flannigan said:
>> s/\|/h/g foreach @filecontents;
>>
>
>Works like a charm. I sure appreciate your help.
>
>It's going to take me a few years to figure out (even generally)
>what all these commands are doing. Sure is an intriguing
>language.
Then here's another operator to le
Ronen Kfir wrote at Sun, 13 Jul 2003 19:29:27 +0300:
> I hold the visual studio .net professional CD. How do I install perl on
> it? Installed the windows compenents cd. Now I can see a setup page with
> checkboxes I have to choose from. Things like: Path
> Languege tools
> Etc.
> docomuntaation
Vemulakonda Uday Bhaskar wrote at Fri, 11 Jul 2003 08:44:16 +:
> my $SFTP=Net::SSH::Perl->new("xxx.xxx.xxx.xxx") or die "Cant connect";
> $sftp->login("xyz","abc");
>
> the above code is working fine.
How do you know that the code is working fine?
I don't know the Net::SSH::Perl module very
Hari Krishnaan wrote at Thu, 10 Jul 2003 14:03:32 -0700:
> I was using a for loop in the following manner in one of my perl programs.
>
> for($j=31, $n=$initial;$j>=0,$n<=$final;$j--,$n++) {
>
> # Executing statements here
> }
> }
> 1) Is it legal in perl to use the for loop as mentioned above
There is a Perl.NET package that ActiveState distributes. They call it
Visual Perl, and I've heard it works quite well, but it's a little pricy.
-Original Message-
From: Janek Schleicher
To: [EMAIL PROTECTED]
Sent: 7/13/03 5:16 AM
Subject: Re: Perl on Visual studio
Ronen Kfir wrote at
On Jul 13, Janek Schleicher said:
>Hari Krishnaan wrote at Thu, 10 Jul 2003 14:03:32 -0700:
>
>> I was using a for loop in the following manner in one of my perl programs.
>>
>> for($j=31, $n=$initial;$j>=0,$n<=$final;$j--,$n++) {
The test of $j >= 0 is wasted here. Perhaps you meant to say
f
Jeff 'Japhy' Pinyan wrote:
>
> On Jul 13, David Storrs said:
>
> >Given this code:
> >
> > my $TOKEN_DELIMS = qr/[^\w\-'\$]/;
> > my $text = # string containing the contents of an mbox file
> >
> > my @tokens = split /$TOKEN_DELIMS/o, $text;
> >
> >I end up with a large number of null strings
Tim Johnson wrote:
> There's one caveat to be aware of with doing a "@array = " type
> of file read. If you end up having to work with very large files (or you
> don't have a whole lot of RAM to work with), you could be slowing down your
> program, maybe drastically if you try to load the entir
Jeff 'japhy' Pinyan wrote:
> On Jul 13, Mike Flannigan said:
>
> >> s/\|/h/g foreach @filecontents;
> >>
> >
> >Works like a charm. I sure appreciate your help.
> >
> >It's going to take me a few years to figure out (even generally)
> >what all these commands are doing. Sure is an intriguing
On Jul 13, John W. Krahn said:
>Jeff 'Japhy' Pinyan wrote:
>>
>> On Jul 13, David Storrs said:
>>
>> >Given this code:
>> >
>> > my $TOKEN_DELIMS = qr/[^\w\-'\$]/;
>> > my $text = # string containing the contents of an mbox file
>> >
>> > my @tokens = split /$TOKEN_DELIMS/o, $text;
>> >
>> >I e
On Jul 13, Mike Flannigan said:
>> tr/|/h/ for @filecontents;
>>
>> That transliterates ALL |'s to h's, for each string in @filecontents.
>
>Yeah, I was trying to figure out the difference from s///. I guess it
>returns the number of characters replaced (or deleted), as opposed
>to the number o
Jeff 'Japhy' Pinyan wrote:
>
> On Jul 13, John W. Krahn said:
> >
> >And you are not going to need the /o option as qr// compiles the regular
> >expression.
>
> The /o is modifying the split() operator. It's perfectly fine to put it
> there. The increase will be EXCEPTIONALLY minor, but it's st
Hi!,
I have the following hash:
for $j ( 1..20 ) {
for $i ( 0..$DAT{ good_setups }{ $id } ) {
$pin{ order }{ $i }{ $j } = $DAT{ pin}{ $id }{ $i }{ $j }{ 0
} if $DAT{ pin }{ $id }{ $i }{ $j }{ 0 } > 0;
$pin{ depth }{ $i }{ $j } = $DAT{ height }{ $id }{ $i }{ $j }{ 0 }
if $D
On Jul 13, John W. Krahn said:
>Sometimes I am never really sure about /o and the qr// operator accepts
>it as well which is more confusing. :-)
Heh, yeah. That's a very RARE condition indeed.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #
On Sun, Jul 13, 2003 at 08:39:16AM -0400, Jeff 'japhy' Pinyan wrote:
> On Jul 13, David Storrs said:
>
> >Given this code:
> >
> > my $TOKEN_DELIMS = qr/[^\w\-'\$]/;
> > my $text = # string containing the contents of an mbox file
> >
> > my @tokens = split /$TOKEN_DELIMS/o, $text;
> >
> >I end
>> $tmp =~ /.*?<\/artist>/;
>> $artist = substr($tmp,$-[0]+8,$+[0]-$-[0]-9);
>
> How on EARTH did you learn about the @- and @+ arrays, WITHOUT learning
> about the $1, $2, $3, etc. variables? Honestly, which regex tutorial have
> you been using?
What are @- and @+? I've never heard of those..
On Sat, 2003-07-12 at 20:34, [EMAIL PROTECTED] wrote:
> This will work, but wont solve the problem of the alarm exiting the loop
> before the file has been totaly proccessed.
>
Seems to me that it is exactly what is wanted
> On Sat, 12 Jul 2003, Ramprasad wrote:
>
> > [EMAIL PROTECTED] wr
Maybe I'm missing something.. But when the alarm triggers, the program
drops out of the loop.. I think this is normal, what I need is for the
next line of the file to be read. I'm I wrong here?
On 14 Jul 2003, Ramprasad A Padmanabhan wrote:
>
> On Sat, 2003-07-12 at 20:34, [EMAIL PROTECTED] w
Keven.. This looks really good..
Is it the "eval" that keeps the alarm from kicking the script out of the
loop?
I can tell I'll have some reading to do in the morning..
On Sat, 12 Jul 2003, Kevin Pfeiffer wrote:
> In article <[EMAIL PROTECTED]>,
> [EMAIL PROTECTED] wrote:
>
> Hi,
>
> > I'
29 matches
Mail list logo