le while construct with
my @files = grep { -f $_ && /\.mp3$/ } readdir DIR;
--
Well, then let's give that Java-Wussie a beating... (me)
Michael Lamertz| +49 2234 204947 / +49 171 6900 310
Sandstr. 122
ash{'$sortedListing[1]'})\n";
Note, that the single quotes inside the double quotes do nothing
special like, hmmm, add more quoting.
--
Well, then let's give that Java-Wussie a beating... (me)
Michael Lamertz| +49 2234 204947 / +49 171
tensions
>
> Is this right?
>
> if ($file1 =~ m/\.vbp$/)
opendir DIR, "/some/dir"
or die "Cannot access /some/dir: $!\n";
my @files = grep { -f && /\.(ds|vb)p$/ } readdir DIR;
closedir DIR;
print @files;
--
Well,
printing "$@" instead of matching it, and you'll see what happened.
--
Well, then let's give that Java-Wussie a beating... (me)
Michael Lamertz| +49 2234 204947 / +49 171 6900 310
Sandstr. 122 |
atistics? Smells
like arrays...
And always remember: When it comes to complex data structures,
Data::Dumper is your friend...
--
Well, then let's give that Java-Wussie a beating... (me)
Michael Lamertz| +49 2234 204947 / +49 171 6900 310
Sandstr. 122
bler times. XOR was 1cycle op and the
whole thing only needed 2 registers. The alternative would have been a
3rd register or a memory/stack operation.
Drieux might provide us with some benchmarks about which one's faster
these days... ;-)
--
Well, then le
On Thu, Jul 18, 2002 at 04:53:46PM +0200, Michael Lamertz wrote:
>
> The 'stat' structure is used. That structure has been filled by the -T,
> since the file has been accessed, regardless of the fact that the test
> for the 'text' type failed.
DUH! Me Idiot,
at' structure is used. That structure has been filled by the -T,
since the file has been accessed, regardless of the fact that the test
for the 'text' type failed.
The stat structure contains properties that rely on the working
directories permissions and thus co
ell when to start slurping the body
my $slurp = 0;
while () {
$slurp = 1 if /^$/;
next unless $slurp;
...
--
If we fail, we will lose the war.
Michael Lamertz
#x27;s to output to *both*, the screen and the file.
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49|
starters:
http://archive.develooper.com/beginners%40perl.org/msg26586.html
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49| [EMAIL PROT
ions of Oracle - by default,
so you need to set ORACLE_SID to an existing test user.
Other than that, everything works pretty much as expected.
--
If we fail, we will lose the war.
Michael Lamertz| +4
--
Also looking into
perldoc perldiag
would have given you the same information, although it's left to
discussion if that message would actually have helped in your special
case, now that I'm looking at it.
--
If we fail,
y.
perldoc perlop
Search for 'Exponentiation'. It's the '**' operator.
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49|
sample code we don't do any checking if it's sane to restore these.
(They might have been overridden by other parts of your
application...)
And the results:
-- snip --
nijushiho:~$ perl th.pl
plain print
You are warned!
Untied
nijushiho:~$ cat /tm
g although the
ssh immediately returned. The 'ps' told us that our PPID was 1 which is
'init'.
That should be it, but I may have forgotten something since it's been a
while that I needed that stuff frequently.
To learn more about this kind of stuff, go and buy the late Ri
my ($cur, $max) = unpack('LL', $lim);
print "CUR: $cur\n";
print "MAX: $max\n";
-- snip lim.pl --
Let's start it...
-- snip --
nijushiho:~$ perl lim.pl
Returned Invalid argument
CUR: 0
MAX: 0
exps).
Actually no, it's not easy.
C++ comments (//...) are no problem since they end at EOL, but the
others (/* ... */) are plain evil, especially with compiler flags for
allowing nested comments.
Look for Text::Balance, that should get you started.
--
If we fail,
ng the ulimit beforehand, or you use the BSD::Resource module
http://search.cpan.org/doc/JHI/BSD-Resource-1.15/Resource.pm
which lets you set the limits directly from within perl.
--
If we fail, we will lose the war.
Michael Lamertz| +
ormal behaviour is to offer a by-continent, then by-country list
of servers to chose from and only inputs a name if it cannot fetch the
mirror list.
--
If we fail, we will lose the war.
Michael Lamertz
operator :-)
Yepp, it's the long awaited yadda-yadda-yadda operator that'll go into
perl6.
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49|
ecision for a specific topic, come back and ask which ones
are prefered.
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49| [EMAIL P
print "1st: @INC\n"; }
use lib qw{/tmp};
BEGIN { local $"="\n"; print "2nd @INC\n"; }
local $"="\n"; print "3rd @INC\n";
-- snip --
--
If we fail, we wi
our side.
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49| [EMAIL PROTECTED]
50733 Cologne |
Now, some OO_Bigott would most probably jump right into my face for
allowing some user from the mob to add 'some_other_value' to our holy
moly class object, but in most cases I don't consider that a problem -
the OO_Bigott jumping, that is ;-)
--
If
s...
sort {
$b->[0]{$b->[1]} <=> $a->[0]{$a->[1]}
}
We can split that up and be a bit more verbose:
sort {
my ($a_orig_item, $a_key) = @$a;
my ($b_orig_item, $b_key) = @$b;
the hash.
> perldoc -q "sort a hash"
Nope, he's looking for a *nested* sort, since he has to find the largest
value 'values %$a' and 'values %$b'.
And as a nice addon, he mentions that the keys of the hashes can vary
for longer functions
Since you're thinking about that way of shortening your code, I guess
you're a more or less experienced programmer that is used to - and not
afraid of - using the language's idioms. So consider above reply as a
guide for the *real* beginners and not nece
shiho:/tmp$ perl x.pl
87
23
12.4
nijushiho:/tmp$
-- snip --
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49|
for selecting
sprite coordinates on double-buffered screens :-)
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49|
@fields = ($1, $2, ...);
Perl's behaviour to leave $nn alone in case the match fails will finally
be fixed with 5.8 as far as I remember, but I could mix that up with
Perl 6.
--
If we fail, we will lose the war.
Michael Lamertz| +49
split /:/;
make that 'split /\s*:\s*/;'
> will give you e.g.
> $key "cpu family"
> $value "6"
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr.
#x27;0',
'xmyrgle fx' => '3:2', # <=== TADAAA
'bogomips' => '1592.52',
'vendor_id' => 'GenuineIntel',
'stepping' => '6',
- snip --
It comes at a price though, so I wouldn't use it to process some 20 million
lines of webserver logs in a nightly run :-)
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr.
are for some days, and then one has exactly the problem the original
post described.
He'll still use cron to schedule his script, but the script will need to
'calculate' the filename of the n-days old logfile.
--
If we fai
o $b would be declared, and
thus no warning.
Or do you have one FAT debugging statement at the end of your function?
But that wouldn't give you the information you needed anyway.
--
If we fail, we will lose the war.
Michael Lamertz| +49 221
ome more generic searches in the page like '/real.*user' or '/user.*id'
since you wouldn't know if it's 'user-id', 'userid' or 'user-id'...
BTW: Searching for 'setruid' in 'perltoc' will lead
s we can be.
Take care - Mike
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49| [EMAIL PROTECT
On Thu, Apr 25, 2002 at 09:36:16AM -0500, Elaine -HFB- Ashton wrote:
> Michael Lamertz [[EMAIL PROTECTED]] quoth:
> *>
> *>PS: I've made the mistake to install quite a handful of modules via
> *>Debian packages instead of CPAN and they are *NOT* installed in
> *>
ces) { ... }
See 'perldoc -f sort' for similar uses of the BLOCK style of filter
functions.
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49| [EMA
On Thu, Apr 25, 2002 at 05:02:10AM -0700, John W. Krahn wrote:
> Michael Lamertz wrote:
> >
> > A.
> > perl -p0i -e 's/sub html_base.*//s' *.cgi
> >
> > reads the whole file in one
>
> > (-0 means $/ = \000),
>
> \000 is a re
documents.
Take a look at 'perldoc -f quotemeta' if you're running into similar
problems when using more complex matching and generated search
expressions.
--
If we fail, we will lose the war.
Michael Lamertz
of it in a
while (1) { ... } # <--- I can't wait for that yadda-yadda-yadda operator in perl
6 :-)
block, so you reopen the fifo whenever it gets closed.
--
If we fail, we will lose the war.
Michael
er to type and most probably slower.
For both versions read 'perldoc perlrun' and look up the details of '-0'
and '-n', and eventually '-l'.
--
If we fail, we will lose the war.
Michael Lamertz|
et a grip
on the system and a feeling for where to look for more information...
Keep going, and keep on posting stuff here, you'll see, it'll get
better, and you most probably wont get flamed by a kid with too much
thestosterone everyday...
--
If we
t list by looking for 'site_perl' in the path.
PS: I've made the mistake to install quite a handful of modules via
Debian packages instead of CPAN and they are *NOT* installed in
'site_perl' but somewhere in '/usr/local/share' and are also *NOT*
registered in perllo
the DOS shell.
> But really,
> I'd just get rid of the NT shell and re-write the thing in all-Perl
> :-)
Yepp, Ditto. Or at least install Cygwin...
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900
shell lacks critical
features like backquotes, the only thing I see that's left is a kind of
status file that you write on error. You can check the existance and
content of that file if your script returns an error.
--
If we fail, we will lose the war.
Michael Lamer
ation might be outdated.
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49| [EMAIL PROTECTED]
50733 Cologne |
ver
remote access software you use (telnet, rsh, ssh).
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49|
/search.cpan.org, perhaps you'll find
something that exactly fits your needs befor rolling your own...
Ask if you run into trouble...
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49
cide what to do at runtime. Stuff the parts that are
dependand on Module_X into a clause checking %INC for the corresponding
key 'Module_X.pm';
Search for '%INC' in
perldoc perlvar
--
If we fail, we will lose the wa
ile the forked childprocess does the hard work.
--
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49| [EMAIL PROTECTED]
50733 Cologne
s for your page.pl.
The big advantage of this is "code reuse", since you can now
use MyPass
in other applications that use the functionality.
That's the caveman approach to perl modules, but it should get you
started. For further information read
perldoc perlmod
e are still alot of differences in the output
of ps among platforms.
BTW: it's
$output = `ps -e`
You don't need the 'system' inside the backquotes. Think about using
qx{} instead of the backquote operator if you need to do more complex
stuff in the shell.
--
ippet' ran as user 'nobody'.
Remember that you need to have appropriate permissions to switch users
(speak you need to be root).
Read Stevens' "Advanced Programming in the Unix Environment" for *all*
the information about
of a HTML page.
Once you have your list of links, the remaining part is mostly
repetitive stuff: create a request object, download, optionally parse,
and again... and again...
Ok, if you're still with me that far down the mail, feel free to ask
about details...
--
d
Compound statements
The concept of a 'scope' is explained here. Also read about 'lexically
declared variables' - I dunno where exactly that stuff is documented.
Leaving out the 'my' is what's solving your problem, because you don't
declare a
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49| [EMAIL PROTECTED]
50733 Cologne |
If we fail, we will lose the war.
Michael Lamertz| +49 221 445420 / +49 171 6900 310
Nordstr. 49| [EMAIL PROTECTED]
50733 Cologne | http
there.
There are things like Mail::Box that'll assist you in parsing emails...
--
If we fail, we will lose the war.
Michael Lamertz| [EMAIL PROTECTED]
Nordstr. 49| http://www.lamertz.net - htt
by far the most
comfortable module I know for that job.
Another popular module is Date::Calc.
--
If we fail, we will lose the war.
Michael Lamertz| [EMAIL PROTECTED]
Nordstr. 49| http://www.lamertz.net - http://www.perl-ron
t's how your array-references look from the
inside.
Now, the 'map' acts kind like a filter, applying some code to each
element of a list and returning a new list that contains all the results
of that codeblock. The codeblock gets its parameters via $_, thus
'$_->[1]'
ght side, so the
whole expression fails immediately.
Since functions like 'unlink' return a value, we can use them as part of
that '&&' statement, which brings us back to our example:
-e $_ && unlink
If the file do
program could print a new environment that your
shell could "eval" - see sh(1) for how to use that.
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50733 Colog
ced maintainer, *sometimes*, difficult
problems need difficult code.
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50733 Cologne| Work: +49 221 3091-121
Germany | Priv: +49 221 445420 / +49 171 6900 310
Andrew Teo ([EMAIL PROTECTED]) wrote:
> Just curious, how would you send an attachment?
Get MIME::Lite from CPAN.
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.
2 buttons - side => 'left' into 2nd floor frame
- optionally create 3rd floor frame
If the remaining 2 buttons take up all the space that's left, this
step isn't needed
- put the last 2 buttons in either the remaining window space or the
guage I would recomend
> more...
Post that on /. if you *really* want some flamefest... :-)
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50733 Cologne| Work: +49 221 3091-121
Germany | Priv: +49 221 445420 / +49 171 6900 310
address it specifically as 'main::function_name'.
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50733 Cologne| Work: +49 221 3091-121
Germany | Priv: +49 221 445420 / +49 171 6900 310
m having trouble stripping $0 of the perl script name.
>
> The standard File::Basename module has a dirname() function
> that will do that for you.
^ there.
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTE
b test2 { print "Module2.pm\n"; }
1;
-- Module2.pm --
Try de-commenting out the '#BROKEN: ' line and see what happens.
Of course, things will become more complicated once you learn about the
Exporter module - perldoc Exporter
--
If we fail,
51.28/s (n=500)
2. foreach: 9 wallclock secs ( 9.58 usr + 0.01 sys = 9.59 CPU) @ 52.14/s (n=500)
3. for: 9 wallclock secs ( 9.44 usr + 0.02 sys = 9.46 CPU) @ 52.85/s (n=500)
kanku-dai:~$
-- mod_new --
Conclusion: The perlfaq6 information seems outd
w you 'su' yourself.
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50733 Cologne| Work: +49 221 3091-121
Germany | Priv: +49 221 445420 / +49 171 6900 310
ugging via
perl -d yourscript.pl
In that case everything works, since your perl is most probably in the
PATH.
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50733 Col
his.
YMMV, but depending on how many xx parts per group you have, you reduce
the number of keys that need sorting by at least a factor of 3 for the
examples you provided. Sounds effective to me :-)
Mike
--
If we fail, we will lose the war.
Michael Lamertz | [
s well, finally do a
make install
and you're done.
I hope I haven't forgotten too much stuff...
Mike
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50
o a 'perldoc perlvar' to find out how to get the current input's
line number.
Mike
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50733 Cologne|
rect data - the one you type into SQL+ - should be sufficient.
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50733 Cologne| Work: +49 221 3091-121
Germany
is legislation now
pending in Congress to change all this. IF YOU CARE, ACT!
http://www.careact.org
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50733 Cologne| Work: +49 221 3091-121
Germany | Priv: +49 221 445420 / +49 171 6900 310
D::Oracle will most probably fail to install from out of the CPAN
module, so be prepared to build this by hand by typing 'look CPAN' in
the CPAN shell prompt.
Keep asking if you're stuck...
Mike
--
If we fail, we will lose the war.
Michael Lamertz
790/DocuShare/documents/b004/File-1156/html/main.htm
Casey's is the way to do it.
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50733 Cologne| Work: +49 221 3
Is there any special reason why you don't regexp your information from
out of the line?
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50733 Cologne| W
to system resources
and better to read. To make it short, use it postfix:
$count{$_}++ foreach ($data=~ /.../);
Check 'perldoc perlfaq6' for reference.
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr.
[EMAIL PROTECTED]
([EMAIL PROTECTED]) wrote:
> i input as arguments a dir and a mask, and i need to get the name's of
> the files of that mask in that dir on an array, how can i do this?
Use the glob function - perldoc -f glob
--
If we fail, we will lose the wa
ystem call doesn't catch
the output of the called program. For this you need either the qx
operator or backticks - also explained in the qx section of the docs.
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nord
86 matches
Mail list logo