Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Re: Listing files

by oaklander (Acolyte)
on Feb 13, 2002 at 12:07 UTC ( #145140=note: print w/replies, xml ) Need Help??

in reply to Re: Listing files
in thread Listing files

Can someone explain what this 'shift' word is doing in this subroutine???
sub get_month_year { my $file = shift; #PLEASE EXPLAIN WHAT SHIFT IS DOING? my @params = stat $file; my @dparams = localtime($params[9]); my $month = $dparams[4] + 1; my $year = $dparams[5] + 1900; return($month, $year); }

Replies are listed 'Best First'.
Re: Re: Re: Listing files
by snapdragon (Monk) on Feb 13, 2002 at 12:36 UTC
    The shift in the code is there to return the directory that is passed in the get_month_year. In the get_month_year sub the parent directory is needed - the shift operator does this by shifting the first value of the array off and returning it (the parent directory 'c:' in this case).

    You can find more info on the shift node.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://145140]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2023-09-26 08:32 GMT
Find Nodes?
    Voting Booth?

    No recent polls found