From: jack jack <[EMAIL PROTECTED]> > I have 2 variables $last_accessed and $owner_line > > $last_accessed=": Last accessed 20-Apr-04.12:57:30 by > [EMAIL PROTECTED]"; > > $owner_line="Owner: opc_bld : rwx (all)"; > > -From $last_accessed i want the foll output in > variables : > > $view_day=20 > $view_month=Apr > $view_year=04
($view_day, $view_month, $view_year) = ($last_accessed =~ /Last accessed (\d+)-(\w+)-(\d+)/); The ()s in the regexp denote the parts I am interested in, \d meand "digit", \w means "word character", + means "1 or more of the previous". > -From $owner_line i want the foll output in variable: > > $owner=opc_bld ($owner) = ($owner_line =~ /Owner:\s*(\S+)\s*:/); \s means "whitespace character", \S means "non-whitespace character". The () around the $owner are mandatory: regexp match returns something else in a scalar context and in a list context! In this case we need the list context in which it returns the matched substrings. I hope this shows how simple are regexps and you'll go and read the perlretut manpage. (run "perldoc perlretut" or go to http://www.perldoc.com/perl5.8.4/pod/perlretut.html) HTH, Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>