[19:01] ne2k: So the issue is that I’m tailing logs from an Adobe product (yeah?) and it rotates logs based on size, current phase of the moon, etc
02[19:02] * Mithaldu (~mithaldu@fw-office.allied-internet.ag) Quit (Ping timeout: 246 seconds)
[19:02] ne2k: So basically I need to scan a directory (/logs/fcs) for files matching qr/fcs-access*log/
03[19:02] * alpha– (~name@95.158.11.2) has joined #perl
[19:02] jessicajames: split and then substr
[19:02] perldoc -f split
[19:02] jessicajames – if ($str = /.(.\S+)/) { warn $1 }
[19:02] robd: so which files do you want to follow? old ones? or just the current one? isn’t the current one always called the same thing?
[19:02] ne2k: no, the log files have a timestamp + random increment
[19:02] or voodoo^Wregex, of course
[19:03] ne2k: It’s seriously a random integer
[19:03] ne2k: not time based, but based on how many clients hit that server
[19:03] instead $str = … its $str =~ jessicajames
02[19:03] * jujugre (~julienb@artis2.probesys.com) Quit (Remote host closed the connection)
[19:03] jessicajames – if ($str =~ /.(.\S+)/) { warn $1 }
[19:03] ne2k: So I can very easily find the last file that was modified, it’s just reading files and performing the file scan in a non-blocking fashion thats hard
[19:03] rodb: how many files do you want to follow at once?
[19:03] oh and anchor it
[19:04] jessicajames – if ($str =~ /^.(.\S+)/) { warn $1 }
[19:04] ne2k: Ideally all the ones that match, but I could do just a single file and jump from file to file depending on which was most recently modified
[19:04] metaperl_, this is a stupid question, but why’d you write the answer in an if statement?
02[19:04] * G2P (~G2P@fw-asn1.ornis.com) Quit (Quit: Leaving.)
[19:04] jessicajames – habit?
[19:04] so yeah
[19:04] could I just do $str = …. ?
[19:05] jessicajames – ($str =~ /^.(.\S+)/) and warn $1
[19:05] rodb: can you use inotify?
[19:05] metaperl_, $str =~ /^.(.\S+)/
[19:05] ?
[19:05] ne2k: Does it work on Linux and FreeBSD?
[19:05] rodb: linux only, I think
[19:05] ne2k: I found out that dnotify was Linux only yesterday? (grumble)
[19:05] ne2k: I can look into it
03[19:05] * meraxes (~dave_doyl@h216-235-10-210.host.egate.net) has joined #perl
[19:05] ne2k: maybe I can just do a linux only script and then something else for FreeBSD
03[19:05] * EyesIsMine (~eyes@unaffiliated/eyesismine) has joined #perl
[19:06] SpiceMan, I like your approach but don’t want to have to declare a whole another variable just for this purpose..
[19:06] jessicajames run this – my $str = «Hither, thither and yonder»; ($str =~ /^.(.\S+)/) and warn $1
[19:06] but yes, I think the substr and split suggestions are more DWIM
[19:06] the regexp is definitely more voodoo-ish
03[19:06] * perlsyntax (~perlsynta@unaffiliated/perlsyntax) has left #perl («Leaving»)
[19:06] yeah regexp still scare me
[19:07] metaperl_: fails
[19:07] you’re right to be scared
[19:07] need a paste of the output?
[19:07] SpiceMan – i ran it here
[19:07] jessicajames you can nest the split and substr if you dont want to use separate vars
02[19:07] * TheoKar (~kvirc@hermes.biol.biologie.uni-tuebingen.de) Quit (Ping timeout: 264 seconds)
[19:07] metaperl_: you don’t have my environment (as per request :p)
03[19:07] * driller_work (~drillerwo@c80-217-81-45.bredband.comhem.se) has joined #perl
03[19:08] * Gatto (~Roberto@host234-37-dynamic.249-95-r.retail.telecomitalia.it) has joined #perl
03[19:09] * ozux (~ozux@77.238.59.39) has joined #perl
02[19:09] * csaba (~csaba@194.249.198.102) Quit (Ping timeout: 250 seconds)
03[19:11] * alvaro_o (~alvaro@189.173.104.128) has joined #perl
[19:11] jessicajames – here are 2 working solutions – https://github.com/metaperl/vcpaste/blob/master/paste/2011-08-16-12-11-18/re.pl
[19:11] eval: substr(split(» «, «foo bar»), 1)
[19:11]
SpiceMan: No output.
[19:12] what
[19:12] substr «foo», «bar», 1
02[19:12] * zhaoyi (~merlin@182.92.247.2) Quit (Quit: leaving)
[19:12] thank you metaperl_
[19:12] eval: substr((split(» «, «foo bar»))[1], 1) # heh
[19:12]
SpiceMan: ar
[19:12] substr split(…), … puts split in scalar context
[19:12] you guys are so helpf